Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -139,15 +139,17 @@ def chat_with_model(prompt, document_section, model_choice='gpt-3.5-turbo'):
|
|
139 |
collected_chunks = []
|
140 |
collected_messages = []
|
141 |
for chunk in response:
|
142 |
-
chunk_time = time.time() - start_time # calculate the time delay of the chunk
|
143 |
collected_chunks.append(chunk) # save the event response
|
144 |
chunk_message = chunk['choices'][0]['delta'] # extract the message
|
145 |
collected_messages.append(chunk_message) # save the message
|
146 |
content=chunk["choices"][0].get("delta",{}).get("content")
|
147 |
-
|
148 |
-
#st.write(f"Full response received {chunk_time:.2f} seconds after request")
|
149 |
full_reply_content = ''.join([m.get('content', '') for m in collected_messages])
|
150 |
-
st.write(f"Full conversation received: {full_reply_content}")
|
|
|
|
|
151 |
return full_reply_content
|
152 |
|
153 |
def chat_with_file_contents(prompt, file_content, model_choice='gpt-3.5-turbo'):
|
|
|
139 |
collected_chunks = []
|
140 |
collected_messages = []
|
141 |
for chunk in response:
|
142 |
+
#chunk_time = time.time() - start_time # calculate the time delay of the chunk
|
143 |
collected_chunks.append(chunk) # save the event response
|
144 |
chunk_message = chunk['choices'][0]['delta'] # extract the message
|
145 |
collected_messages.append(chunk_message) # save the message
|
146 |
content=chunk["choices"][0].get("delta",{}).get("content")
|
147 |
+
st.write(f'*{content}*')
|
148 |
+
# st.write(f"Full response received {chunk_time:.2f} seconds after request")
|
149 |
full_reply_content = ''.join([m.get('content', '') for m in collected_messages])
|
150 |
+
# st.write(f"Full conversation received: {full_reply_content}")
|
151 |
+
st.write("Elapsed time:")
|
152 |
+
st.write(time.time() - start_time)
|
153 |
return full_reply_content
|
154 |
|
155 |
def chat_with_file_contents(prompt, file_content, model_choice='gpt-3.5-turbo'):
|