File size: 366 Bytes
e00b411
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from fastapi import FastAPI
from langchain_community.llms import Ollama

app = FastAPI()

# Initialize the Ollama model
llm = Ollama(model="tinyllama")

@app.get("/")
async def root():
    return {"message": "Ollama is running on Hugging Face Spaces!"}

@app.get("/chat")
async def chat(query: str):
    response = llm.invoke(query)
    return {"response": response}