Добавлен auto model routing в prompt sandbox

Этот коммит содержится в:
Виктор
2026-05-11 22:23:16 +09:00
родитель 4856114a52
Коммит e8d9eda61a
+7 -6
Просмотреть файл
@@ -37,6 +37,7 @@ class OpenAIConfigRequest(BaseModel):
class PromptTestRequest(BaseModel): class PromptTestRequest(BaseModel):
prompt: str prompt: str
task_type: str | None = None
@app.get('/') @app.get('/')
@@ -105,26 +106,26 @@ async def test_prompt(payload: PromptTestRequest):
raise HTTPException(status_code=400, detail='Prompt is empty') raise HTTPException(status_code=400, detail='Prompt is empty')
try: try:
answer = await ask_ai(prompt) result = await ask_ai(prompt, payload.task_type)
except OpenAIConfigurationError as exc: except OpenAIConfigurationError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc raise HTTPException(status_code=400, detail=str(exc)) from exc
return { return {
'success': True, 'success': True,
'model': get_openai_model(), 'model': result['model'],
'answer': answer, 'answer': result['answer'],
} }
@app.post('/api/settings/openai/test') @app.post('/api/settings/openai/test')
async def test_openai_connection(): async def test_openai_connection():
try: try:
answer = await ask_ai('Reply with exactly: DevConsole AI connection OK') result = await ask_ai('Reply with exactly: DevConsole AI connection OK', 'test')
except OpenAIConfigurationError as exc: except OpenAIConfigurationError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc raise HTTPException(status_code=400, detail=str(exc)) from exc
return { return {
'success': True, 'success': True,
'model': get_openai_model(), 'model': result['model'],
'answer': answer, 'answer': result['answer'],
} }