RahulGanapathy commited on
Commit
5a89ad3
Β·
verified Β·
1 Parent(s): c53e8fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -27,16 +27,16 @@ def respond(message, history):
27
 
28
  messages.append({"role": "user", "content": message})
29
 
30
- # Get response from Hugging Face model
31
- response = client.chat_completion(messages, max_tokens=200, temperature=0.7)
32
 
33
- # Extract text from API response
34
  bot_reply = response.choices[0].message.content.strip()
35
 
36
  # βœ… Append correctly formatted tuple to history
37
  history.append((message, bot_reply))
38
 
39
- # βœ… Return chatbot history and state (Fixes ValueError)
40
  return history, history
41
 
42
  # Create Gradio chatbot UI
 
27
 
28
  messages.append({"role": "user", "content": message})
29
 
30
+ # βœ… Ensure streaming is disabled to prevent looping
31
+ response = client.chat_completion(messages, max_tokens=200, temperature=0.7, stream=False)
32
 
33
+ # βœ… Extract response only once
34
  bot_reply = response.choices[0].message.content.strip()
35
 
36
  # βœ… Append correctly formatted tuple to history
37
  history.append((message, bot_reply))
38
 
39
+ # βœ… Return chatbot history and state
40
  return history, history
41
 
42
  # Create Gradio chatbot UI