Created
July 25, 2024 10:58
-
-
Save fliepeltje/8a8ce9e364097ce61db67cd713799b24 to your computer and use it in GitHub Desktop.
FastAPI with ollama on Fly.io
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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