MCPcopy
hub / github.com/HKUDS/DeepCode / DeepCodePaper2CodeTool

Class DeepCodePaper2CodeTool

nanobot/nanobot/agent/tools/deepcode.py:24–102  ·  view source on GitHub ↗

Submit a paper (URL or file path) to DeepCode for automatic code reproduction.

Source from the content-addressed store, hash-verified

22
23
24class DeepCodePaper2CodeTool(Tool):
25 """Submit a paper (URL or file path) to DeepCode for automatic code reproduction."""
26
27 def __init__(self, api_url: str | None = None):
28 self._api_url = api_url or _get_deepcode_url()
29
30 @property
31 def name(self) -> str:
32 return "deepcode_paper2code"
33
34 @property
35 def description(self) -> str:
36 return (
37 "Submit a research paper to DeepCode for automatic code reproduction. "
38 "Accepts a paper URL (e.g. arxiv link) or a local file path. "
39 "Returns a task ID for tracking progress. "
40 "The code generation process runs in the background and may take 10-60 minutes. "
41 "Use deepcode_status to check progress."
42 )
43
44 @property
45 def parameters(self) -> dict[str, Any]:
46 return {
47 "type": "object",
48 "properties": {
49 "input_source": {
50 "type": "string",
51 "description": "Paper URL (e.g. https://arxiv.org/abs/...) or local file path",
52 },
53 "input_type": {
54 "type": "string",
55 "enum": ["url", "file"],
56 "description": "Type of input: 'url' for web links, 'file' for local files",
57 },
58 "enable_indexing": {
59 "type": "boolean",
60 "description": "Enable code reference indexing for enhanced quality (slower but better). Default: false",
61 },
62 },
63 "required": ["input_source", "input_type"],
64 }
65
66 async def execute(
67 self,
68 input_source: str,
69 input_type: str = "url",
70 enable_indexing: bool = False,
71 **kwargs: Any,
72 ) -> str:
73 try:
74 async with httpx.AsyncClient(timeout=30.0) as client:
75 response = await client.post(
76 f"{self._api_url}/api/v1/workflows/paper-to-code",
77 json={
78 "input_source": input_source,
79 "input_type": input_type,
80 "enable_indexing": enable_indexing,
81 },

Callers 1

create_all_toolsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected