2024-01-21 05:35:29 +01:00
|
|
|
import json
|
|
|
|
|
2024-12-19 13:48:57 +01:00
|
|
|
import requests
|
|
|
|
|
2024-01-21 05:35:29 +01:00
|
|
|
url = "http://localhost:1234/v1/chat/completions"
|
|
|
|
|
|
|
|
payload = {
|
|
|
|
"messages": [
|
|
|
|
{
|
|
|
|
"role": "system",
|
2024-12-19 13:48:57 +01:00
|
|
|
"content": "You are a research engineer specialized in the applications of AI in robotics.",
|
2024-01-21 05:35:29 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"role": "user",
|
2024-12-19 13:48:57 +01:00
|
|
|
"content": "What are some popular AI frameworks for robotics?",
|
|
|
|
},
|
2024-01-21 05:35:29 +01:00
|
|
|
],
|
|
|
|
"max_tokens": 100,
|
2024-12-19 13:48:57 +01:00
|
|
|
"temperature": 0.5,
|
2024-01-21 05:35:29 +01:00
|
|
|
}
|
|
|
|
|
2024-12-19 13:48:57 +01:00
|
|
|
headers = {"Content-Type": "application/json"}
|
2024-01-21 05:35:29 +01:00
|
|
|
|
|
|
|
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:
|
2024-12-19 13:48:57 +01:00
|
|
|
print("Error:", response.status_code)
|