andreska commited on
Commit
d846673
·
verified ·
1 Parent(s): 24f34eb

Convert to stream the response

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -18,14 +18,19 @@ def analyze(project_data, question):
18
  temperature=0.7,
19
  top_p=0.95,
20
  repetition_penalty=1.1,
21
- do_sample=True
 
22
  )
23
 
24
- return response
 
 
 
 
25
 
26
  except Exception as e:
27
  print(f"Error details: {str(e)}")
28
- return f"Error occurred: {str(e)}"
29
 
30
  iface = gr.Interface(
31
  fn=analyze,
 
18
  temperature=0.7,
19
  top_p=0.95,
20
  repetition_penalty=1.1,
21
+ do_sample=True,
22
+ stream=True
23
  )
24
 
25
+ #return response
26
+ response_text = ""
27
+ for token in response_generator:
28
+ response_text += token.text
29
+ yeald response_text
30
 
31
  except Exception as e:
32
  print(f"Error details: {str(e)}")
33
+ yeald f"Error occurred: {str(e)}"
34
 
35
  iface = gr.Interface(
36
  fn=analyze,