cakebut commited on
Commit
c62b4e7
·
verified ·
1 Parent(s): e1ef9b6

Create requirements.txt

Browse files
Files changed (1) hide show
  1. requirements.txt +16 -0
requirements.txt ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from llama_cpp import Llama
3
+
4
+ app = FastAPI()
5
+
6
+ # Load your GGUF model
7
+ llm = Llama.from_pretrained("llama-2-7b-chat.Q4_K_M.gguf", n_ctx=1024)
8
+
9
+ @app.get("/")
10
+ def root():
11
+ return {"status": "ok"}
12
+
13
+ @app.post("/chat")
14
+ def chat(message: str):
15
+ completion = llm.create_chat_completion(messages=[{"role": "user", "content": message}], max_tokens=512)
16
+ return {"answer": completion['choices'][0]['message']['content']}