Spaces:
Runtime error
Runtime error
File size: 671 Bytes
7937220 bd41508 7937220 ddb6686 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import anyio.to_thread
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
from pydantic import BaseModel
from smolagents import CodeAgent, InferenceClientModel
from deepengineer.deepsearch.main_agent import main_search
app = FastAPI()
class AgentRequest(BaseModel):
task: str
@app.post("/deepsearch")
async def run_agent(request: AgentRequest):
task = request.task
# Run the agent synchronously in a background thread
result, output_image_path = await anyio.to_thread.run_sync(main_search, task)
return JSONResponse(content={"result": result})
@app.get("/")
async def root():
return {"message": "Hello World"}
|