Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -88,49 +88,7 @@ def respond(message, history, max_tokens, temperature, top_p):
|
|
88 |
response_container.text(response) # Stream the response
|
89 |
|
90 |
return response
|
91 |
-
|
92 |
-
# # Prepare the list of messages for the chat completion
|
93 |
-
# messages = [{"role": "system", "content": st.session_state.messages[0]["content"]}]
|
94 |
-
|
95 |
-
# for val in history:
|
96 |
-
# if val["role"] == "user":
|
97 |
-
# messages.append({"role": "user", "content": val["content"]})
|
98 |
-
# elif val["role"] == "assistant":
|
99 |
-
# messages.append({"role": "assistant", "content": val["content"]})
|
100 |
-
|
101 |
-
# messages.append({"role": "user", "content": message})
|
102 |
-
|
103 |
-
# # Generate response
|
104 |
-
# response = ""
|
105 |
-
# response_container = st.empty() # Placeholder to update the response text dynamically
|
106 |
-
|
107 |
-
# try:
|
108 |
-
# for item in client.chat_completion(
|
109 |
-
# messages,
|
110 |
-
# max_tokens=max_tokens,
|
111 |
-
# stream=True,
|
112 |
-
# temperature=temperature,
|
113 |
-
# top_p=top_p,
|
114 |
-
# ):
|
115 |
-
# # Get the payload from the response
|
116 |
-
# payload = item['choices'][0]['delta']['content']
|
117 |
-
# # Clean and log the payload
|
118 |
-
# cleaned_payload = payload.lstrip("data:").rstrip("\n")
|
119 |
-
# print(f"Payload received: {cleaned_payload}") # Debugging line
|
120 |
-
|
121 |
-
# try:
|
122 |
-
# token = json.loads(cleaned_payload) # Attempt to parse as JSON
|
123 |
-
# response += token
|
124 |
-
# response_container.text(response) # Stream the response
|
125 |
-
# except json.JSONDecodeError as e:
|
126 |
-
# print(f"JSON decoding failed: {e}")
|
127 |
-
# response_container.text("An error occurred while processing the response.")
|
128 |
-
|
129 |
-
# except Exception as e:
|
130 |
-
# print(f"Error during chat completion: {e}")
|
131 |
-
# response_container.text("An error occurred while generating a response.")
|
132 |
-
|
133 |
-
# return response
|
134 |
|
135 |
# User input
|
136 |
if user_input := st.chat_input("Ask a health question..."):
|
|
|
88 |
response_container.text(response) # Stream the response
|
89 |
|
90 |
return response
|
91 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
# User input
|
94 |
if user_input := st.chat_input("Ask a health question..."):
|