acecalisto3 commited on
Commit
959decf
·
verified ·
1 Parent(s): f61d2c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -139,7 +139,16 @@ def respond(
139
  prompt = format_prompt(message, history)
140
 
141
  # Generate response using the InferenceClient
142
- response = client.generate(prompt, max_tokens=max_tokens, temperature=temperature, top_p=top_p)
 
 
 
 
 
 
 
 
 
143
 
144
  # Append the response to history
145
  history.append((message, response))
@@ -147,8 +156,6 @@ def respond(
147
  # Handle the selected task
148
  handle_input(task, storage_location, url1, url2, scrape_interval, content_type)
149
 
150
- return response
151
-
152
  # Create Gradio interface
153
  demo = gr.ChatInterface(
154
  respond,
 
139
  prompt = format_prompt(message, history)
140
 
141
  # Generate response using the InferenceClient
142
+ response = ""
143
+ for message in client.chat_completion(
144
+ prompt,
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))
 
156
  # Handle the selected task
157
  handle_input(task, storage_location, url1, url2, scrape_interval, content_type)
158
 
 
 
159
  # Create Gradio interface
160
  demo = gr.ChatInterface(
161
  respond,