Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -112,10 +112,12 @@ def generate_response(user_input, model_id):
|
|
112 |
for msg in chat_history:
|
113 |
func_caller.append({"role": "user", "content": f"{str(msg[0])}"})
|
114 |
func_caller.append({"role": "assistant", "content": f"{str(msg[1])}"})
|
|
|
|
|
115 |
|
116 |
# Reformulated prompt based on intent classification
|
117 |
-
reformulated_prompt = reformulate_prompt(user_input,
|
118 |
-
|
119 |
func_caller.append({"role": "user", "content": f'{reformulated_prompt}'})
|
120 |
formatted_prompt = "\n".join([f"{m['role']}: {m['content']}" for m in func_caller])
|
121 |
|
@@ -185,7 +187,7 @@ def handle_post_request():
|
|
185 |
return jsonify({"error": "No JSON data provided"}), 400
|
186 |
|
187 |
message = data.get("inputs", "No message provided.")
|
188 |
-
model_id = data.get("model_id", "
|
189 |
|
190 |
print(f"Processing request with model_id: {model_id}")
|
191 |
model_response = generate_response(message, model_id)
|
|
|
112 |
for msg in chat_history:
|
113 |
func_caller.append({"role": "user", "content": f"{str(msg[0])}"})
|
114 |
func_caller.append({"role": "assistant", "content": f"{str(msg[1])}"})
|
115 |
+
|
116 |
+
highest_label_result = classify_intent(user_input)
|
117 |
|
118 |
# Reformulated prompt based on intent classification
|
119 |
+
reformulated_prompt = reformulate_prompt(user_input, highest_label_result)
|
120 |
+
|
121 |
func_caller.append({"role": "user", "content": f'{reformulated_prompt}'})
|
122 |
formatted_prompt = "\n".join([f"{m['role']}: {m['content']}" for m in func_caller])
|
123 |
|
|
|
187 |
return jsonify({"error": "No JSON data provided"}), 400
|
188 |
|
189 |
message = data.get("inputs", "No message provided.")
|
190 |
+
model_id = data.get("model_id", "openai-community/gpt2-large")
|
191 |
|
192 |
print(f"Processing request with model_id: {model_id}")
|
193 |
model_response = generate_response(message, model_id)
|