auto-coder-web 0.1.39__py3-none-any.whl → 0.1.41__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.
- auto_coder_web/auto_coder_runner_wrapper.py +6 -1
- auto_coder_web/common_router/model_router.py +4 -4
- auto_coder_web/init_project.py +26 -0
- auto_coder_web/proxy.py +40 -74
- auto_coder_web/version.py +1 -1
- auto_coder_web/web/asset-manifest.json +6 -6
- auto_coder_web/web/index.html +1 -1
- auto_coder_web/web/static/css/{main.0ef9afe0.css → main.d58ae48e.css} +3 -3
- auto_coder_web/web/static/css/main.d58ae48e.css.map +1 -0
- auto_coder_web/web/static/js/{main.c3e68e66.js → main.0fc8391d.js} +3 -3
- auto_coder_web/web/static/js/{main.c3e68e66.js.map → main.0fc8391d.js.map} +1 -1
- {auto_coder_web-0.1.39.dist-info → auto_coder_web-0.1.41.dist-info}/METADATA +1 -1
- {auto_coder_web-0.1.39.dist-info → auto_coder_web-0.1.41.dist-info}/RECORD +17 -17
- auto_coder_web/auto_coder_runner.py +0 -836
- auto_coder_web/web/static/css/main.0ef9afe0.css.map +0 -1
- /auto_coder_web/web/static/js/{main.c3e68e66.js.LICENSE.txt → main.0fc8391d.js.LICENSE.txt} +0 -0
- {auto_coder_web-0.1.39.dist-info → auto_coder_web-0.1.41.dist-info}/WHEEL +0 -0
- {auto_coder_web-0.1.39.dist-info → auto_coder_web-0.1.41.dist-info}/entry_points.txt +0 -0
- {auto_coder_web-0.1.39.dist-info → auto_coder_web-0.1.41.dist-info}/top_level.txt +0 -0
@@ -33,13 +33,18 @@ from autocoder.auto_coder_runner import (
|
|
33
33
|
completer,
|
34
34
|
summon,
|
35
35
|
get_memory,
|
36
|
+
get_all_extensions
|
36
37
|
)
|
37
38
|
|
38
39
|
class AutoCoderRunnerWrapper:
|
39
40
|
def __init__(self, project_path: str, product_mode: str = "lite"):
|
41
|
+
self.project_path = project_path
|
42
|
+
self.product_mode = product_mode
|
40
43
|
load_memory()
|
41
44
|
load_tokenizer()
|
42
|
-
|
45
|
+
|
46
|
+
def get_all_extensions_wrapper(self):
|
47
|
+
return get_all_extensions(self.project_path)
|
43
48
|
|
44
49
|
def auto_command_wrapper(self, command: str, params: Dict[str, Any]) -> Dict[str, str]:
|
45
50
|
return auto_command(command,params)
|
@@ -23,7 +23,8 @@ class Model(BaseModel):
|
|
23
23
|
model_name: str
|
24
24
|
model_type: str
|
25
25
|
base_url: str
|
26
|
-
|
26
|
+
api_key: str = ""
|
27
|
+
api_key_path:str = ""
|
27
28
|
is_reasoning: bool = False
|
28
29
|
input_price: float = 0.0
|
29
30
|
output_price: float = 0.0
|
@@ -60,9 +61,8 @@ async def add_model(model: Model):
|
|
60
61
|
existing_models = model_utils.load_models()
|
61
62
|
if any(m["name"] == model.name for m in existing_models):
|
62
63
|
raise HTTPException(status_code=400, detail="Model with this name already exists")
|
63
|
-
|
64
|
-
|
65
|
-
model_utils.save_models(existing_models)
|
64
|
+
|
65
|
+
model_utils.add_and_activate_models([model.model_dump()])
|
66
66
|
return model
|
67
67
|
except Exception as e:
|
68
68
|
raise HTTPException(status_code=500, detail=str(e))
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import os
|
2
|
+
from autocoder.common import git_utils
|
3
|
+
def init_project(project_path: str):
|
4
|
+
os.makedirs(os.path.join(project_path, "actions"), exist_ok=True)
|
5
|
+
os.makedirs(os.path.join(project_path,
|
6
|
+
".auto-coder"), exist_ok=True)
|
7
|
+
|
8
|
+
from autocoder.common.command_templates import create_actions
|
9
|
+
|
10
|
+
source_dir = os.path.abspath(project_path)
|
11
|
+
create_actions(
|
12
|
+
source_dir=source_dir,
|
13
|
+
params={"project_type": "python",
|
14
|
+
"source_dir": source_dir},
|
15
|
+
)
|
16
|
+
git_utils.init(os.path.abspath(project_path))
|
17
|
+
|
18
|
+
with open(os.path.join(source_dir, ".gitignore"), "a") as f:
|
19
|
+
f.write("\n.auto-coder/")
|
20
|
+
f.write("\n/actions/")
|
21
|
+
f.write("\n/output.txt")
|
22
|
+
|
23
|
+
print(
|
24
|
+
f"""Successfully initialized auto-coder project in {os.path.abspath(project_path)}."""
|
25
|
+
)
|
26
|
+
return
|
auto_coder_web/proxy.py
CHANGED
@@ -16,10 +16,6 @@ import argparse
|
|
16
16
|
import aiofiles
|
17
17
|
import pkg_resources
|
18
18
|
import sys
|
19
|
-
from auto_coder_web.auto_coder_runner import AutoCoderRunner
|
20
|
-
from .types import (
|
21
|
-
FileContentResponse,
|
22
|
-
)
|
23
19
|
from .terminal import terminal_manager
|
24
20
|
from autocoder.common import AutoCoderArgs
|
25
21
|
from auto_coder_web.auto_coder_runner_wrapper import AutoCoderRunnerWrapper
|
@@ -31,26 +27,31 @@ from loguru import logger
|
|
31
27
|
from auto_coder_web.lang import get_message
|
32
28
|
|
33
29
|
class ProxyServer:
|
34
|
-
def __init__(self, project_path: str, quick: bool = False, product_mode: str = "pro"):
|
30
|
+
def __init__(self, project_path: str, quick: bool = False, product_mode: str = "pro"):
|
35
31
|
self.app = FastAPI()
|
36
|
-
self.setup_middleware()
|
32
|
+
self.setup_middleware()
|
37
33
|
|
38
34
|
self.setup_static_files()
|
39
35
|
self.project_path = project_path
|
40
|
-
|
36
|
+
self.product_mode = product_mode
|
37
|
+
self.auto_coder_runner = None
|
41
38
|
# Check if project is initialized
|
42
39
|
self.is_initialized = self.check_project_initialization()
|
43
|
-
if not self.is_initialized:
|
40
|
+
if not self.is_initialized and product_mode == "pro":
|
44
41
|
logger.warning(get_message("project_not_initialized"))
|
45
42
|
logger.warning(get_message("run_auto_coder_chat"))
|
46
|
-
sys.exit(1)
|
47
|
-
|
48
|
-
self.auto_coder_runner = AutoCoderRunnerWrapper(project_path, product_mode=product_mode)
|
49
|
-
|
43
|
+
sys.exit(1)
|
50
44
|
|
45
|
+
if self.is_initialized:
|
46
|
+
self._initialize()
|
47
|
+
|
51
48
|
self.setup_routes()
|
49
|
+
|
50
|
+
def _initialize(self):
|
51
|
+
self.auto_coder_runner = AutoCoderRunnerWrapper(self.project_path, product_mode=self.product_mode)
|
52
52
|
self.client = httpx.AsyncClient()
|
53
53
|
|
54
|
+
|
54
55
|
def setup_middleware(self):
|
55
56
|
self.app.add_middleware(
|
56
57
|
CORSMiddleware,
|
@@ -127,10 +128,7 @@ class ProxyServer:
|
|
127
128
|
|
128
129
|
@self.app.get("/api/project-path")
|
129
130
|
async def get_project_path():
|
130
|
-
return {"project_path": self.project_path}
|
131
|
-
|
132
|
-
def get_project_runner(project_path: str) -> AutoCoderRunner:
|
133
|
-
return self.projects[project_path]
|
131
|
+
return {"project_path": self.project_path}
|
134
132
|
|
135
133
|
@self.app.get("/api/os")
|
136
134
|
async def get_os():
|
@@ -162,65 +160,33 @@ class ProxyServer:
|
|
162
160
|
"default": field.default
|
163
161
|
})
|
164
162
|
return {"keys": keys}
|
163
|
+
|
164
|
+
|
165
|
+
@self.app.post("/api/initialization-project")
|
166
|
+
async def initialization_project():
|
167
|
+
"""Get the project initialization status"""
|
168
|
+
from auto_coder_web.init_project import init_project
|
169
|
+
init_project(self.project_path)
|
170
|
+
base_persist_dir = os.path.join(self.project_path,".auto-coder", "plugins", "chat-auto-coder")
|
171
|
+
os.makedirs(base_persist_dir, exist_ok=True)
|
172
|
+
self.is_initialized = True
|
173
|
+
self._initialize()
|
174
|
+
return {"success": True}
|
175
|
+
|
176
|
+
@self.app.get("/api/guess/project_type")
|
177
|
+
async def get_project_type():
|
178
|
+
v = self.auto_coder_runner.get_all_extensions_wrapper()
|
179
|
+
return {
|
180
|
+
"project_type":v
|
181
|
+
}
|
182
|
+
|
183
|
+
@self.app.put("/api/congigure/project_type")
|
184
|
+
async def configure_project_type(project_type:str):
|
185
|
+
self.auto_coder_runner.configure_wrapper(f"project_type:{project_type}")
|
186
|
+
return {
|
187
|
+
"succcess": True
|
188
|
+
}
|
165
189
|
|
166
|
-
@self.app.post("/api/revert")
|
167
|
-
async def revert():
|
168
|
-
try:
|
169
|
-
result = self.auto_coder_runner.revert()
|
170
|
-
return result
|
171
|
-
except Exception as e:
|
172
|
-
raise HTTPException(status_code=500, detail=str(e))
|
173
|
-
|
174
|
-
@self.app.get("/api/active-files")
|
175
|
-
async def get_active_files():
|
176
|
-
"""获取当前活动文件列表"""
|
177
|
-
active_files = self.auto_coder_runner.get_active_files()
|
178
|
-
return active_files
|
179
|
-
|
180
|
-
@self.app.post("/api/commit")
|
181
|
-
async def commit():
|
182
|
-
try:
|
183
|
-
result = self.auto_coder_runner.commit()
|
184
|
-
return result
|
185
|
-
except Exception as e:
|
186
|
-
raise HTTPException(status_code=500, detail=str(e))
|
187
|
-
|
188
|
-
@self.app.get("/api/last-yaml")
|
189
|
-
async def get_last_yaml():
|
190
|
-
"""Get information about the last YAML file"""
|
191
|
-
return JSONResponse(content=self.auto_coder_runner.get_last_yaml_info())
|
192
|
-
|
193
|
-
@self.app.get("/api/history/file-content/{file_number}", response_model=FileContentResponse)
|
194
|
-
async def get_file_content(file_number: int):
|
195
|
-
"""获取指定编号文件的完整内容"""
|
196
|
-
auto_coder_dir = "actions"
|
197
|
-
file_name = f"{file_number}_chat_action.yml"
|
198
|
-
file_path = ""
|
199
|
-
|
200
|
-
# 搜索文件
|
201
|
-
for root, _, files in os.walk(auto_coder_dir):
|
202
|
-
if file_name in files:
|
203
|
-
file_path = os.path.join(root, file_name)
|
204
|
-
break
|
205
|
-
|
206
|
-
if not file_path:
|
207
|
-
return FileContentResponse(
|
208
|
-
success=False,
|
209
|
-
message=f"找不到文件: {file_name}"
|
210
|
-
)
|
211
|
-
|
212
|
-
try:
|
213
|
-
with open(file_path, 'r', encoding='utf-8') as f:
|
214
|
-
content = f.read()
|
215
|
-
return FileContentResponse(
|
216
|
-
success=True,
|
217
|
-
content=content
|
218
|
-
)
|
219
|
-
except Exception as e:
|
220
|
-
return FileContentResponse(
|
221
|
-
success=False,
|
222
|
-
message=f"读取文件出错: {str(e)}"
|
223
|
-
)
|
224
190
|
|
225
191
|
@self.app.get("/api/initialization-status")
|
226
192
|
async def get_initialization_status():
|
auto_coder_web/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.1.
|
1
|
+
__version__ = "0.1.41"
|
@@ -1,15 +1,15 @@
|
|
1
1
|
{
|
2
2
|
"files": {
|
3
|
-
"main.css": "/static/css/main.
|
4
|
-
"main.js": "/static/js/main.
|
3
|
+
"main.css": "/static/css/main.d58ae48e.css",
|
4
|
+
"main.js": "/static/js/main.0fc8391d.js",
|
5
5
|
"static/js/453.d855a71b.chunk.js": "/static/js/453.d855a71b.chunk.js",
|
6
6
|
"index.html": "/index.html",
|
7
|
-
"main.
|
8
|
-
"main.
|
7
|
+
"main.d58ae48e.css.map": "/static/css/main.d58ae48e.css.map",
|
8
|
+
"main.0fc8391d.js.map": "/static/js/main.0fc8391d.js.map",
|
9
9
|
"453.d855a71b.chunk.js.map": "/static/js/453.d855a71b.chunk.js.map"
|
10
10
|
},
|
11
11
|
"entrypoints": [
|
12
|
-
"static/css/main.
|
13
|
-
"static/js/main.
|
12
|
+
"static/css/main.d58ae48e.css",
|
13
|
+
"static/js/main.0fc8391d.js"
|
14
14
|
]
|
15
15
|
}
|
auto_coder_web/web/index.html
CHANGED
@@ -1 +1 @@
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.0fc8391d.js"></script><link href="/static/css/main.d58ae48e.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|