Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -49,11 +49,16 @@ agent = CodeAgent(
|
|
| 49 |
# Define chat function
|
| 50 |
def chat_with_agent(user_input, history):
|
| 51 |
if not user_input.strip():
|
| 52 |
-
return history + [
|
| 53 |
|
|
|
|
| 54 |
response = query({"inputs": user_input, "parameters": {"max_tokens": 100}})
|
| 55 |
bot_response = response.get("generated_text", "Sorry, I couldn't generate a response.")
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
return history
|
| 58 |
|
| 59 |
# Create Gradio Chat UI
|
|
|
|
| 49 |
# Define chat function
|
| 50 |
def chat_with_agent(user_input, history):
|
| 51 |
if not user_input.strip():
|
| 52 |
+
return history + [{"role": "assistant", "content": "Please enter a message to start the conversation!"}]
|
| 53 |
|
| 54 |
+
# Send request to Hugging Face API
|
| 55 |
response = query({"inputs": user_input, "parameters": {"max_tokens": 100}})
|
| 56 |
bot_response = response.get("generated_text", "Sorry, I couldn't generate a response.")
|
| 57 |
+
|
| 58 |
+
# Ensure history is in the correct format
|
| 59 |
+
history.append({"role": "user", "content": user_input})
|
| 60 |
+
history.append({"role": "assistant", "content": bot_response})
|
| 61 |
+
|
| 62 |
return history
|
| 63 |
|
| 64 |
# Create Gradio Chat UI
|