Spaces:
Runtime error
Runtime error
Commit ·
7eb99e8
1
Parent(s): 377f697
refactor: Update chat_history parameter type in call_admin function and adjust usage
Browse files- backend/models.py +2 -1
- backend/tools.py +8 -4
backend/models.py
CHANGED
|
@@ -174,7 +174,8 @@ class LLMFinanceAnalyzer:
|
|
| 174 |
fn_args = json.loads(fn_args_str)
|
| 175 |
if fn_name == "call_admin":
|
| 176 |
# Add the chat history to the function arguments
|
| 177 |
-
fn_args['chat_history'] = messages
|
|
|
|
| 178 |
|
| 179 |
|
| 180 |
|
|
|
|
| 174 |
fn_args = json.loads(fn_args_str)
|
| 175 |
if fn_name == "call_admin":
|
| 176 |
# Add the chat history to the function arguments
|
| 177 |
+
fn_args['chat_history'] = messages[1:]
|
| 178 |
+
# print(f"call_admin fn_args: {fn_args}")
|
| 179 |
|
| 180 |
|
| 181 |
|
backend/tools.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import json
|
| 2 |
-
from typing import Any, Dict
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
import os
|
| 5 |
import requests
|
|
@@ -151,13 +151,14 @@ def summary_order(promotion_id: str, quantity: int) -> Dict[str, Any]:
|
|
| 151 |
}
|
| 152 |
|
| 153 |
|
| 154 |
-
def call_admin(cause: str, chat_history : Dict[str, str]):
|
| 155 |
#transfer the call to admin..
|
| 156 |
payload = {
|
| 157 |
|
| 158 |
"cause":cause,
|
| 159 |
"history":chat_history
|
| 160 |
}
|
|
|
|
| 161 |
|
| 162 |
try:
|
| 163 |
# 3. Make the API call with a timeout to prevent it from hanging
|
|
@@ -428,13 +429,16 @@ def execute_tool(name: str, arguments: Dict[str, Any]) -> str:
|
|
| 428 |
if __name__ == "__main__":
|
| 429 |
result = call_admin(
|
| 430 |
cause="ตัวอย่างปัญหา: ไม่สามารถทำรายการสั่งซื้อได้",
|
| 431 |
-
chat_history=[{
|
|
|
|
|
|
|
| 432 |
)
|
| 433 |
print(result)
|
| 434 |
result = purchase_product(
|
| 435 |
promotion_id="00001",
|
| 436 |
quantity=1,
|
| 437 |
-
|
|
|
|
| 438 |
address="123 ถนนสุขุมวิท กรุงเทพฯ 10110",
|
| 439 |
tel="0812345678"
|
| 440 |
)
|
|
|
|
| 1 |
import json
|
| 2 |
+
from typing import Any, Dict, List
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
import os
|
| 5 |
import requests
|
|
|
|
| 151 |
}
|
| 152 |
|
| 153 |
|
| 154 |
+
def call_admin(cause: str, chat_history : List[Dict[str, str]]):
|
| 155 |
#transfer the call to admin..
|
| 156 |
payload = {
|
| 157 |
|
| 158 |
"cause":cause,
|
| 159 |
"history":chat_history
|
| 160 |
}
|
| 161 |
+
|
| 162 |
|
| 163 |
try:
|
| 164 |
# 3. Make the API call with a timeout to prevent it from hanging
|
|
|
|
| 429 |
if __name__ == "__main__":
|
| 430 |
result = call_admin(
|
| 431 |
cause="ตัวอย่างปัญหา: ไม่สามารถทำรายการสั่งซื้อได้",
|
| 432 |
+
chat_history=[ {'role': 'assistant', 'metadata': None, 'content': 'สวัสดีค่ะณภัทร 1577Homeshopping ยินดีให้บริการค่ะ', 'options': None}, {'role': 'user', 'content': 'ขอคุยกับแอดมินหน่อยครับ'}]
|
| 433 |
+
|
| 434 |
+
|
| 435 |
)
|
| 436 |
print(result)
|
| 437 |
result = purchase_product(
|
| 438 |
promotion_id="00001",
|
| 439 |
quantity=1,
|
| 440 |
+
name="สมชาย",
|
| 441 |
+
surname="ใจดี",
|
| 442 |
address="123 ถนนสุขุมวิท กรุงเทพฯ 10110",
|
| 443 |
tel="0812345678"
|
| 444 |
)
|