akhaliq HF Staff commited on
Commit
c9e592c
·
verified ·
1 Parent(s): 0ad5e40

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -25,20 +25,19 @@ def respond(message, history):
25
  # Add current message
26
  prompt += f"User: {message}\nAssistant: "
27
 
28
- # Generate response with streaming
29
- response = ""
30
- for token in pipe(
31
  prompt,
32
  max_new_tokens=256,
33
  temperature=0.7,
34
  do_sample=True,
35
  pad_token_id=pipe.tokenizer.eos_token_id,
36
  return_full_text=False,
37
- stream=True,
38
- ):
39
- chunk = token[0]["generated_text"]
40
- response = chunk
41
- yield response
42
 
43
  # Create the chat interface
44
  demo = gr.ChatInterface(
 
25
  # Add current message
26
  prompt += f"User: {message}\nAssistant: "
27
 
28
+ # Generate response
29
+ response = pipe(
 
30
  prompt,
31
  max_new_tokens=256,
32
  temperature=0.7,
33
  do_sample=True,
34
  pad_token_id=pipe.tokenizer.eos_token_id,
35
  return_full_text=False,
36
+ )
37
+
38
+ # Extract and yield the generated text
39
+ generated_text = response[0]["generated_text"]
40
+ yield generated_text
41
 
42
  # Create the chat interface
43
  demo = gr.ChatInterface(