Добавлен auto model routing в prompt sandbox
Этот коммит содержится в:
@@ -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'],
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user