Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

Fix chat API endpoint returning non-serializable ChatCompletion object (#245)

Murtaza Nasir17f6bde5d46c
diff --git a/src/api/api_v1.py b/src/api/api_v1.py
index 4359870e..6ca999da 100644
--- a/src/api/api_v1.py
+++ b/src/api/api_v1.py
@@ -1921,10 +1921,11 @@ Notes: {recording.notes or 'None'}
messages.append({"role": "user", "content": user_message})
try:
- response = call_chat_completion(messages, user_id=current_user.id)
+ completion = call_chat_completion(messages, user_id=current_user.id)
+ reply = completion.choices[0].message.content
return jsonify({
- 'response': response,
+ 'response': reply,
'sources': [] # Could be enhanced to extract relevant segments
})
except Exception as e: