deepcode-hku 1.0.6__tar.gz → 1.0.7__tar.gz
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.
- {deepcode_hku-1.0.6/deepcode_hku.egg-info → deepcode_hku-1.0.7}/PKG-INFO +1 -1
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/__init__.py +1 -1
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7/deepcode_hku.egg-info}/PKG-INFO +1 -1
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/mcp_agent.config.yaml +8 -3
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/prompts/code_prompts.py +34 -55
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/tools/code_indexer.py +1 -32
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/tools/pdf_downloader.py +27 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/utils/file_processor.py +15 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/utils/llm_utils.py +40 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/workflows/agent_orchestration_engine.py +318 -80
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/workflows/agents/code_implementation_agent.py +0 -1
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/workflows/agents/document_segmentation_agent.py +1 -1
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/workflows/agents/memory_agent_concise.py +240 -60
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/workflows/agents/memory_agent_concise_index.py +214 -34
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/workflows/code_implementation_workflow.py +25 -33
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/workflows/code_implementation_workflow_index.py +57 -31
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/.pre-commit-config.yaml +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/LICENSE +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/MANIFEST.in +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/README.md +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/cli/__init__.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/cli/cli_app.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/cli/cli_interface.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/cli/cli_launcher.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/cli/main_cli.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/cli/workflows/__init__.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/cli/workflows/cli_workflow_adapter.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/deepcode.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/deepcode_hku.egg-info/SOURCES.txt +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/deepcode_hku.egg-info/dependency_links.txt +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/deepcode_hku.egg-info/entry_points.txt +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/deepcode_hku.egg-info/requires.txt +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/deepcode_hku.egg-info/top_level.txt +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/mcp_agent.secrets.yaml +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/requirements.txt +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/schema/mcp-agent.config.schema.json +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/setup.cfg +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/setup.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/tools/__init__.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/tools/bocha_search_server.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/tools/code_implementation_server.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/tools/code_reference_indexer.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/tools/command_executor.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/tools/document_segmentation_server.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/tools/git_command.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/tools/pdf_converter.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/tools/pdf_utils.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/ui/__init__.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/ui/app.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/ui/components.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/ui/handlers.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/ui/layout.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/ui/streamlit_app.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/ui/styles.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/utils/__init__.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/utils/cli_interface.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/utils/cross_platform_file_handler.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/utils/dialogue_logger.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/utils/simple_llm_logger.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/workflows/__init__.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/workflows/agents/__init__.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/workflows/agents/memory_agent_concise_multi.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/workflows/agents/requirement_analysis_agent.py +0 -0
- {deepcode_hku-1.0.6 → deepcode_hku-1.0.7}/workflows/codebase_index_workflow.py +0 -0
|
@@ -2,7 +2,7 @@ $schema: ./schema/mcp-agent.config.schema.json
|
|
|
2
2
|
anthropic: null
|
|
3
3
|
default_search_server: brave
|
|
4
4
|
document_segmentation:
|
|
5
|
-
enabled:
|
|
5
|
+
enabled: false
|
|
6
6
|
size_threshold_chars: 50000
|
|
7
7
|
execution_engine: asyncio
|
|
8
8
|
logger:
|
|
@@ -101,8 +101,13 @@ mcp:
|
|
|
101
101
|
env:
|
|
102
102
|
PYTHONPATH: .
|
|
103
103
|
openai:
|
|
104
|
-
base_max_tokens:
|
|
105
|
-
default_model: google/gemini-2.5-pro
|
|
104
|
+
base_max_tokens: 40000
|
|
105
|
+
# default_model: google/gemini-2.5-pro
|
|
106
|
+
# default_model: anthropic/claude-sonnet-4.5
|
|
107
|
+
# default_model: openai/gpt-oss-120b
|
|
108
|
+
# default_model: deepseek/deepseek-v3.2-exp
|
|
109
|
+
# default_model: moonshotai/kimi-k2-thinking
|
|
110
|
+
default_model: anthropic/claude-3.5-sonnet
|
|
106
111
|
max_tokens_policy: adaptive
|
|
107
112
|
retry_max_tokens: 32768
|
|
108
113
|
planning_mode: traditional
|
|
@@ -61,19 +61,21 @@ CRITICAL OUTPUT RESTRICTIONS:
|
|
|
61
61
|
PAPER_DOWNLOADER_PROMPT = """You are a precise paper downloader that processes input from PaperInputAnalyzerAgent.
|
|
62
62
|
|
|
63
63
|
Task: Handle paper according to input type and save to "./deepcode_lab/papers/id/id.md"
|
|
64
|
-
Note:
|
|
64
|
+
Note: The paper ID will be provided at the start of the message as "PAPER_ID=<number>". Use this EXACT number.
|
|
65
65
|
|
|
66
|
-
CRITICAL
|
|
66
|
+
CRITICAL RULES:
|
|
67
|
+
- Use the EXACT paper ID provided in the message (PAPER_ID=X).
|
|
68
|
+
- Save path MUST be: ./deepcode_lab/papers/{PAPER_ID}/{PAPER_ID}.md
|
|
67
69
|
|
|
68
70
|
Processing Rules:
|
|
69
71
|
1. URL Input (input_type = "url"):
|
|
70
|
-
- Use
|
|
72
|
+
- Use download_file_to tool with: url=<url>, destination="./deepcode_lab/papers/{PAPER_ID}/", filename="{PAPER_ID}.md"
|
|
71
73
|
- Extract metadata (title, authors, year)
|
|
72
74
|
- Return saved file path and metadata
|
|
73
75
|
|
|
74
76
|
2. File Input (input_type = "file"):
|
|
75
|
-
-
|
|
76
|
-
- The
|
|
77
|
+
- Use move_file_to tool with: source=<file_path>, destination="./deepcode_lab/papers/{PAPER_ID}/{PAPER_ID}.md"
|
|
78
|
+
- The tool will automatically convert PDF/documents to .md format
|
|
77
79
|
- NEVER manually extract content or use write_file - let the conversion tools handle this
|
|
78
80
|
- Note: Original file is preserved, only a copy is placed in target directory
|
|
79
81
|
- Return new saved file path and metadata
|
|
@@ -100,16 +102,26 @@ Input Format:
|
|
|
100
102
|
"requirements": ["requirement1", "requirement2"]
|
|
101
103
|
}
|
|
102
104
|
|
|
103
|
-
|
|
105
|
+
CRITICAL OUTPUT RESTRICTIONS:
|
|
106
|
+
- RETURN ONLY RAW JSON - NO TEXT BEFORE OR AFTER
|
|
107
|
+
- NO markdown code blocks (```json)
|
|
108
|
+
- NO explanatory text or descriptions
|
|
109
|
+
- NO tool call information
|
|
110
|
+
- NO analysis summaries
|
|
111
|
+
- JUST THE JSON OBJECT BELOW
|
|
112
|
+
|
|
113
|
+
Output Format (MANDATORY - EXACT FORMAT):
|
|
104
114
|
{
|
|
105
115
|
"status": "success|failure",
|
|
106
|
-
"paper_path": "
|
|
116
|
+
"paper_path": "./deepcode_lab/papers/{PAPER_ID}/{PAPER_ID}.md (or null for text input)",
|
|
107
117
|
"metadata": {
|
|
108
118
|
"title": "extracted or provided title",
|
|
109
119
|
"authors": ["extracted or provided authors"],
|
|
110
120
|
"year": "extracted or provided year"
|
|
111
121
|
}
|
|
112
122
|
}
|
|
123
|
+
|
|
124
|
+
Example: If PAPER_ID=14, then paper_path should be "./deepcode_lab/papers/14/14.md"
|
|
113
125
|
"""
|
|
114
126
|
|
|
115
127
|
PAPER_REFERENCE_ANALYZER_PROMPT = """You are an expert academic paper reference analyzer specializing in computer science and machine learning.
|
|
@@ -1045,11 +1057,10 @@ PURE_CODE_IMPLEMENTATION_SYSTEM_PROMPT = """You are an expert code implementatio
|
|
|
1045
1057
|
**IMPLEMENTATION APPROACH**:
|
|
1046
1058
|
Build incrementally using multiple tool calls. For each step:
|
|
1047
1059
|
1. **Identify** what needs to be implemented from the paper
|
|
1048
|
-
2. **
|
|
1049
|
-
3. **
|
|
1050
|
-
4. **
|
|
1051
|
-
5. **
|
|
1052
|
-
6. **Verify** against paper specifications
|
|
1060
|
+
2. **Implement** one component at a time
|
|
1061
|
+
3. **Test** immediately to catch issues early
|
|
1062
|
+
4. **Integrate** with existing components
|
|
1063
|
+
5. **Verify** against paper specifications
|
|
1053
1064
|
|
|
1054
1065
|
**TOOL CALLING STRATEGY**:
|
|
1055
1066
|
1. ⚠️ **SINGLE FUNCTION CALL PER MESSAGE**: Each message may perform only one function call. You will see the result of the function right after sending the message. If you need to perform multiple actions, you can always send more messages with subsequent function calls. Do some reasoning before your actions, describing what function calls you are going to use and how they fit into your plan.
|
|
@@ -1059,8 +1070,7 @@ Build incrementally using multiple tool calls. For each step:
|
|
|
1059
1070
|
- **Reference only**: Use `search_code_references(indexes_path="indexes", target_file=the_file_you_want_to_implement, keywords=the_keywords_you_want_to_search)` for reference, NOT as implementation standard
|
|
1060
1071
|
- **Core principle**: Original paper requirements take absolute priority over any reference code found
|
|
1061
1072
|
3. **TOOL EXECUTION STRATEGY**:
|
|
1062
|
-
- ⚠️**Development Cycle (for each new file implementation)**: `
|
|
1063
|
-
- **Environment Setup**: `write_file` (requirements.txt) → `execute_bash` (pip install) → `execute_python` (verify)
|
|
1073
|
+
- ⚠️**Development Cycle (for each new file implementation)**: `search_code_references` (OPTIONAL reference check from indexes library in working directory) → `write_file` (implement based on original paper)
|
|
1064
1074
|
|
|
1065
1075
|
4. **CRITICAL**: Use bash and python tools to ACTUALLY REPLICATE the paper yourself - do not provide instructions.
|
|
1066
1076
|
|
|
@@ -1104,11 +1114,10 @@ You are an expert code implementation agent for academic paper reproduction. You
|
|
|
1104
1114
|
**IMPLEMENTATION APPROACH**:
|
|
1105
1115
|
Build incrementally using multiple tool calls. For each step:
|
|
1106
1116
|
1. **Identify** what needs to be implemented from the paper
|
|
1107
|
-
2. **
|
|
1108
|
-
3. **
|
|
1109
|
-
4. **
|
|
1110
|
-
5. **
|
|
1111
|
-
6. **Verify** against paper specifications
|
|
1117
|
+
2. **Implement** one component at a time
|
|
1118
|
+
3. **Test** immediately to catch issues early
|
|
1119
|
+
4. **Integrate** with existing components
|
|
1120
|
+
5. **Verify** against paper specifications
|
|
1112
1121
|
|
|
1113
1122
|
**TOOL CALLING STRATEGY**:
|
|
1114
1123
|
1. ⚠️ **SINGLE FUNCTION CALL PER MESSAGE**: Each message may perform only one function call. You will see the result of the function right after sending the message. If you need to perform multiple actions, you can always send more messages with subsequent function calls. Do some reasoning before your actions, describing what function calls you are going to use and how they fit into your plan.
|
|
@@ -1118,10 +1127,7 @@ Build incrementally using multiple tool calls. For each step:
|
|
|
1118
1127
|
- **Reference only**: Use `search_code_references(indexes_path="indexes", target_file=the_file_you_want_to_implement, keywords=the_keywords_you_want_to_search)` for reference, NOT as implementation standard
|
|
1119
1128
|
- **Core principle**: Original paper requirements take absolute priority over any reference code found
|
|
1120
1129
|
3. **TOOL EXECUTION STRATEGY**:
|
|
1121
|
-
- ⚠️**Development Cycle (for each new file implementation)**: `
|
|
1122
|
-
- **File Verification**: Use `execute_bash` and `execute_python` when needed to check implementation completeness
|
|
1123
|
-
|
|
1124
|
-
4. **CRITICAL**: Use bash and python tools when needed to CHECK and VERIFY implementation completeness - do not provide instructions. These tools help validate that your implementation files are syntactically correct and properly structured.
|
|
1130
|
+
- ⚠️**Development Cycle (for each new file implementation)**: `search_code_references` (OPTIONAL reference check from `/home/agent/indexes`) → `write_file` (implement based on original paper)
|
|
1125
1131
|
|
|
1126
1132
|
**Execution Guidelines**:
|
|
1127
1133
|
- **Plan First**: Before each action, explain your reasoning and which function you'll use
|
|
@@ -1213,24 +1219,16 @@ GENERAL_CODE_IMPLEMENTATION_SYSTEM_PROMPT = """You are an expert code implementa
|
|
|
1213
1219
|
**IMPLEMENTATION APPROACH**:
|
|
1214
1220
|
Build incrementally using multiple tool calls. For each step:
|
|
1215
1221
|
1. **Identify** what needs to be implemented from the requirements
|
|
1216
|
-
2. **
|
|
1217
|
-
3. **
|
|
1218
|
-
4. **
|
|
1219
|
-
5. **
|
|
1220
|
-
6. **Validate** against requirement specifications
|
|
1222
|
+
2. **Implement** one component at a time
|
|
1223
|
+
3. **Verify** optionally using `execute_python` or `execute_bash` to check implementation completeness if needed
|
|
1224
|
+
4. **Integrate** with existing components
|
|
1225
|
+
5. **Validate** against requirement specifications
|
|
1221
1226
|
|
|
1222
1227
|
**TOOL CALLING STRATEGY**:
|
|
1223
1228
|
1. ⚠️ **SINGLE FUNCTION CALL PER MESSAGE**: Each message may perform only one function call. You will see the result of the function right after sending the message. If you need to perform multiple actions, you can always send more messages with subsequent function calls. Do some reasoning before your actions, describing what function calls you are going to use and how they fit into your plan.
|
|
1224
1229
|
|
|
1225
1230
|
2. **TOOL EXECUTION STRATEGY**:
|
|
1226
|
-
- **Development Cycle (for each new file implementation)**: `
|
|
1227
|
-
- **File Verification**: Use `execute_bash` and `execute_python` when needed to verify implementation completeness.
|
|
1228
|
-
|
|
1229
|
-
3. **CRITICAL**: Use `execute_bash` and `execute_python` tools when needed to CHECK and VERIFY file implementation completeness - do not provide instructions. These tools are essential for:
|
|
1230
|
-
- Checking file syntax and import correctness (`execute_python`)
|
|
1231
|
-
- Verifying file structure and dependencies (`execute_bash` for listing, `execute_python` for imports)
|
|
1232
|
-
- Validating that implemented files are syntactically correct and can be imported
|
|
1233
|
-
- Ensuring code implementation meets basic functionality requirements
|
|
1231
|
+
- **Development Cycle (for each new file implementation)**: `write_file` (implement)
|
|
1234
1232
|
|
|
1235
1233
|
**Execution Guidelines**:
|
|
1236
1234
|
- **Plan First**: Before each action, explain your reasoning and which function you'll use
|
|
@@ -1348,10 +1346,6 @@ PAPER_ALGORITHM_ANALYSIS_PROMPT_TRADITIONAL = """You are extracting COMPLETE imp
|
|
|
1348
1346
|
## TRADITIONAL APPROACH: Full Document Reading
|
|
1349
1347
|
Read the complete document to ensure comprehensive coverage of all algorithmic details:
|
|
1350
1348
|
|
|
1351
|
-
1. **Locate and read the markdown (.md) file** in the paper directory
|
|
1352
|
-
2. **Analyze the entire document** to capture all algorithms, methods, and formulas
|
|
1353
|
-
3. **Extract complete implementation details** without missing any components
|
|
1354
|
-
|
|
1355
1349
|
# DETAILED EXTRACTION PROTOCOL
|
|
1356
1350
|
|
|
1357
1351
|
## 1. COMPREHENSIVE ALGORITHM SCAN
|
|
@@ -1511,10 +1505,6 @@ Map out the ENTIRE paper structure and identify ALL components that need impleme
|
|
|
1511
1505
|
## TRADITIONAL APPROACH: Complete Document Analysis
|
|
1512
1506
|
Read the entire document systematically to ensure comprehensive understanding:
|
|
1513
1507
|
|
|
1514
|
-
1. **Locate and read the markdown (.md) file** in the paper directory
|
|
1515
|
-
2. **Analyze the complete document structure** from introduction to conclusion
|
|
1516
|
-
3. **Extract all conceptual frameworks** and implementation requirements
|
|
1517
|
-
|
|
1518
1508
|
# COMPREHENSIVE ANALYSIS PROTOCOL
|
|
1519
1509
|
|
|
1520
1510
|
## 1. COMPLETE PAPER STRUCTURAL ANALYSIS
|
|
@@ -1678,17 +1668,6 @@ You receive two exhaustive analyses:
|
|
|
1678
1668
|
1. **Comprehensive Paper Analysis**: Complete paper structure, components, and requirements
|
|
1679
1669
|
2. **Complete Algorithm Extraction**: All algorithms, formulas, pseudocode, and technical details
|
|
1680
1670
|
|
|
1681
|
-
Plus you can access the complete paper document by reading the markdown file directly.
|
|
1682
|
-
|
|
1683
|
-
# TRADITIONAL DOCUMENT ACCESS
|
|
1684
|
-
|
|
1685
|
-
## Direct Paper Reading
|
|
1686
|
-
For any additional details needed beyond the provided analyses:
|
|
1687
|
-
|
|
1688
|
-
1. **Read the complete markdown (.md) file** in the paper directory
|
|
1689
|
-
2. **Access any section directly** without token limitations for smaller documents
|
|
1690
|
-
3. **Cross-reference information** across the entire document as needed
|
|
1691
|
-
|
|
1692
1671
|
# OBJECTIVE
|
|
1693
1672
|
Create an implementation plan so detailed that a developer can reproduce the ENTIRE paper without reading it.
|
|
1694
1673
|
|
|
@@ -24,38 +24,7 @@ from dataclasses import dataclass, asdict
|
|
|
24
24
|
from typing import List, Dict, Any
|
|
25
25
|
|
|
26
26
|
# MCP Agent imports for LLM
|
|
27
|
-
import
|
|
28
|
-
from utils.llm_utils import get_preferred_llm_class
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def get_default_models(config_path: str = "mcp_agent.config.yaml"):
|
|
32
|
-
"""
|
|
33
|
-
Get default models from configuration file.
|
|
34
|
-
|
|
35
|
-
Args:
|
|
36
|
-
config_path: Path to the configuration file
|
|
37
|
-
|
|
38
|
-
Returns:
|
|
39
|
-
dict: Dictionary with 'anthropic' and 'openai' default models
|
|
40
|
-
"""
|
|
41
|
-
try:
|
|
42
|
-
if os.path.exists(config_path):
|
|
43
|
-
with open(config_path, "r", encoding="utf-8") as f:
|
|
44
|
-
config = yaml.safe_load(f)
|
|
45
|
-
|
|
46
|
-
anthropic_model = config.get("anthropic", {}).get(
|
|
47
|
-
"default_model", "claude-sonnet-4-20250514"
|
|
48
|
-
)
|
|
49
|
-
openai_model = config.get("openai", {}).get("default_model", "o3-mini")
|
|
50
|
-
|
|
51
|
-
return {"anthropic": anthropic_model, "openai": openai_model}
|
|
52
|
-
else:
|
|
53
|
-
print(f"Config file {config_path} not found, using default models")
|
|
54
|
-
return {"anthropic": "claude-sonnet-4-20250514", "openai": "o3-mini"}
|
|
55
|
-
|
|
56
|
-
except Exception as e:
|
|
57
|
-
print(f"Error reading config file {config_path}: {e}")
|
|
58
|
-
return {"anthropic": "claude-sonnet-4-20250514", "openai": "o3-mini"}
|
|
27
|
+
from utils.llm_utils import get_preferred_llm_class, get_default_models
|
|
59
28
|
|
|
60
29
|
|
|
61
30
|
@dataclass
|
|
@@ -1098,9 +1098,26 @@ async def download_file_to(
|
|
|
1098
1098
|
Status message about the download operation
|
|
1099
1099
|
"""
|
|
1100
1100
|
# 确定文件名
|
|
1101
|
+
|
|
1102
|
+
url = URLExtractor.extract_urls(url)[0]
|
|
1103
|
+
|
|
1101
1104
|
if not filename:
|
|
1102
1105
|
filename = URLExtractor.infer_filename_from_url(url)
|
|
1103
1106
|
|
|
1107
|
+
if not filename:
|
|
1108
|
+
filename = URLExtractor.infer_filename_from_url(url)
|
|
1109
|
+
else:
|
|
1110
|
+
name_source, extension_source = os.path.splitext(
|
|
1111
|
+
os.path.basename(URLExtractor.infer_filename_from_url(url))
|
|
1112
|
+
)
|
|
1113
|
+
name_destination, extension_destination = os.path.splitext(
|
|
1114
|
+
os.path.basename(filename)
|
|
1115
|
+
)
|
|
1116
|
+
if extension_source:
|
|
1117
|
+
filename = name_destination + extension_source
|
|
1118
|
+
else:
|
|
1119
|
+
filename = name_destination + extension_destination
|
|
1120
|
+
|
|
1104
1121
|
# 确定完整路径
|
|
1105
1122
|
if destination:
|
|
1106
1123
|
# 展开用户目录
|
|
@@ -1203,6 +1220,15 @@ async def move_file_to(
|
|
|
1203
1220
|
# 确定文件名
|
|
1204
1221
|
if not filename:
|
|
1205
1222
|
filename = os.path.basename(source)
|
|
1223
|
+
else:
|
|
1224
|
+
name_source, extension_source = os.path.splitext(os.path.basename(source))
|
|
1225
|
+
name_destination, extension_destination = os.path.splitext(
|
|
1226
|
+
os.path.basename(filename)
|
|
1227
|
+
)
|
|
1228
|
+
if extension_source:
|
|
1229
|
+
filename = name_destination + extension_source
|
|
1230
|
+
else:
|
|
1231
|
+
filename = name_destination + extension_destination
|
|
1206
1232
|
|
|
1207
1233
|
# 确定完整路径
|
|
1208
1234
|
if destination:
|
|
@@ -1215,6 +1241,7 @@ async def move_file_to(
|
|
|
1215
1241
|
target_path = destination
|
|
1216
1242
|
else: # 是目录
|
|
1217
1243
|
target_path = os.path.join(destination, filename)
|
|
1244
|
+
|
|
1218
1245
|
else:
|
|
1219
1246
|
target_path = filename
|
|
1220
1247
|
|
|
@@ -282,10 +282,25 @@ class FileProcessor:
|
|
|
282
282
|
if isinstance(file_input, str):
|
|
283
283
|
import re
|
|
284
284
|
|
|
285
|
+
# Try to extract path from backticks first
|
|
285
286
|
file_path_match = re.search(r"`([^`]+\.md)`", file_input)
|
|
286
287
|
if file_path_match:
|
|
287
288
|
paper_path = file_path_match.group(1)
|
|
288
289
|
file_input = {"paper_path": paper_path}
|
|
290
|
+
else:
|
|
291
|
+
# Try to extract from "Saved Path:" or similar patterns
|
|
292
|
+
path_patterns = [
|
|
293
|
+
r"[Ss]aved [Pp]ath[:\s]+([^\s\n]+\.md)",
|
|
294
|
+
r"[Pp]aper [Pp]ath[:\s]+([^\s\n]+\.md)",
|
|
295
|
+
r"[Ff]ile[:\s]+([^\s\n]+\.md)",
|
|
296
|
+
r"[Oo]utput[:\s]+([^\s\n]+\.md)",
|
|
297
|
+
]
|
|
298
|
+
for pattern in path_patterns:
|
|
299
|
+
match = re.search(pattern, file_input)
|
|
300
|
+
if match:
|
|
301
|
+
paper_path = match.group(1)
|
|
302
|
+
file_input = {"paper_path": paper_path}
|
|
303
|
+
break
|
|
289
304
|
|
|
290
305
|
# Extract paper directory path
|
|
291
306
|
paper_dir = cls.extract_file_path(file_input)
|
|
@@ -53,6 +53,46 @@ def get_preferred_llm_class(config_path: str = "mcp_agent.secrets.yaml") -> Type
|
|
|
53
53
|
return OpenAIAugmentedLLM
|
|
54
54
|
|
|
55
55
|
|
|
56
|
+
def get_token_limits(config_path: str = "mcp_agent.config.yaml") -> Tuple[int, int]:
|
|
57
|
+
"""
|
|
58
|
+
Get token limits from configuration.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
config_path: Path to the main configuration file
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
tuple: (base_max_tokens, retry_max_tokens)
|
|
65
|
+
"""
|
|
66
|
+
# Default values that work with qwen/qwen-max (32768 total context)
|
|
67
|
+
default_base = 20000
|
|
68
|
+
default_retry = 15000
|
|
69
|
+
|
|
70
|
+
try:
|
|
71
|
+
if os.path.exists(config_path):
|
|
72
|
+
with open(config_path, "r", encoding="utf-8") as f:
|
|
73
|
+
config = yaml.safe_load(f)
|
|
74
|
+
|
|
75
|
+
openai_config = config.get("openai", {})
|
|
76
|
+
base_tokens = openai_config.get("base_max_tokens", default_base)
|
|
77
|
+
retry_tokens = openai_config.get("retry_max_tokens", default_retry)
|
|
78
|
+
|
|
79
|
+
print(
|
|
80
|
+
f"⚙️ Token limits from config: base={base_tokens}, retry={retry_tokens}"
|
|
81
|
+
)
|
|
82
|
+
return base_tokens, retry_tokens
|
|
83
|
+
else:
|
|
84
|
+
print(
|
|
85
|
+
f"⚠️ Config file {config_path} not found, using defaults: base={default_base}, retry={default_retry}"
|
|
86
|
+
)
|
|
87
|
+
return default_base, default_retry
|
|
88
|
+
except Exception as e:
|
|
89
|
+
print(f"⚠️ Error reading token config from {config_path}: {e}")
|
|
90
|
+
print(
|
|
91
|
+
f"🔧 Falling back to default token limits: base={default_base}, retry={default_retry}"
|
|
92
|
+
)
|
|
93
|
+
return default_base, default_retry
|
|
94
|
+
|
|
95
|
+
|
|
56
96
|
def get_default_models(config_path: str = "mcp_agent.config.yaml"):
|
|
57
97
|
"""
|
|
58
98
|
Get default models from configuration file.
|