Добавлен API анализатора GitHub проектов

Этот коммит содержится в:
Виктор
2026-05-11 22:25:31 +09:00
родитель 7a277df9b0
Коммит 9b0f551618
+23
Просмотреть файл
@@ -12,6 +12,7 @@ from backend.config_store import (
set_setting, set_setting,
) )
from backend.openai_client import OpenAIConfigurationError, ask_ai from backend.openai_client import OpenAIConfigurationError, ask_ai
from backend.project_analyzer import analyze_github_project
ROOT_DIR = Path(__file__).resolve().parent.parent ROOT_DIR = Path(__file__).resolve().parent.parent
FRONTEND_DIR = ROOT_DIR / 'frontend' FRONTEND_DIR = ROOT_DIR / 'frontend'
@@ -40,6 +41,10 @@ class PromptTestRequest(BaseModel):
task_type: str | None = None task_type: str | None = None
class ProjectAnalyzeRequest(BaseModel):
repo_url: str
@app.get('/') @app.get('/')
async def root(): async def root():
index_file = FRONTEND_DIR / 'index.html' index_file = FRONTEND_DIR / 'index.html'
@@ -129,3 +134,21 @@ async def test_openai_connection():
'model': result['model'], 'model': result['model'],
'answer': result['answer'], 'answer': result['answer'],
} }
@app.post('/api/projects/analyze')
async def analyze_project(payload: ProjectAnalyzeRequest):
repo_url = payload.repo_url.strip()
if not repo_url.startswith('http'):
raise HTTPException(status_code=400, detail='Invalid repository URL')
try:
analysis = analyze_github_project(repo_url)
except Exception as exc:
raise HTTPException(status_code=500, detail=str(exc)) from exc
return {
'success': True,
'analysis': analysis.to_dict(),
}