test_ollama / main.py
myyim's picture
Update main.py
3cf16d5 verified
raw
history blame contribute delete
674 Bytes
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
import ollama
# ollama.pull('gemma3:4b')
app = FastAPI()
@app.get("/infer_t5")
def t5(input):
response = ollama.chat(model='gemma3:4b',
messages=[{
'role': 'user',
'content': 'Describe the image',
'images': ["profile.png"]
}],
# options={"temperature":0.7}
)
return {"output": response['message']['content']}
app.mount("/", StaticFiles(directory="static", html=True), name="static")
@app.get("/")
def index() -> FileResponse:
return FileResponse(path="/app/static/index.html", media_type="text/html")