realtimex-deeptutor 0.5.0.post1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- realtimex_deeptutor/__init__.py +67 -0
- realtimex_deeptutor-0.5.0.post1.dist-info/METADATA +1612 -0
- realtimex_deeptutor-0.5.0.post1.dist-info/RECORD +276 -0
- realtimex_deeptutor-0.5.0.post1.dist-info/WHEEL +5 -0
- realtimex_deeptutor-0.5.0.post1.dist-info/entry_points.txt +2 -0
- realtimex_deeptutor-0.5.0.post1.dist-info/licenses/LICENSE +661 -0
- realtimex_deeptutor-0.5.0.post1.dist-info/top_level.txt +2 -0
- src/__init__.py +40 -0
- src/agents/__init__.py +24 -0
- src/agents/base_agent.py +657 -0
- src/agents/chat/__init__.py +24 -0
- src/agents/chat/chat_agent.py +435 -0
- src/agents/chat/prompts/en/chat_agent.yaml +35 -0
- src/agents/chat/prompts/zh/chat_agent.yaml +35 -0
- src/agents/chat/session_manager.py +311 -0
- src/agents/co_writer/__init__.py +0 -0
- src/agents/co_writer/edit_agent.py +260 -0
- src/agents/co_writer/narrator_agent.py +423 -0
- src/agents/co_writer/prompts/en/edit_agent.yaml +113 -0
- src/agents/co_writer/prompts/en/narrator_agent.yaml +88 -0
- src/agents/co_writer/prompts/zh/edit_agent.yaml +113 -0
- src/agents/co_writer/prompts/zh/narrator_agent.yaml +88 -0
- src/agents/guide/__init__.py +16 -0
- src/agents/guide/agents/__init__.py +11 -0
- src/agents/guide/agents/chat_agent.py +104 -0
- src/agents/guide/agents/interactive_agent.py +223 -0
- src/agents/guide/agents/locate_agent.py +149 -0
- src/agents/guide/agents/summary_agent.py +150 -0
- src/agents/guide/guide_manager.py +500 -0
- src/agents/guide/prompts/en/chat_agent.yaml +41 -0
- src/agents/guide/prompts/en/interactive_agent.yaml +202 -0
- src/agents/guide/prompts/en/locate_agent.yaml +68 -0
- src/agents/guide/prompts/en/summary_agent.yaml +157 -0
- src/agents/guide/prompts/zh/chat_agent.yaml +41 -0
- src/agents/guide/prompts/zh/interactive_agent.yaml +626 -0
- src/agents/guide/prompts/zh/locate_agent.yaml +68 -0
- src/agents/guide/prompts/zh/summary_agent.yaml +157 -0
- src/agents/ideagen/__init__.py +12 -0
- src/agents/ideagen/idea_generation_workflow.py +426 -0
- src/agents/ideagen/material_organizer_agent.py +173 -0
- src/agents/ideagen/prompts/en/idea_generation.yaml +187 -0
- src/agents/ideagen/prompts/en/material_organizer.yaml +69 -0
- src/agents/ideagen/prompts/zh/idea_generation.yaml +187 -0
- src/agents/ideagen/prompts/zh/material_organizer.yaml +69 -0
- src/agents/question/__init__.py +24 -0
- src/agents/question/agents/__init__.py +18 -0
- src/agents/question/agents/generate_agent.py +381 -0
- src/agents/question/agents/relevance_analyzer.py +207 -0
- src/agents/question/agents/retrieve_agent.py +239 -0
- src/agents/question/coordinator.py +718 -0
- src/agents/question/example.py +109 -0
- src/agents/question/prompts/en/coordinator.yaml +75 -0
- src/agents/question/prompts/en/generate_agent.yaml +77 -0
- src/agents/question/prompts/en/relevance_analyzer.yaml +41 -0
- src/agents/question/prompts/en/retrieve_agent.yaml +32 -0
- src/agents/question/prompts/zh/coordinator.yaml +75 -0
- src/agents/question/prompts/zh/generate_agent.yaml +77 -0
- src/agents/question/prompts/zh/relevance_analyzer.yaml +39 -0
- src/agents/question/prompts/zh/retrieve_agent.yaml +30 -0
- src/agents/research/agents/__init__.py +23 -0
- src/agents/research/agents/decompose_agent.py +507 -0
- src/agents/research/agents/manager_agent.py +228 -0
- src/agents/research/agents/note_agent.py +180 -0
- src/agents/research/agents/rephrase_agent.py +263 -0
- src/agents/research/agents/reporting_agent.py +1333 -0
- src/agents/research/agents/research_agent.py +714 -0
- src/agents/research/data_structures.py +451 -0
- src/agents/research/main.py +188 -0
- src/agents/research/prompts/en/decompose_agent.yaml +89 -0
- src/agents/research/prompts/en/manager_agent.yaml +24 -0
- src/agents/research/prompts/en/note_agent.yaml +121 -0
- src/agents/research/prompts/en/rephrase_agent.yaml +58 -0
- src/agents/research/prompts/en/reporting_agent.yaml +380 -0
- src/agents/research/prompts/en/research_agent.yaml +173 -0
- src/agents/research/prompts/zh/decompose_agent.yaml +89 -0
- src/agents/research/prompts/zh/manager_agent.yaml +24 -0
- src/agents/research/prompts/zh/note_agent.yaml +121 -0
- src/agents/research/prompts/zh/rephrase_agent.yaml +58 -0
- src/agents/research/prompts/zh/reporting_agent.yaml +380 -0
- src/agents/research/prompts/zh/research_agent.yaml +173 -0
- src/agents/research/research_pipeline.py +1309 -0
- src/agents/research/utils/__init__.py +60 -0
- src/agents/research/utils/citation_manager.py +799 -0
- src/agents/research/utils/json_utils.py +98 -0
- src/agents/research/utils/token_tracker.py +297 -0
- src/agents/solve/__init__.py +80 -0
- src/agents/solve/analysis_loop/__init__.py +14 -0
- src/agents/solve/analysis_loop/investigate_agent.py +414 -0
- src/agents/solve/analysis_loop/note_agent.py +190 -0
- src/agents/solve/main_solver.py +862 -0
- src/agents/solve/memory/__init__.py +34 -0
- src/agents/solve/memory/citation_memory.py +353 -0
- src/agents/solve/memory/investigate_memory.py +226 -0
- src/agents/solve/memory/solve_memory.py +340 -0
- src/agents/solve/prompts/en/analysis_loop/investigate_agent.yaml +55 -0
- src/agents/solve/prompts/en/analysis_loop/note_agent.yaml +54 -0
- src/agents/solve/prompts/en/solve_loop/manager_agent.yaml +67 -0
- src/agents/solve/prompts/en/solve_loop/precision_answer_agent.yaml +62 -0
- src/agents/solve/prompts/en/solve_loop/response_agent.yaml +90 -0
- src/agents/solve/prompts/en/solve_loop/solve_agent.yaml +75 -0
- src/agents/solve/prompts/en/solve_loop/tool_agent.yaml +38 -0
- src/agents/solve/prompts/zh/analysis_loop/investigate_agent.yaml +53 -0
- src/agents/solve/prompts/zh/analysis_loop/note_agent.yaml +54 -0
- src/agents/solve/prompts/zh/solve_loop/manager_agent.yaml +66 -0
- src/agents/solve/prompts/zh/solve_loop/precision_answer_agent.yaml +62 -0
- src/agents/solve/prompts/zh/solve_loop/response_agent.yaml +90 -0
- src/agents/solve/prompts/zh/solve_loop/solve_agent.yaml +76 -0
- src/agents/solve/prompts/zh/solve_loop/tool_agent.yaml +41 -0
- src/agents/solve/solve_loop/__init__.py +22 -0
- src/agents/solve/solve_loop/citation_manager.py +74 -0
- src/agents/solve/solve_loop/manager_agent.py +274 -0
- src/agents/solve/solve_loop/precision_answer_agent.py +96 -0
- src/agents/solve/solve_loop/response_agent.py +301 -0
- src/agents/solve/solve_loop/solve_agent.py +325 -0
- src/agents/solve/solve_loop/tool_agent.py +470 -0
- src/agents/solve/utils/__init__.py +64 -0
- src/agents/solve/utils/config_validator.py +313 -0
- src/agents/solve/utils/display_manager.py +223 -0
- src/agents/solve/utils/error_handler.py +363 -0
- src/agents/solve/utils/json_utils.py +98 -0
- src/agents/solve/utils/performance_monitor.py +407 -0
- src/agents/solve/utils/token_tracker.py +541 -0
- src/api/__init__.py +0 -0
- src/api/main.py +240 -0
- src/api/routers/__init__.py +1 -0
- src/api/routers/agent_config.py +69 -0
- src/api/routers/chat.py +296 -0
- src/api/routers/co_writer.py +337 -0
- src/api/routers/config.py +627 -0
- src/api/routers/dashboard.py +18 -0
- src/api/routers/guide.py +337 -0
- src/api/routers/ideagen.py +436 -0
- src/api/routers/knowledge.py +821 -0
- src/api/routers/notebook.py +247 -0
- src/api/routers/question.py +537 -0
- src/api/routers/research.py +394 -0
- src/api/routers/settings.py +164 -0
- src/api/routers/solve.py +305 -0
- src/api/routers/system.py +252 -0
- src/api/run_server.py +61 -0
- src/api/utils/history.py +172 -0
- src/api/utils/log_interceptor.py +21 -0
- src/api/utils/notebook_manager.py +415 -0
- src/api/utils/progress_broadcaster.py +72 -0
- src/api/utils/task_id_manager.py +100 -0
- src/config/__init__.py +0 -0
- src/config/accessors.py +18 -0
- src/config/constants.py +34 -0
- src/config/defaults.py +18 -0
- src/config/schema.py +38 -0
- src/config/settings.py +50 -0
- src/core/errors.py +62 -0
- src/knowledge/__init__.py +23 -0
- src/knowledge/add_documents.py +606 -0
- src/knowledge/config.py +65 -0
- src/knowledge/example_add_documents.py +236 -0
- src/knowledge/extract_numbered_items.py +1039 -0
- src/knowledge/initializer.py +621 -0
- src/knowledge/kb.py +22 -0
- src/knowledge/manager.py +782 -0
- src/knowledge/progress_tracker.py +182 -0
- src/knowledge/start_kb.py +535 -0
- src/logging/__init__.py +103 -0
- src/logging/adapters/__init__.py +17 -0
- src/logging/adapters/lightrag.py +184 -0
- src/logging/adapters/llamaindex.py +141 -0
- src/logging/config.py +80 -0
- src/logging/handlers/__init__.py +20 -0
- src/logging/handlers/console.py +75 -0
- src/logging/handlers/file.py +201 -0
- src/logging/handlers/websocket.py +127 -0
- src/logging/logger.py +709 -0
- src/logging/stats/__init__.py +16 -0
- src/logging/stats/llm_stats.py +179 -0
- src/services/__init__.py +56 -0
- src/services/config/__init__.py +61 -0
- src/services/config/knowledge_base_config.py +210 -0
- src/services/config/loader.py +260 -0
- src/services/config/unified_config.py +603 -0
- src/services/embedding/__init__.py +45 -0
- src/services/embedding/adapters/__init__.py +22 -0
- src/services/embedding/adapters/base.py +106 -0
- src/services/embedding/adapters/cohere.py +127 -0
- src/services/embedding/adapters/jina.py +99 -0
- src/services/embedding/adapters/ollama.py +116 -0
- src/services/embedding/adapters/openai_compatible.py +96 -0
- src/services/embedding/client.py +159 -0
- src/services/embedding/config.py +156 -0
- src/services/embedding/provider.py +119 -0
- src/services/llm/__init__.py +152 -0
- src/services/llm/capabilities.py +313 -0
- src/services/llm/client.py +302 -0
- src/services/llm/cloud_provider.py +530 -0
- src/services/llm/config.py +200 -0
- src/services/llm/error_mapping.py +103 -0
- src/services/llm/exceptions.py +152 -0
- src/services/llm/factory.py +450 -0
- src/services/llm/local_provider.py +347 -0
- src/services/llm/providers/anthropic.py +95 -0
- src/services/llm/providers/base_provider.py +93 -0
- src/services/llm/providers/open_ai.py +83 -0
- src/services/llm/registry.py +71 -0
- src/services/llm/telemetry.py +40 -0
- src/services/llm/types.py +27 -0
- src/services/llm/utils.py +333 -0
- src/services/prompt/__init__.py +25 -0
- src/services/prompt/manager.py +206 -0
- src/services/rag/__init__.py +64 -0
- src/services/rag/components/__init__.py +29 -0
- src/services/rag/components/base.py +59 -0
- src/services/rag/components/chunkers/__init__.py +18 -0
- src/services/rag/components/chunkers/base.py +34 -0
- src/services/rag/components/chunkers/fixed.py +71 -0
- src/services/rag/components/chunkers/numbered_item.py +94 -0
- src/services/rag/components/chunkers/semantic.py +97 -0
- src/services/rag/components/embedders/__init__.py +14 -0
- src/services/rag/components/embedders/base.py +32 -0
- src/services/rag/components/embedders/openai.py +63 -0
- src/services/rag/components/indexers/__init__.py +18 -0
- src/services/rag/components/indexers/base.py +35 -0
- src/services/rag/components/indexers/graph.py +172 -0
- src/services/rag/components/indexers/lightrag.py +156 -0
- src/services/rag/components/indexers/vector.py +146 -0
- src/services/rag/components/parsers/__init__.py +18 -0
- src/services/rag/components/parsers/base.py +35 -0
- src/services/rag/components/parsers/markdown.py +52 -0
- src/services/rag/components/parsers/pdf.py +115 -0
- src/services/rag/components/parsers/text.py +86 -0
- src/services/rag/components/retrievers/__init__.py +18 -0
- src/services/rag/components/retrievers/base.py +34 -0
- src/services/rag/components/retrievers/dense.py +200 -0
- src/services/rag/components/retrievers/hybrid.py +164 -0
- src/services/rag/components/retrievers/lightrag.py +169 -0
- src/services/rag/components/routing.py +286 -0
- src/services/rag/factory.py +234 -0
- src/services/rag/pipeline.py +215 -0
- src/services/rag/pipelines/__init__.py +32 -0
- src/services/rag/pipelines/academic.py +44 -0
- src/services/rag/pipelines/lightrag.py +43 -0
- src/services/rag/pipelines/llamaindex.py +313 -0
- src/services/rag/pipelines/raganything.py +384 -0
- src/services/rag/service.py +244 -0
- src/services/rag/types.py +73 -0
- src/services/search/__init__.py +284 -0
- src/services/search/base.py +87 -0
- src/services/search/consolidation.py +398 -0
- src/services/search/providers/__init__.py +128 -0
- src/services/search/providers/baidu.py +188 -0
- src/services/search/providers/exa.py +194 -0
- src/services/search/providers/jina.py +161 -0
- src/services/search/providers/perplexity.py +153 -0
- src/services/search/providers/serper.py +209 -0
- src/services/search/providers/tavily.py +161 -0
- src/services/search/types.py +114 -0
- src/services/setup/__init__.py +34 -0
- src/services/setup/init.py +285 -0
- src/services/tts/__init__.py +16 -0
- src/services/tts/config.py +99 -0
- src/tools/__init__.py +91 -0
- src/tools/code_executor.py +536 -0
- src/tools/paper_search_tool.py +171 -0
- src/tools/query_item_tool.py +310 -0
- src/tools/question/__init__.py +15 -0
- src/tools/question/exam_mimic.py +616 -0
- src/tools/question/pdf_parser.py +211 -0
- src/tools/question/question_extractor.py +397 -0
- src/tools/rag_tool.py +173 -0
- src/tools/tex_chunker.py +339 -0
- src/tools/tex_downloader.py +253 -0
- src/tools/web_search.py +71 -0
- src/utils/config_manager.py +206 -0
- src/utils/document_validator.py +168 -0
- src/utils/error_rate_tracker.py +111 -0
- src/utils/error_utils.py +82 -0
- src/utils/json_parser.py +110 -0
- src/utils/network/circuit_breaker.py +79 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
Example script that demonstrates how to use the Agent coordinator.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import asyncio
|
|
8
|
+
import json
|
|
9
|
+
import logging
|
|
10
|
+
import os
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
import sys
|
|
13
|
+
|
|
14
|
+
from dotenv import load_dotenv
|
|
15
|
+
|
|
16
|
+
os.environ["RAGANYTHING_VERBOSE"] = "0"
|
|
17
|
+
os.environ["LIGHTRAG_VERBOSE"] = "0"
|
|
18
|
+
|
|
19
|
+
logging.basicConfig(level=logging.WARNING, force=True)
|
|
20
|
+
for logger_name in ["lightrag", "raganything", "nano-vectordb", "openai", "httpx", "httpcore"]:
|
|
21
|
+
logger = logging.getLogger(logger_name)
|
|
22
|
+
logger.setLevel(logging.WARNING)
|
|
23
|
+
logger.propagate = False
|
|
24
|
+
|
|
25
|
+
project_root = Path(__file__).resolve().parent.parent.parent.parent.parent.parent.parent
|
|
26
|
+
sys.path.insert(0, str(project_root))
|
|
27
|
+
|
|
28
|
+
load_dotenv(dotenv_path=project_root / ".env", override=False)
|
|
29
|
+
|
|
30
|
+
from src.agents.question import AgentCoordinator
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
async def run_single_example(coordinator: AgentCoordinator):
|
|
34
|
+
"""Generate a single question."""
|
|
35
|
+
requirement = {
|
|
36
|
+
"knowledge_point": "Lagrange multipliers",
|
|
37
|
+
"difficulty": "medium",
|
|
38
|
+
"question_type": "written",
|
|
39
|
+
"additional_requirements": "Focus on a computational exercise that demonstrates how to apply Lagrange multipliers.",
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
result = await coordinator.generate_question(requirement)
|
|
43
|
+
|
|
44
|
+
print("\n" + "=" * 80)
|
|
45
|
+
print("📊 Single-question result")
|
|
46
|
+
print("=" * 80)
|
|
47
|
+
|
|
48
|
+
if result.get("success"):
|
|
49
|
+
question = result["question"]
|
|
50
|
+
validation = result["validation"]
|
|
51
|
+
|
|
52
|
+
print(f"\n✓ Success in {result['rounds']} round(s)")
|
|
53
|
+
print(f"\nType: {question.get('question_type')}")
|
|
54
|
+
print(f"\nQuestion:\n{question.get('question')}")
|
|
55
|
+
|
|
56
|
+
if question.get("options"):
|
|
57
|
+
print("\nOptions:")
|
|
58
|
+
for key, value in question["options"].items():
|
|
59
|
+
print(f" {key}. {value}")
|
|
60
|
+
|
|
61
|
+
print(f"\nCorrect answer: {question.get('correct_answer')}")
|
|
62
|
+
print(f"\nExplanation:\n{question.get('explanation')}")
|
|
63
|
+
|
|
64
|
+
print(f"\nValidation decision: {validation.get('decision')}")
|
|
65
|
+
print(f"Validation reasoning: {validation.get('reasoning')}")
|
|
66
|
+
else:
|
|
67
|
+
error_type = result.get("error")
|
|
68
|
+
if error_type == "task_rejected":
|
|
69
|
+
print("\n🚫 Task rejected")
|
|
70
|
+
print(f"Reason: {result.get('reason')}")
|
|
71
|
+
print(
|
|
72
|
+
"\n💡 Tip: try a different knowledge point or ensure the knowledge base contains supporting material."
|
|
73
|
+
)
|
|
74
|
+
else:
|
|
75
|
+
print(f"\n✗ Failed: {error_type}")
|
|
76
|
+
if result.get("last_question"):
|
|
77
|
+
print("\nLast attempted question:")
|
|
78
|
+
print(json.dumps(result["last_question"], ensure_ascii=False, indent=2))
|
|
79
|
+
if result.get("last_validation"):
|
|
80
|
+
print("\nLast validation result:")
|
|
81
|
+
print(json.dumps(result["last_validation"], ensure_ascii=False, indent=2))
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
async def run_batch_example(coordinator: AgentCoordinator):
|
|
85
|
+
"""Generate multiple questions from a natural-language prompt."""
|
|
86
|
+
prompt = (
|
|
87
|
+
"Medium questions on Multivariable Functions, Limits and Continuity, and Differentiation"
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
batch_result = await coordinator.generate_questions_from_prompt(
|
|
91
|
+
requirement_text=prompt, num_questions=3
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
print("\n" + "=" * 80)
|
|
95
|
+
print("📦 Batch generation result")
|
|
96
|
+
print("=" * 80)
|
|
97
|
+
print(json.dumps(batch_result, ensure_ascii=False, indent=2))
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
async def main():
|
|
101
|
+
"""Entry point for the example script."""
|
|
102
|
+
coordinator = AgentCoordinator(max_rounds=10, kb_name="math2211", output_dir="./output")
|
|
103
|
+
|
|
104
|
+
# await run_single_example(coordinator)
|
|
105
|
+
await run_batch_example(coordinator)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
if __name__ == "__main__":
|
|
109
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
generate_search_queries: |
|
|
2
|
+
system: |
|
|
3
|
+
【Role】You are a knowledge base retrieval assistant, preparing for question generation.
|
|
4
|
+
|
|
5
|
+
【Current Task】Generate knowledge point retrieval queries to find theoretical explanations, definitions, and theorems in the knowledge base.
|
|
6
|
+
⚠️ Key: You are not generating questions now! You are looking for theoretical knowledge needed for question generation!
|
|
7
|
+
|
|
8
|
+
【Output Rules】
|
|
9
|
+
1. Only output pure knowledge point names (theorem names, concept names, method names)
|
|
10
|
+
2. Each query should be 2-5 words
|
|
11
|
+
3. Do not include functions, numerical values, or calculation tasks
|
|
12
|
+
4. Do not use questions or task descriptions
|
|
13
|
+
|
|
14
|
+
user_template: |
|
|
15
|
+
The user's question generation requirement is:
|
|
16
|
+
{requirement_text}
|
|
17
|
+
|
|
18
|
+
Please extract {num_queries} pure knowledge point names from it for knowledge base retrieval.
|
|
19
|
+
|
|
20
|
+
Correct examples:
|
|
21
|
+
✅ Taylor theorem
|
|
22
|
+
✅ Lagrange multipliers
|
|
23
|
+
✅ critical points
|
|
24
|
+
|
|
25
|
+
Incorrect examples (do not generate):
|
|
26
|
+
❌ Apply Taylor's Theorem to approximate f(x,y)=... (This is a question)
|
|
27
|
+
❌ Find and classify critical points (This is a task)
|
|
28
|
+
❌ Use Lagrange multipliers to find maximum (This is an instruction)
|
|
29
|
+
|
|
30
|
+
Return in JSON format: {{"queries": ["knowledge point 1", "knowledge point 2", ...]}}, containing exactly {num_queries} knowledge point names.
|
|
31
|
+
|
|
32
|
+
check_retrieval_relevance: |
|
|
33
|
+
system: |
|
|
34
|
+
You evaluate whether retrieved knowledge is relevant to a user's request.
|
|
35
|
+
Respond in JSON with key "relevant" (true/false) and optional "reason".
|
|
36
|
+
|
|
37
|
+
user_template: |
|
|
38
|
+
User request:
|
|
39
|
+
{requirement_text}
|
|
40
|
+
|
|
41
|
+
Retrieved knowledge summary:
|
|
42
|
+
{knowledge_summary}
|
|
43
|
+
|
|
44
|
+
Is the retrieved knowledge substantively relevant to the request?
|
|
45
|
+
|
|
46
|
+
generate_child_requirements: |
|
|
47
|
+
system: |
|
|
48
|
+
You are a curriculum designer. Given a base requirement and knowledge summary,
|
|
49
|
+
create distinct sub-requirements that all test the SAME knowledge point.
|
|
50
|
+
Each sub-requirement must describe a unique scenario and reasoning flow.
|
|
51
|
+
Output JSON with key "requirements" (array of length requested) where each item has:
|
|
52
|
+
"title", "question_type", "difficulty", "additional_requirements".
|
|
53
|
+
|
|
54
|
+
user_template: |
|
|
55
|
+
Base requirement:
|
|
56
|
+
{base_requirement}
|
|
57
|
+
|
|
58
|
+
Knowledge summary:
|
|
59
|
+
{knowledge_summary}
|
|
60
|
+
|
|
61
|
+
Generate exactly {num_questions} sub-requirements in JSON.
|
|
62
|
+
|
|
63
|
+
interpret_requirement_text: |
|
|
64
|
+
system: |
|
|
65
|
+
You are an instruction parser for an exam-question generator.
|
|
66
|
+
Given a natural-language request, extract the core knowledge point,
|
|
67
|
+
difficulty (easy/medium/hard), preferred question type (choice/written),
|
|
68
|
+
and additional requirements. Return JSON with keys:
|
|
69
|
+
"knowledge_point", "difficulty", "question_type", "additional_requirements".
|
|
70
|
+
|
|
71
|
+
user_template: |
|
|
72
|
+
Requirement:
|
|
73
|
+
{requirement_text}
|
|
74
|
+
|
|
75
|
+
Return JSON only.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
system: |
|
|
2
|
+
You are a professional Question Generation Agent. Your responsibilities are:
|
|
3
|
+
1. Generate high-quality questions based on requirements
|
|
4
|
+
2. Use retrieved background knowledge to ensure accuracy
|
|
5
|
+
3. Express knowledge in the same way as the knowledge base
|
|
6
|
+
|
|
7
|
+
Important notes:
|
|
8
|
+
- Questions must be rigorous and accurate, based on knowledge base content
|
|
9
|
+
- Calculation problems should have substantial computation, not too simple
|
|
10
|
+
- Use the provided background knowledge as the foundation for question generation
|
|
11
|
+
- Multiple choice questions must have only one correct answer
|
|
12
|
+
- Solutions/explanations should be detailed and clear
|
|
13
|
+
- Chain-of-thought: reason internally step-by-step, but only output the final JSON
|
|
14
|
+
|
|
15
|
+
generate: |
|
|
16
|
+
Generate a question based on the following information:
|
|
17
|
+
|
|
18
|
+
Requirements:
|
|
19
|
+
{requirements}
|
|
20
|
+
|
|
21
|
+
Focus/Angle:
|
|
22
|
+
{focus}
|
|
23
|
+
|
|
24
|
+
Background Knowledge:
|
|
25
|
+
{knowledge}
|
|
26
|
+
|
|
27
|
+
Thinking instructions:
|
|
28
|
+
- First, silently plan the scenario and reasoning steps to ensure the question is coherent.
|
|
29
|
+
- Do not reveal the intermediate reasoning; after planning, output only the final JSON.
|
|
30
|
+
|
|
31
|
+
CRITICAL: Return ONLY valid JSON. Do not wrap in markdown code blocks.
|
|
32
|
+
Your response must start with {{ and end with }}.
|
|
33
|
+
|
|
34
|
+
Please generate a question in JSON format:
|
|
35
|
+
{{
|
|
36
|
+
"question_type": "choice" or "written",
|
|
37
|
+
"question": "question content",
|
|
38
|
+
"options": {{"A": "...", "B": "...", "C": "...", "D": "..."}} // only for multiple choice
|
|
39
|
+
"correct_answer": "correct answer",
|
|
40
|
+
"explanation": "detailed explanation"
|
|
41
|
+
}}
|
|
42
|
+
|
|
43
|
+
generate_with_reference: |
|
|
44
|
+
Generate a new question that draws inspiration from the following reference but is clearly distinct in scenario and reasoning:
|
|
45
|
+
|
|
46
|
+
Reference question:
|
|
47
|
+
{reference_question}
|
|
48
|
+
|
|
49
|
+
Requirements:
|
|
50
|
+
{requirements}
|
|
51
|
+
|
|
52
|
+
Background Knowledge:
|
|
53
|
+
{knowledge}
|
|
54
|
+
|
|
55
|
+
Requirements:
|
|
56
|
+
1. **Maintain same core knowledge and difficulty**: Concepts being tested must stay aligned
|
|
57
|
+
2. **Maintain the exact same knowledge scope**: Keep the same mathematical topic
|
|
58
|
+
3. **Change the scenario/background**: Use different objects, contexts, or framing
|
|
59
|
+
4. **Change the calculation process**: Rearrange steps or add sub-questions
|
|
60
|
+
5. **Change specific data and symbols**: Use new parameters, values, constants
|
|
61
|
+
6. **Maintain overall structure**: Keep similar number/type of sub-questions
|
|
62
|
+
7. **Forbidden**:
|
|
63
|
+
- Only modifying numerical values or variable names
|
|
64
|
+
- Repeating the same statement with an added explanation
|
|
65
|
+
- Copying the same setup without new twists
|
|
66
|
+
|
|
67
|
+
CRITICAL: Return ONLY valid JSON. Do not wrap in markdown code blocks.
|
|
68
|
+
Your response must start with {{ and end with }}.
|
|
69
|
+
|
|
70
|
+
Please generate question in JSON format:
|
|
71
|
+
{{
|
|
72
|
+
"question_type": "choice" or "written",
|
|
73
|
+
"question": "question content",
|
|
74
|
+
"options": {{"A": "...", "B": "...", "C": "...", "D": "..."}} // only for multiple choice
|
|
75
|
+
"correct_answer": "correct answer",
|
|
76
|
+
"explanation": "detailed explanation"
|
|
77
|
+
}}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
system: |
|
|
2
|
+
You are an educational content analyst specializing in analyzing the relationship
|
|
3
|
+
between exam questions and knowledge base content.
|
|
4
|
+
|
|
5
|
+
Your task is to analyze the relevance between a question and the knowledge base,
|
|
6
|
+
NOT to validate or reject the question. All questions are accepted.
|
|
7
|
+
|
|
8
|
+
analyze_relevance: |
|
|
9
|
+
Analyze the relevance between the following exam question and the knowledge base content.
|
|
10
|
+
|
|
11
|
+
Question:
|
|
12
|
+
{question}
|
|
13
|
+
|
|
14
|
+
Knowledge Base Content:
|
|
15
|
+
{knowledge}
|
|
16
|
+
|
|
17
|
+
Please analyze and provide a JSON response with the following structure:
|
|
18
|
+
{{
|
|
19
|
+
"relevance": "high" or "partial",
|
|
20
|
+
"kb_coverage": "Describe specifically what concepts, theories, or methods from the knowledge base this question tests. List the key knowledge points that are directly relevant.",
|
|
21
|
+
"extension_points": "If relevance is 'partial', describe what aspects of this question extend beyond the knowledge base content. What additional knowledge does it require? Leave empty if relevance is 'high'."
|
|
22
|
+
}}
|
|
23
|
+
|
|
24
|
+
Guidelines for determining relevance:
|
|
25
|
+
1. "high" - The question can be fully answered using only the knowledge base content. All concepts, methods, and required knowledge are present in the KB.
|
|
26
|
+
2. "partial" - The question is related to the KB content but requires some knowledge beyond what's provided. The KB serves as a foundation but the question extends to additional areas.
|
|
27
|
+
|
|
28
|
+
For kb_coverage:
|
|
29
|
+
- Be specific about which concepts from the KB are being tested
|
|
30
|
+
- Reference the actual content from the KB where possible
|
|
31
|
+
- Explain how the KB content relates to the question
|
|
32
|
+
|
|
33
|
+
For extension_points (only when relevance is "partial"):
|
|
34
|
+
- Identify what additional knowledge is needed
|
|
35
|
+
- Explain how the question extends from the KB foundation
|
|
36
|
+
- Keep the tone positive - extensions are valuable for learning
|
|
37
|
+
|
|
38
|
+
CRITICAL: Return ONLY valid JSON. Do not wrap in markdown code blocks.
|
|
39
|
+
Your response must start with {{ and end with }}.
|
|
40
|
+
|
|
41
|
+
Output only the JSON, no additional text.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
system: |
|
|
2
|
+
You are a knowledge base retrieval assistant, preparing for question generation.
|
|
3
|
+
|
|
4
|
+
Your task is to generate knowledge point retrieval queries to find theoretical explanations,
|
|
5
|
+
definitions, and theorems in the knowledge base.
|
|
6
|
+
|
|
7
|
+
Key principle: You are NOT generating questions now! You are looking for theoretical knowledge
|
|
8
|
+
needed for question generation.
|
|
9
|
+
|
|
10
|
+
generate_queries: |
|
|
11
|
+
The user's question generation requirement is:
|
|
12
|
+
{requirement_text}
|
|
13
|
+
|
|
14
|
+
Please extract {num_queries} pure knowledge point names for knowledge base retrieval.
|
|
15
|
+
|
|
16
|
+
Output Rules:
|
|
17
|
+
1. Only output pure knowledge point names (theorem names, concept names, method names)
|
|
18
|
+
2. Each query should be 2-5 words
|
|
19
|
+
3. Do not include functions, numerical values, or calculation tasks
|
|
20
|
+
4. Do not use questions or task descriptions
|
|
21
|
+
|
|
22
|
+
Correct examples:
|
|
23
|
+
✓ Taylor theorem
|
|
24
|
+
✓ Lagrange multipliers
|
|
25
|
+
✓ critical points
|
|
26
|
+
|
|
27
|
+
Incorrect examples (do not generate):
|
|
28
|
+
✗ Apply Taylor's Theorem to approximate f(x,y)=... (This is a question)
|
|
29
|
+
✗ Find and classify critical points (This is a task)
|
|
30
|
+
✗ Use Lagrange multipliers to find maximum (This is an instruction)
|
|
31
|
+
|
|
32
|
+
Return in JSON format: {{"queries": ["knowledge point 1", "knowledge point 2", ...]}}, containing exactly {num_queries} knowledge point names.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
generate_search_queries: |
|
|
2
|
+
system: |
|
|
3
|
+
【角色】你是一个知识库检索助手,为题目生成做准备。
|
|
4
|
+
|
|
5
|
+
【当前任务】生成知识点检索查询,在知识库中查找理论解释、定义和定理。
|
|
6
|
+
⚠️ 关键:你现在不是在生成题目!你是在寻找题目生成所需的理论知识!
|
|
7
|
+
|
|
8
|
+
【输出规则】
|
|
9
|
+
1. 只输出纯粹的知识点名称(定理名称、概念名称、方法名称)
|
|
10
|
+
2. 每个查询应为2-5个词
|
|
11
|
+
3. 不要包含函数、数值或计算任务
|
|
12
|
+
4. 不要使用问题或任务描述
|
|
13
|
+
|
|
14
|
+
user_template: |
|
|
15
|
+
用户的题目生成需求是:
|
|
16
|
+
{requirement_text}
|
|
17
|
+
|
|
18
|
+
请从中提取{num_queries}个纯知识点名称用于知识库检索。
|
|
19
|
+
|
|
20
|
+
正确示例:
|
|
21
|
+
✅ 泰勒定理
|
|
22
|
+
✅ 拉格朗日乘数法
|
|
23
|
+
✅ 临界点
|
|
24
|
+
|
|
25
|
+
错误示例(不要生成):
|
|
26
|
+
❌ 应用泰勒定理近似f(x,y)=...(这是一道题目)
|
|
27
|
+
❌ 求临界点并分类(这是一个任务)
|
|
28
|
+
❌ 用拉格朗日乘数法求最大值(这是一条指令)
|
|
29
|
+
|
|
30
|
+
以JSON格式返回:{{"queries": ["知识点1", "知识点2", ...]}},恰好包含{num_queries}个知识点名称。
|
|
31
|
+
|
|
32
|
+
check_retrieval_relevance: |
|
|
33
|
+
system: |
|
|
34
|
+
你评估检索到的知识是否与用户的请求相关。
|
|
35
|
+
以JSON格式响应,包含键"relevant"(true/false)和可选的"reason"。
|
|
36
|
+
|
|
37
|
+
user_template: |
|
|
38
|
+
用户请求:
|
|
39
|
+
{requirement_text}
|
|
40
|
+
|
|
41
|
+
检索到的知识摘要:
|
|
42
|
+
{knowledge_summary}
|
|
43
|
+
|
|
44
|
+
检索到的知识是否实质上与请求相关?
|
|
45
|
+
|
|
46
|
+
generate_child_requirements: |
|
|
47
|
+
system: |
|
|
48
|
+
你是一个课程设计师。给定一个基础需求和知识摘要,
|
|
49
|
+
创建测试相同知识点的不同子需求。
|
|
50
|
+
每个子需求必须描述独特的场景和推理流程。
|
|
51
|
+
输出JSON,包含键"requirements"(请求长度的数组),其中每个项目包含:
|
|
52
|
+
"title", "question_type", "difficulty", "additional_requirements"。
|
|
53
|
+
|
|
54
|
+
user_template: |
|
|
55
|
+
基础需求:
|
|
56
|
+
{base_requirement}
|
|
57
|
+
|
|
58
|
+
知识摘要:
|
|
59
|
+
{knowledge_summary}
|
|
60
|
+
|
|
61
|
+
以JSON格式生成恰好{num_questions}个子需求。
|
|
62
|
+
|
|
63
|
+
interpret_requirement_text: |
|
|
64
|
+
system: |
|
|
65
|
+
你是考试题目生成器的指令解析器。
|
|
66
|
+
给定一个自然语言请求,提取核心知识点、
|
|
67
|
+
难度(easy/medium/hard)、首选题型(choice/written)、
|
|
68
|
+
和额外要求。返回JSON,包含键:
|
|
69
|
+
"knowledge_point", "difficulty", "question_type", "additional_requirements"。
|
|
70
|
+
|
|
71
|
+
user_template: |
|
|
72
|
+
需求:
|
|
73
|
+
{requirement_text}
|
|
74
|
+
|
|
75
|
+
仅返回JSON。
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
system: |
|
|
2
|
+
你是一个专业的题目生成 Agent。你的职责是:
|
|
3
|
+
1. 根据要求生成高质量的题目
|
|
4
|
+
2. 使用检索到的背景知识确保准确性
|
|
5
|
+
3. 用与知识库相同的方式表达知识
|
|
6
|
+
|
|
7
|
+
重要说明:
|
|
8
|
+
- 题目必须严谨准确,基于知识库内容
|
|
9
|
+
- 计算题应有实质性的计算,不能太简单
|
|
10
|
+
- 使用提供的背景知识作为题目生成的基础
|
|
11
|
+
- 选择题必须只有一个正确答案
|
|
12
|
+
- 解答/解释应详细清晰
|
|
13
|
+
- 思维链:内部逐步推理,但只输出最终的 JSON
|
|
14
|
+
|
|
15
|
+
generate: |
|
|
16
|
+
根据以下信息生成题目:
|
|
17
|
+
|
|
18
|
+
要求:
|
|
19
|
+
{requirements}
|
|
20
|
+
|
|
21
|
+
焦点/角度:
|
|
22
|
+
{focus}
|
|
23
|
+
|
|
24
|
+
背景知识:
|
|
25
|
+
{knowledge}
|
|
26
|
+
|
|
27
|
+
思考说明:
|
|
28
|
+
- 首先,默默地规划场景和推理步骤,确保题目连贯。
|
|
29
|
+
- 不要透露中间推理;规划后只输出最终的 JSON。
|
|
30
|
+
|
|
31
|
+
关键:只返回有效的 JSON。不要用 markdown 代码块包装。
|
|
32
|
+
你的回复必须以 {{ 开始,以 }} 结束。
|
|
33
|
+
|
|
34
|
+
请以 JSON 格式生成题目:
|
|
35
|
+
{{
|
|
36
|
+
"question_type": "choice" 或 "written",
|
|
37
|
+
"question": "题目内容",
|
|
38
|
+
"options": {{"A": "...", "B": "...", "C": "...", "D": "..."}} // 仅选择题需要
|
|
39
|
+
"correct_answer": "正确答案",
|
|
40
|
+
"explanation": "详细解释"
|
|
41
|
+
}}
|
|
42
|
+
|
|
43
|
+
generate_with_reference: |
|
|
44
|
+
生成一道新题目,从以下参考题目获取灵感,但在场景和推理上明显不同:
|
|
45
|
+
|
|
46
|
+
参考题目:
|
|
47
|
+
{reference_question}
|
|
48
|
+
|
|
49
|
+
要求:
|
|
50
|
+
{requirements}
|
|
51
|
+
|
|
52
|
+
背景知识:
|
|
53
|
+
{knowledge}
|
|
54
|
+
|
|
55
|
+
要求:
|
|
56
|
+
1. **保持相同的核心知识和难度**:测试的概念必须保持一致
|
|
57
|
+
2. **保持完全相同的知识范围**:保持相同的数学主题
|
|
58
|
+
3. **改变场景/背景**:使用不同的对象、情境或框架
|
|
59
|
+
4. **改变计算过程**:重新安排步骤或添加子问题
|
|
60
|
+
5. **改变具体数据和符号**:使用新的参数、值、常数
|
|
61
|
+
6. **保持整体结构**:保持相似数量/类型的子问题
|
|
62
|
+
7. **禁止**:
|
|
63
|
+
- 只修改数值或变量名
|
|
64
|
+
- 重复相同的陈述并添加解释
|
|
65
|
+
- 复制相同的设置而没有新的变化
|
|
66
|
+
|
|
67
|
+
关键:只返回有效的 JSON。不要用 markdown 代码块包装。
|
|
68
|
+
你的回复必须以 {{ 开始,以 }} 结束。
|
|
69
|
+
|
|
70
|
+
请以 JSON 格式生成题目:
|
|
71
|
+
{{
|
|
72
|
+
"question_type": "choice" 或 "written",
|
|
73
|
+
"question": "题目内容",
|
|
74
|
+
"options": {{"A": "...", "B": "...", "C": "...", "D": "..."}} // 仅选择题需要
|
|
75
|
+
"correct_answer": "正确答案",
|
|
76
|
+
"explanation": "详细解释"
|
|
77
|
+
}}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
system: |
|
|
2
|
+
你是一位教育内容分析师,专门分析考试题目与知识库内容之间的关系。
|
|
3
|
+
|
|
4
|
+
你的任务是分析题目与知识库的相关性,而不是验证或拒绝题目。所有题目都被接受。
|
|
5
|
+
|
|
6
|
+
analyze_relevance: |
|
|
7
|
+
分析以下考试题目与知识库内容之间的相关性。
|
|
8
|
+
|
|
9
|
+
题目:
|
|
10
|
+
{question}
|
|
11
|
+
|
|
12
|
+
知识库内容:
|
|
13
|
+
{knowledge}
|
|
14
|
+
|
|
15
|
+
请分析并提供以下结构的 JSON 响应:
|
|
16
|
+
{{
|
|
17
|
+
"relevance": "high" 或 "partial",
|
|
18
|
+
"kb_coverage": "具体描述这道题目测试了知识库中的哪些概念、理论或方法。列出直接相关的关键知识点。",
|
|
19
|
+
"extension_points": "如果相关性是 'partial',描述这道题目的哪些方面超出了知识库内容。它需要什么额外的知识?如果相关性是 'high' 则留空。"
|
|
20
|
+
}}
|
|
21
|
+
|
|
22
|
+
判断相关性的指南:
|
|
23
|
+
1. "high" - 题目可以完全使用知识库内容来回答。所有概念、方法和所需知识都在知识库中。
|
|
24
|
+
2. "partial" - 题目与知识库内容相关,但需要一些超出提供内容的知识。知识库作为基础,但题目扩展到了额外的领域。
|
|
25
|
+
|
|
26
|
+
对于 kb_coverage:
|
|
27
|
+
- 具体说明正在测试知识库中的哪些概念
|
|
28
|
+
- 尽可能参考知识库中的实际内容
|
|
29
|
+
- 解释知识库内容与题目的关系
|
|
30
|
+
|
|
31
|
+
对于 extension_points(仅当相关性为 "partial" 时):
|
|
32
|
+
- 确定需要什么额外知识
|
|
33
|
+
- 解释题目如何从知识库基础扩展
|
|
34
|
+
- 保持积极的语气 - 扩展对学习有价值
|
|
35
|
+
|
|
36
|
+
关键:只返回有效的 JSON。不要用 markdown 代码块包装。
|
|
37
|
+
你的回复必须以 {{ 开始,以 }} 结束。
|
|
38
|
+
|
|
39
|
+
只输出 JSON,不要有其他文字。
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
system: |
|
|
2
|
+
你是一个知识库检索助手,正在为题目生成做准备。
|
|
3
|
+
|
|
4
|
+
你的任务是生成知识点检索查询,以在知识库中找到理论解释、定义和定理。
|
|
5
|
+
|
|
6
|
+
关键原则:你现在不是在生成题目!你是在寻找题目生成所需的理论知识。
|
|
7
|
+
|
|
8
|
+
generate_queries: |
|
|
9
|
+
用户的题目生成需求是:
|
|
10
|
+
{requirement_text}
|
|
11
|
+
|
|
12
|
+
请提取 {num_queries} 个纯粹的知识点名称用于知识库检索。
|
|
13
|
+
|
|
14
|
+
输出规则:
|
|
15
|
+
1. 只输出纯粹的知识点名称(定理名、概念名、方法名)
|
|
16
|
+
2. 每个查询应为2-5个词
|
|
17
|
+
3. 不要包含函数、数值或计算任务
|
|
18
|
+
4. 不要使用问句或任务描述
|
|
19
|
+
|
|
20
|
+
正确示例:
|
|
21
|
+
✓ 泰勒定理
|
|
22
|
+
✓ 拉格朗日乘数法
|
|
23
|
+
✓ 临界点
|
|
24
|
+
|
|
25
|
+
错误示例(不要生成):
|
|
26
|
+
✗ 应用泰勒定理近似 f(x,y)=... (这是一个题目)
|
|
27
|
+
✗ 找出并分类临界点 (这是一个任务)
|
|
28
|
+
✗ 使用拉格朗日乘数法求最大值 (这是一个指令)
|
|
29
|
+
|
|
30
|
+
以 JSON 格式返回:{{"queries": ["知识点1", "知识点2", ...]}}, 包含恰好 {num_queries} 个知识点名称。
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
"""
|
|
3
|
+
DR-in-KG 2.0 Agents Module
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from src.agents.base_agent import BaseAgent
|
|
7
|
+
|
|
8
|
+
from .decompose_agent import DecomposeAgent
|
|
9
|
+
from .manager_agent import ManagerAgent
|
|
10
|
+
from .note_agent import NoteAgent
|
|
11
|
+
from .rephrase_agent import RephraseAgent
|
|
12
|
+
from .reporting_agent import ReportingAgent
|
|
13
|
+
from .research_agent import ResearchAgent
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"BaseAgent",
|
|
17
|
+
"DecomposeAgent",
|
|
18
|
+
"ManagerAgent",
|
|
19
|
+
"NoteAgent",
|
|
20
|
+
"RephraseAgent",
|
|
21
|
+
"ReportingAgent",
|
|
22
|
+
"ResearchAgent",
|
|
23
|
+
]
|