Spaces:
Paused
Paused
Echo-ai
commited on
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from langchain_community.llms import Ollama
|
| 3 |
+
|
| 4 |
+
app = FastAPI()
|
| 5 |
+
|
| 6 |
+
# Initialize the Ollama model
|
| 7 |
+
llm = Ollama(model="tinyllama")
|
| 8 |
+
|
| 9 |
+
@app.get("/")
|
| 10 |
+
async def root():
|
| 11 |
+
return {"message": "Ollama is running on Hugging Face Spaces!"}
|
| 12 |
+
|
| 13 |
+
@app.get("/chat")
|
| 14 |
+
async def chat(query: str):
|
| 15 |
+
response = llm.invoke(query)
|
| 16 |
+
return {"response": response}
|