vpcom commited on
Commit
f381212
1 Parent(s): 58d18f7

fix: use the right way to extract the generated text from the stream

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -137,16 +137,17 @@ def generate(
137
 
138
  if len(ENDPOINT)>0:
139
  stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
140
- print(f"STREAM: {stream}\n")
141
- stream = stream.generated_text
142
  else:
143
  stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=False, details=True, return_full_text=False)
144
 
145
-
146
-
147
  output = ""
148
  for response in stream:
149
- output += response
 
 
 
 
 
150
 
151
  for stop_str in stop_sequences:
152
  if output.endswith(stop_str):
 
137
 
138
  if len(ENDPOINT)>0:
139
  stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
 
 
140
  else:
141
  stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=False, details=True, return_full_text=False)
142
 
 
 
143
  output = ""
144
  for response in stream:
145
+ print('stream',response)
146
+
147
+ if len(ENDPOINT)>0:
148
+ output += response.generated_text
149
+ else:
150
+ output += response
151
 
152
  for stop_str in stop_sequences:
153
  if output.endswith(stop_str):