subatomicERROR's picture
Refactored Quantum-API: removed codelama & ollama, added phi endpoint using Ollama
55cfbd7
raw
history blame
715 Bytes
from fastapi import APIRouter, HTTPException
from pydantic import BaseModel
import requests
router = APIRouter()
class QueryRequest(BaseModel):
query: str
@router.post("/")
async def phi_response(data: QueryRequest):
try:
# Call the Ollama local API to generate a response using the phi model
response = requests.post(
"http://localhost:11434/api/generate",
json={"model": "phi:latest", "prompt": data.query, "stream": False}
)
response.raise_for_status()
result = response.json()
return {"response": result.get("response", "")}
except Exception as e:
raise HTTPException(status_code=500, detail=f"Phi error: {str(e)}")