Spaces:
Sleeping
Sleeping
chathistory
Browse files
app.py
CHANGED
|
@@ -145,7 +145,6 @@ def respond(destination, transportation, date, preference, include_options, mino
|
|
| 145 |
- **Budget Preference:** {preference}
|
| 146 |
- **Minors included:** {minors}
|
| 147 |
- **Additional Info:** {', '.join(include_options) if include_options else 'None'}
|
| 148 |
-
Provide a detailed travel guide based on these details.
|
| 149 |
"""
|
| 150 |
travel_guide_output = prompt
|
| 151 |
print("respond", travel_guide_output)
|
|
@@ -163,7 +162,7 @@ def respond(destination, transportation, date, preference, include_options, mino
|
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
-
def chatbot_respond(
|
| 167 |
global travel_guide_output
|
| 168 |
print("chatbot_respond", travel_guide_output)
|
| 169 |
|
|
@@ -171,7 +170,7 @@ def chatbot_respond(messages, chat_history):
|
|
| 171 |
travel_guide_output = "No travel guide has been generated yet. Please enter your travel details first."
|
| 172 |
|
| 173 |
system_message = f"""
|
| 174 |
-
You are
|
| 175 |
|
| 176 |
{travel_guide_output}
|
| 177 |
|
|
@@ -179,9 +178,15 @@ def chatbot_respond(messages, chat_history):
|
|
| 179 |
If the user asks general travel questions, respond accordingly.
|
| 180 |
If they make casual conversation, respond naturally.
|
| 181 |
"""
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
try:
|
| 184 |
-
response = client.chat_completion(messages
|
| 185 |
return response['choices'][0]['message']['content'].strip()
|
| 186 |
except Exception as e:
|
| 187 |
return f"An error occurred: {e}"
|
|
|
|
| 145 |
- **Budget Preference:** {preference}
|
| 146 |
- **Minors included:** {minors}
|
| 147 |
- **Additional Info:** {', '.join(include_options) if include_options else 'None'}
|
|
|
|
| 148 |
"""
|
| 149 |
travel_guide_output = prompt
|
| 150 |
print("respond", travel_guide_output)
|
|
|
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
+
def chatbot_respond(message, chat_history):
|
| 166 |
global travel_guide_output
|
| 167 |
print("chatbot_respond", travel_guide_output)
|
| 168 |
|
|
|
|
| 170 |
travel_guide_output = "No travel guide has been generated yet. Please enter your travel details first."
|
| 171 |
|
| 172 |
system_message = f"""
|
| 173 |
+
You are a travel assistant. Use the following details to assist them:
|
| 174 |
|
| 175 |
{travel_guide_output}
|
| 176 |
|
|
|
|
| 178 |
If the user asks general travel questions, respond accordingly.
|
| 179 |
If they make casual conversation, respond naturally.
|
| 180 |
"""
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
messages = []
|
| 184 |
+
messages.append({"role": "system", "content": system_message})
|
| 185 |
+
|
| 186 |
+
if chat_history:
|
| 187 |
+
messages.extend(chat_history)
|
| 188 |
try:
|
| 189 |
+
response = client.chat_completion(messages)
|
| 190 |
return response['choices'][0]['message']['content'].strip()
|
| 191 |
except Exception as e:
|
| 192 |
return f"An error occurred: {e}"
|