Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI, Request
|
| 2 |
+
from llama_cpp import Llama
|
| 3 |
+
|
| 4 |
+
app = FastAPI()
|
| 5 |
+
# Load your 3.6GB model
|
| 6 |
+
llm = Llama(model_path="./mpt-7b-chat.ggmlv0.q4_0.bin")
|
| 7 |
+
|
| 8 |
+
@app.post("/v1/chat")
|
| 9 |
+
async def chat(request: Request):
|
| 10 |
+
data = await request.json()
|
| 11 |
+
# Basic API logic:
|
| 12 |
+
response = llm(data["prompt"], max_tokens=100)
|
| 13 |
+
return {"choices": [{"text": response["choices"][0]["text"]}]}
|
| 14 |
+
|
| 15 |
+
@app.get("/")
|
| 16 |
+
def home():
|
| 17 |
+
return {"status": "Your AI is Always Up!"}
|