Spaces:
Sleeping
Sleeping
fix error: unfound keys
Browse files- app.py +1 -1
- chatbot_simulator.py +4 -1
app.py
CHANGED
@@ -68,7 +68,7 @@ def chat(user_input, history):
|
|
68 |
valid_response = simulator_app.chat_interaction(user_input, history)
|
69 |
return valid_response
|
70 |
else:
|
71 |
-
invalid_response = "Invalid input. Please use the format:
|
72 |
return invalid_response
|
73 |
|
74 |
|
|
|
68 |
valid_response = simulator_app.chat_interaction(user_input, history)
|
69 |
return valid_response
|
70 |
else:
|
71 |
+
invalid_response = "Invalid input. Please use the format: Number. Description: query"
|
72 |
return invalid_response
|
73 |
|
74 |
|
chatbot_simulator.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
from openai import OpenAI
|
2 |
import json_repair
|
3 |
from transformers import AutoTokenizer
|
|
|
|
|
4 |
|
5 |
|
6 |
class ChatbotSimulation:
|
@@ -149,7 +151,8 @@ Example Output Format:
|
|
149 |
# Parse and update the user state
|
150 |
updated_state = json_repair.loads(updated_state)
|
151 |
|
152 |
-
|
|
|
153 |
transform_prompt = f""""
|
154 |
Transform {updated_state} to a properly formate JSON file.
|
155 |
Example Output Format:
|
|
|
1 |
from openai import OpenAI
|
2 |
import json_repair
|
3 |
from transformers import AutoTokenizer
|
4 |
+
from openai import RateLimitError
|
5 |
+
import time
|
6 |
|
7 |
|
8 |
class ChatbotSimulation:
|
|
|
151 |
# Parse and update the user state
|
152 |
updated_state = json_repair.loads(updated_state)
|
153 |
|
154 |
+
required_keys = {'current_page', 'last_page', 'task_completed'}
|
155 |
+
while not isinstance(updated_state, dict) or not required_keys.issubset(updated_state.keys()):
|
156 |
transform_prompt = f""""
|
157 |
Transform {updated_state} to a properly formate JSON file.
|
158 |
Example Output Format:
|