Mistral-8x7b / mistral_8x7b.py
DevsDoCode's picture
Upload 4 files
cbbe463 verified
raw
history blame contribute delete
796 Bytes
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))