Hadeel11 commited on
Commit
7a79bfb
1 Parent(s): 1695fdf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -8,14 +8,13 @@ app = FastAPI()
8
  model = AutoModelForCausalLM.from_pretrained("Hadeel11/fine-tuned-model")
9
  tokenizer = AutoTokenizer.from_pretrained("Hadeel11/fine-tuned-model")
10
 
11
- class Query(BaseModel):
12
- question: str
13
- contexts: list
14
 
15
- @app.post("/predict/")
16
- async def predict(query: Query):
17
- inputs = tokenizer(query.question, return_tensors="pt")
18
- outputs = model.generate(**inputs)
19
- answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
20
- return {"answer": answer}
 
 
21
 
 
8
  model = AutoModelForCausalLM.from_pretrained("Hadeel11/fine-tuned-model")
9
  tokenizer = AutoTokenizer.from_pretrained("Hadeel11/fine-tuned-model")
10
 
 
 
 
11
 
12
+
13
+ @app.post("/query/")
14
+ async def query_rag(request: Request):
15
+ data = await request.json()
16
+ question = data.get("question", "")
17
+ contexts = query_qdrant(question, top_k=2)
18
+ answer = generate_answer(question, contexts)
19
+ return {"question": question, "contexts": contexts, "answer": answer}
20