briankchan commited on
Commit
10b507e
·
1 Parent(s): 1b66c59

Stop reusing var name

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -65,7 +65,6 @@ def is_empty(s: str):
65
  def check_content(s: str):
66
  if is_empty(s):
67
  raise gr.exceptions.Error('Please input some text before running.')
68
- print("running: '" + s + "'")
69
 
70
 
71
  def load_chain(api_key, api_type):
@@ -141,13 +140,13 @@ def run(content, chain: LLMChain):
141
  with start_blocking_portal() as portal:
142
  portal.start_task_soon(task)
143
 
144
- content = ""
145
  while True:
146
  next_token = q.get(True, timeout=10)
147
  if next_token is job_done:
148
  break
149
- content += next_token
150
- yield content
151
 
152
  # TODO share code with above
153
  def run_followup(followup_question, input_vars, chain, chat: ChatOpenAI):
@@ -170,13 +169,13 @@ def run_followup(followup_question, input_vars, chain, chat: ChatOpenAI):
170
  with start_blocking_portal() as portal:
171
  portal.start_task_soon(task)
172
 
173
- content = ""
174
  while True:
175
  next_token = q.get(True, timeout=10)
176
  if next_token is job_done:
177
  break
178
- content += next_token
179
- yield content
180
 
181
 
182
  def run_body(content, title, chain, llm):
 
65
  def check_content(s: str):
66
  if is_empty(s):
67
  raise gr.exceptions.Error('Please input some text before running.')
 
68
 
69
 
70
  def load_chain(api_key, api_type):
 
140
  with start_blocking_portal() as portal:
141
  portal.start_task_soon(task)
142
 
143
+ output = ""
144
  while True:
145
  next_token = q.get(True, timeout=10)
146
  if next_token is job_done:
147
  break
148
+ output += next_token
149
+ yield output
150
 
151
  # TODO share code with above
152
  def run_followup(followup_question, input_vars, chain, chat: ChatOpenAI):
 
169
  with start_blocking_portal() as portal:
170
  portal.start_task_soon(task)
171
 
172
+ output = ""
173
  while True:
174
  next_token = q.get(True, timeout=10)
175
  if next_token is job_done:
176
  break
177
+ output += next_token
178
+ yield output
179
 
180
 
181
  def run_body(content, title, chain, llm):