m-ric HF staff commited on
Commit
ce66c61
1 Parent(s): 16f146b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -44,7 +44,7 @@ def generate_key_points(text):
44
  Description: {text}
45
  Thought:
46
  """
47
- return llm_client.text_generation(prompt, max_new_tokens=2000)
48
 
49
 
50
  def parse_llm_output(output):
@@ -139,10 +139,14 @@ def create_map_from_markers(dataframe):
139
 
140
 
141
  def run_display(text):
142
- output = generate_key_points(text)
143
- dataframe, rationale = parse_llm_output(output)
 
 
 
 
144
  map = create_map_from_markers(dataframe)
145
- return map, rationale
146
 
147
 
148
  def select_example(df, data: gr.SelectData):
 
44
  Description: {text}
45
  Thought:
46
  """
47
+ return llm_client.text_generation(prompt, max_new_tokens=2000, stream=True)
48
 
49
 
50
  def parse_llm_output(output):
 
139
 
140
 
141
  def run_display(text):
142
+ current_output = ""
143
+ for output in generate_key_points(text):
144
+ current_output += output
145
+ yield None, "```python\n" + current_output + "\n```"
146
+ current_output = current_output.replace("</s>", "")
147
+ dataframe, _ = parse_llm_output(current_output)
148
  map = create_map_from_markers(dataframe)
149
+ yield map, "```python\n" + current_output + "\n```"
150
 
151
 
152
  def select_example(df, data: gr.SelectData):