Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -140,15 +140,19 @@ def respond(
|
|
140 |
|
141 |
# Generate response using the InferenceClient
|
142 |
response = ""
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
|
|
|
|
|
|
|
|
152 |
|
153 |
# Append the response to history
|
154 |
history.append((message, response))
|
@@ -182,4 +186,4 @@ demo = gr.ChatInterface(
|
|
182 |
)
|
183 |
|
184 |
if __name__ == "__main__":
|
185 |
-
demo.launch(
|
|
|
140 |
|
141 |
# Generate response using the InferenceClient
|
142 |
response = ""
|
143 |
+
try:
|
144 |
+
for message in client.chat_completion(
|
145 |
+
messages=messages,
|
146 |
+
max_tokens=max_tokens,
|
147 |
+
temperature=temperature,
|
148 |
+
top_p=top_p,
|
149 |
+
):
|
150 |
+
print("DEBUG: message:", message) # Debugging statement
|
151 |
+
token = message.choices[0].delta.content
|
152 |
+
response += token
|
153 |
+
yield response
|
154 |
+
except Exception as e:
|
155 |
+
print("Error during chat completion:", e)
|
156 |
|
157 |
# Append the response to history
|
158 |
history.append((message, response))
|
|
|
186 |
)
|
187 |
|
188 |
if __name__ == "__main__":
|
189 |
+
demo.launch()
|