DenverJones commited on
Commit
d36b03e
·
verified ·
1 Parent(s): 5e77b3a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
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 + [[user_input, "Please enter a message to start the conversation!"]]
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
- history.append([user_input, bot_response])
 
 
 
 
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