Passen Sie die Chat -Antwort in eine Liste in GPT -API einPython

Python-Programme
Anonymous
 Passen Sie die Chat -Antwort in eine Liste in GPT -API ein

Post by Anonymous »

Ich versuche, die Emotionen mit Chatgpt API < /p>
in einem Text zu bekommendef infer_feeling(text):
prompt = f"What feeling is filled in the following text?\nText: {text}\nFeeling:"

response = openai.ChatCompletion.create(
model=model,
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": prompt}
]
)

reply = response.choices[0].message['content']

emotions = ["happiness", "sadness", "anger", "fear", "trust", "curiosity", "hope", "despair"]
< /code>
Was ich möchte, ist die Antwort als Array -Element (Emotionen). Ist es möglich, die Antwort von GPT auf das Element dieses Arrays abzustimmen? Ich möchte>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post