Nachrichteninhalt ist immer leer - CalbyaiPython

Python-Programme
Anonymous
 Nachrichteninhalt ist immer leer - Calbyai

Post by Anonymous »

Ich habe an einem Projekt gearbeitet, das eine AI -API benötigt, um mit deren Einschränkungen und vielseitig zu arbeiten. leer.
Im Moment ist hier der Code, den ich verwendet habe: < /p>

Code: Select all

import requests
import json

data = {
"model": "llama-3.1-8b-instruct", # A free model available on Cably AI
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello, how are you today?"
}
],
"stream": False,
}

header = {
"authorization":"Bearer CABLY_AI_BEARER_AUTHORIZATION", # Just needs to be replaced with a real one
"accept": "application/json",
"content-type":"application/json"
}
response = requests.post("https://cablyai.com/v1/chat/completions", data=json.dumps(data, indent=2), headers=header) # Or we can use 'json=data' instead of 'data=json.dumps(data, indent=2)'
print(json.loads(response.text))
< /code>
Und hier ist die Ausgabe aus Ausgabe des Codes (und Einrichten des Trägers) < /p>
{'id': 'chatcmpl-123', 'object': 'chat.completion', 'created': 1677652288, 'model': 'o3-mini-low', 'choices': [{'index': 0, 'message': {'role': 'assistant', 'content': ''}, 'finish_reason': 'stop'}], 'usage': {'prompt_tokens': 0, 'completion_tokens': 0, 'total_tokens': 0}}
Ich hoffe, mein Problem ist jetzt klar.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post