Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,3 @@
|
|
| 1 |
-
Your code is well-structured and seems to be implementing a simple chatbot using the Hugging Face OpenAI API and the Gradio library. However, there are a few issues that need to be addressed:
|
| 2 |
-
|
| 3 |
-
1. The `respond` function does not yield the response after processing all the input messages. You need to add `yield` after `response += token_text`.
|
| 4 |
-
|
| 5 |
-
2. The `client.chat.completions.create` function returns an iterator of completion objects, and the response will be in the form of a list of these objects. You need to iterate over these objects and get the `choices` attribute to get the response text.
|
| 6 |
-
|
| 7 |
-
Here is the corrected code:
|
| 8 |
-
|
| 9 |
-
```python
|
| 10 |
import gradio as gr
|
| 11 |
from openai import OpenAI
|
| 12 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from openai import OpenAI
|
| 3 |
import os
|