File size: 796 Bytes
cbbe463
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import requests
import json

def generate(message: str,  system_prompt: str="Talk Like Shakespeare", max_tokens: int=2048, temperature: float=0.9):
    url = "https://api.yep.com/v1/chat/completions"
    payload = {
        "stream": False,
        "max_tokens": max_tokens,
        "top_p": 0.7,
        "temperature": temperature,
        "messages": [{"content": f"## SYSTEM MESSAGE: {system_prompt}\n\nQUERY: {message}", "role": "user"}],
        "model": "Mixtral-8x7B-Instruct-v0.1"
    }

    response = requests.post(url, data=json.dumps(payload)).json()
    try : return response['choices'][0]['message']['content']
    except Exception as e : return f"Error processing response: {str(e)}"

if __name__ == "__main__":
    query = "What is the capital of India"
    print(generate(query))