Skip to content

Instantly share code, notes, and snippets.

@fliepeltje
Created July 25, 2024 10:58
Show Gist options
  • Select an option

  • Save fliepeltje/8a8ce9e364097ce61db67cd713799b24 to your computer and use it in GitHub Desktop.

Select an option

Save fliepeltje/8a8ce9e364097ce61db67cd713799b24 to your computer and use it in GitHub Desktop.
FastAPI with ollama on Fly.io
import os
from fastapi import FastAPI
from ollama import AsyncClient
OLLAMA_HOST = os.getenv('OLLAMA_HOST')
ollama_client = AsyncClient(OLLAMA_HOST)
app = FastAPI()
@app.get("/")
async def read_root():
resp = await ollama_client.generate(
model="llama3.1",
prompt="Why is the sky not green?",
)
return resp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment