anhkhoiphan commited on
Commit
dc832e8
·
1 Parent(s): caedafc

Tích hợp luồng tạo quiz vào luồng sẵn có, route qua args, không đi vào orchestrator

Browse files
Files changed (1) hide show
  1. core.py +8 -0
core.py CHANGED
@@ -18,6 +18,7 @@ from src.graph import run
18
  from src.nodes import final_response_node, image_response_node
19
  from src.pdf_processing import format_chat_history, pdf_to_markdown
20
  from src.qdrant_store import get_custom_prompt
 
21
  from src.redis_client import redis_client
22
  from src.state import MAX_ITERS, AgentState
23
 
@@ -29,6 +30,8 @@ def final_answer(
29
  pdf_path: Optional[str] = None,
30
  image_path: Optional[str] = None,
31
  pdf_name: Optional[str] = None,
 
 
32
  ) -> tuple[str, str, str | None, str | None]:
33
  """
34
  Khởi tạo AgentState, chạy graph, trả về 4 giá trị.
@@ -52,6 +55,11 @@ def final_answer(
52
  if not query:
53
  raise ValueError("query không được để trống.")
54
 
 
 
 
 
 
55
  custom_prompt = get_custom_prompt(sender_id)
56
 
57
  if pdf_path is not None:
 
18
  from src.nodes import final_response_node, image_response_node
19
  from src.pdf_processing import format_chat_history, pdf_to_markdown
20
  from src.qdrant_store import get_custom_prompt
21
+ from src.quiz import generate_quiz
22
  from src.redis_client import redis_client
23
  from src.state import MAX_ITERS, AgentState
24
 
 
30
  pdf_path: Optional[str] = None,
31
  image_path: Optional[str] = None,
32
  pdf_name: Optional[str] = None,
33
+ gen_quiz: bool = False,
34
+ k_question: Optional[int] = None,
35
  ) -> tuple[str, str, str | None, str | None]:
36
  """
37
  Khởi tạo AgentState, chạy graph, trả về 4 giá trị.
 
55
  if not query:
56
  raise ValueError("query không được để trống.")
57
 
58
+ if gen_quiz:
59
+ t0 = time.perf_counter()
60
+ answer = generate_quiz(query, k_question or 10)
61
+ return answer, f"{time.perf_counter() - t0:.2f}s", None, None
62
+
63
  custom_prompt = get_custom_prompt(sender_id)
64
 
65
  if pdf_path is not None: