allekssandr commited on
Commit
152d4a2
·
verified ·
1 Parent(s): 7573ef8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -1,13 +1,26 @@
1
  from fastapi import FastAPI
2
- from transformers import AutoModel
3
 
4
  app = FastAPI()
5
 
6
  # Загрузка модели Hugging Face
7
- model = AutoModel.from_pretrained("bartowski/Phi-3.5-mini-instruct-GGUF")
 
 
 
 
 
 
8
 
9
  @app.post("/predict")
10
  async def predict(text: str):
11
  # Генерация ответа с помощью модели
12
- result = model(text, max_length=50, num_return_sequences=1)
 
 
 
 
 
 
 
13
  return {"response": result[0]["generated_text"]}
 
1
  from fastapi import FastAPI
2
+ from llama_cpp import Llama
3
 
4
  app = FastAPI()
5
 
6
  # Загрузка модели Hugging Face
7
+
8
+
9
+ llm = Llama.from_pretrained(
10
+ repo_id="bartowski/Phi-3.5-mini-instruct-GGUF",
11
+ filename="Phi-3.5-mini-instruct-IQ2_M.gguf",
12
+ )
13
+
14
 
15
  @app.post("/predict")
16
  async def predict(text: str):
17
  # Генерация ответа с помощью модели
18
+ response = llm.create_chat_completion(
19
+ messages = [
20
+ {
21
+ "role": "user",
22
+ "content": text
23
+ }
24
+ ]
25
+ )
26
  return {"response": result[0]["generated_text"]}