mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2024-12-25 15:01:03 +00:00
33 lines
774 B
Python
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)
|