Aura Gen commited on
Commit
4b046d5
·
verified ·
1 Parent(s): 05e152b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -101,4 +101,18 @@ def chat_endpoint():
101
  stream=True
102
  )
103
 
104
- for
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  stream=True
102
  )
103
 
104
+ for chunk in completion:
105
+ if chunk.choices and chunk.choices[0].delta.content is not None:
106
+ # Frontend (index.html) को बिल्कुल वही JSON स्ट्रक्चर चाहिए जो NVIDIA देता था
107
+ # chunk.model_dump_json() इसे एकदम सही फॉर्मेट में बदल देता है
108
+ chunk_data = chunk.model_dump_json()
109
+ yield f"data: {chunk_data}\n\n"
110
+
111
+ except Exception as e:
112
+ logger.error(f"OpenAI API Error: {str(e)}")
113
+ yield f"data: {{\"error\": \"AI Provider Error: {str(e)}\"}}\n\n"
114
+
115
+ return Response(stream_with_context(generate_stream()), mimetype='text/event-stream')
116
+
117
+ if __name__ == '__main__':
118
+ app.run(host='0.0.0.0', port=7860, debug=False)