Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -145,21 +145,17 @@ def chat_with_model(prompt, document_section, model_choice='gpt-3.5-turbo'):
|
|
145 |
stream=True
|
146 |
):
|
147 |
|
148 |
-
#for chunk in response:
|
149 |
collected_chunks.append(chunk) # save the event response
|
150 |
chunk_message = chunk['choices'][0]['delta'] # extract the message
|
151 |
collected_messages.append(chunk_message) # save the message
|
152 |
|
153 |
content=chunk["choices"][0].get("delta",{}).get("content")
|
154 |
|
155 |
-
# join method to concatenate the elements of the list
|
156 |
-
# into a single string,
|
157 |
-
# then strip out any empty strings
|
158 |
try:
|
159 |
report.append(content)
|
160 |
if len(content) > 0:
|
161 |
result = "".join(report).strip()
|
162 |
-
result = result.replace("\n", "")
|
163 |
res_box.markdown(f'*{result}*')
|
164 |
except:
|
165 |
st.write('.')
|
|
|
145 |
stream=True
|
146 |
):
|
147 |
|
|
|
148 |
collected_chunks.append(chunk) # save the event response
|
149 |
chunk_message = chunk['choices'][0]['delta'] # extract the message
|
150 |
collected_messages.append(chunk_message) # save the message
|
151 |
|
152 |
content=chunk["choices"][0].get("delta",{}).get("content")
|
153 |
|
|
|
|
|
|
|
154 |
try:
|
155 |
report.append(content)
|
156 |
if len(content) > 0:
|
157 |
result = "".join(report).strip()
|
158 |
+
#result = result.replace("\n", "")
|
159 |
res_box.markdown(f'*{result}*')
|
160 |
except:
|
161 |
st.write('.')
|