lollms-webui/tests/unitary_tests/test_chat_interface.py
2024-01-21 05:35:29 +01:00

33 lines
774 B
Python

import requests
import json
url = "http://localhost:1234/v1/chat/completions"
payload = {
"messages": [
{
"role": "system",
"content": "You are a research engineer specialized in the applications of AI in robotics."
},
{
"role": "user",
"content": "What are some popular AI frameworks for robotics?"
}
],
"max_tokens": 100,
"temperature": 0.5
}
headers = {
"Content-Type": "application/json"
}
response = requests.post(url, data=json.dumps(payload), headers=headers)
if response.status_code == 200:
data = response.json()
print(data)
completion = data["choices"][0]["message"]["content"]
print(completion)
else:
print("Error:", response.status_code)