update
Browse files
app.py
CHANGED
|
@@ -1,30 +1,17 @@
|
|
| 1 |
-
from fastapi import FastAPI, HTTPException
|
| 2 |
from fastapi.responses import Response
|
| 3 |
-
from pydantic import BaseModel
|
| 4 |
import ollama
|
|
|
|
| 5 |
app = FastAPI()
|
| 6 |
|
| 7 |
@app.get('/')
|
| 8 |
def home():
|
| 9 |
return "Hello world"
|
| 10 |
|
| 11 |
-
# @app.post("/chat")
|
| 12 |
-
# async def chat(query: str):
|
| 13 |
-
# if not query:
|
| 14 |
-
# return {"error": "Message cannot be empty."}
|
| 15 |
-
|
| 16 |
-
# response = ollama.chat(model="llama3", messages=[{"role": "user", "content": query}])
|
| 17 |
-
# return {"response": response['message']['content']}
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
class ChatRequest(BaseModel):
|
| 22 |
-
query: str
|
| 23 |
-
|
| 24 |
@app.post("/chat")
|
| 25 |
-
async def chat(
|
| 26 |
-
if not
|
| 27 |
-
|
| 28 |
|
| 29 |
-
response = ollama.chat(model="llama3", messages=[{"role": "user", "content":
|
| 30 |
return {"response": response['message']['content']}
|
|
|
|
| 1 |
+
from fastapi import FastAPI, Request, HTTPException
|
| 2 |
from fastapi.responses import Response
|
|
|
|
| 3 |
import ollama
|
| 4 |
+
|
| 5 |
app = FastAPI()
|
| 6 |
|
| 7 |
@app.get('/')
|
| 8 |
def home():
|
| 9 |
return "Hello world"
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
@app.post("/chat")
|
| 12 |
+
async def chat(query: str):
|
| 13 |
+
if not query:
|
| 14 |
+
return {"error": "Message cannot be empty."}
|
| 15 |
|
| 16 |
+
response = ollama.chat(model="llama3", messages=[{"role": "user", "content": query}])
|
| 17 |
return {"response": response['message']['content']}
|