acecalisto3 commited on
Commit
5d596ed
·
verified ·
1 Parent(s): 504b577

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -140,15 +140,19 @@ def respond(
140
 
141
  # Generate response using the InferenceClient
142
  response = ""
143
- for message in client.chat_completion(
144
- messages=messages,
145
- max_tokens=max_tokens,
146
- temperature=temperature,
147
- top_p=top_p,
148
- ):
149
- token = message.choices[0].delta.content
150
- response += token
151
- yield response
 
 
 
 
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(share=True)
 
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()