Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,9 +3,9 @@ import os
|
|
| 3 |
import shutil
|
| 4 |
import json
|
| 5 |
import torch
|
| 6 |
-
import re
|
| 7 |
import requests
|
| 8 |
-
import transformers
|
| 9 |
import chardet
|
| 10 |
import deepeval
|
| 11 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
@@ -540,7 +540,7 @@ def time_tool(query: str) -> str:
|
|
| 540 |
location = "London"
|
| 541 |
|
| 542 |
location_key = location.lower()
|
| 543 |
-
tz_str =
|
| 544 |
now = datetime.now(ZoneInfo(tz_str))
|
| 545 |
|
| 546 |
# return time or date
|
|
@@ -1269,6 +1269,7 @@ def detect_intent_embedding(query, file_names=[]):
|
|
| 1269 |
best_label = label
|
| 1270 |
return best_label if best_label else "General"
|
| 1271 |
|
|
|
|
| 1272 |
def decide_next(state):
|
| 1273 |
query = state.get("query", "")
|
| 1274 |
file_names = state.get("file_names", [])
|
|
@@ -1306,14 +1307,6 @@ def build_langgraph_gpt_like():
|
|
| 1306 |
graph.add_node("Summarise", summarizer_run)
|
| 1307 |
|
| 1308 |
graph.set_entry_point("Router")
|
| 1309 |
-
|
| 1310 |
-
# Router 條件邏輯:你可以換成你自己的邏輯規則
|
| 1311 |
-
def decide_next(state):
|
| 1312 |
-
query = state.get("query", "")
|
| 1313 |
-
file_names = state.get("file_names", [])
|
| 1314 |
-
label = detect_intent_embedding(query, file_names)
|
| 1315 |
-
return label
|
| 1316 |
-
|
| 1317 |
graph.add_conditional_edges("Router", decide_next, {
|
| 1318 |
"DocQA": "DocQA",
|
| 1319 |
"General": "General",
|
|
|
|
| 3 |
import shutil
|
| 4 |
import json
|
| 5 |
import torch
|
| 6 |
+
# import re
|
| 7 |
import requests
|
| 8 |
+
# import transformers
|
| 9 |
import chardet
|
| 10 |
import deepeval
|
| 11 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
| 540 |
location = "London"
|
| 541 |
|
| 542 |
location_key = location.lower()
|
| 543 |
+
tz_str = location_to_timezone(location)
|
| 544 |
now = datetime.now(ZoneInfo(tz_str))
|
| 545 |
|
| 546 |
# return time or date
|
|
|
|
| 1269 |
best_label = label
|
| 1270 |
return best_label if best_label else "General"
|
| 1271 |
|
| 1272 |
+
# Router 條件邏輯:你可以換成你自己的邏輯規則
|
| 1273 |
def decide_next(state):
|
| 1274 |
query = state.get("query", "")
|
| 1275 |
file_names = state.get("file_names", [])
|
|
|
|
| 1307 |
graph.add_node("Summarise", summarizer_run)
|
| 1308 |
|
| 1309 |
graph.set_entry_point("Router")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1310 |
graph.add_conditional_edges("Router", decide_next, {
|
| 1311 |
"DocQA": "DocQA",
|
| 1312 |
"General": "General",
|