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

Class DeepCodeChat2CodeTool

nanobot/nanobot/agent/tools/deepcode.py:105–174  ·  view source on GitHub ↗

Submit text requirements to DeepCode for code generation.

Source from the content-addressed store, hash-verified

103
104
105class DeepCodeChat2CodeTool(Tool):
106 """Submit text requirements to DeepCode for code generation."""
107
108 def __init__(self, api_url: str | None = None):
109 self._api_url = api_url or _get_deepcode_url()
110
111 @property
112 def name(self) -> str:
113 return "deepcode_chat2code"
114
115 @property
116 def description(self) -> str:
117 return (
118 "Submit coding requirements to DeepCode for automatic code generation. "
119 "Provide a text description of what you want to build (e.g. web app, algorithm, backend service). "
120 "DeepCode will generate a complete implementation. "
121 "Returns a task ID for tracking progress."
122 )
123
124 @property
125 def parameters(self) -> dict[str, Any]:
126 return {
127 "type": "object",
128 "properties": {
129 "requirements": {
130 "type": "string",
131 "description": "Detailed description of coding requirements",
132 },
133 "enable_indexing": {
134 "type": "boolean",
135 "description": "Enable code reference indexing for enhanced quality. Default: false",
136 },
137 },
138 "required": ["requirements"],
139 }
140
141 async def execute(
142 self,
143 requirements: str,
144 enable_indexing: bool = False,
145 **kwargs: Any,
146 ) -> str:
147 try:
148 async with httpx.AsyncClient(timeout=30.0) as client:
149 response = await client.post(
150 f"{self._api_url}/api/v1/workflows/chat-planning",
151 json={
152 "requirements": requirements,
153 "enable_indexing": enable_indexing,
154 },
155 )
156 response.raise_for_status()
157 data = response.json()
158 task_id = data.get("task_id", "unknown")
159 return (
160 f"Chat-to-code task submitted successfully!\n"
161 f"Task ID: {task_id}\n"
162 f"Status: {data.get('status', 'started')}\n"

Callers 1

create_all_toolsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected