File size: 647 Bytes
e62cb42
 
 
 
 
 
1695fdf
 
 
e62cb42
 
7a79bfb
 
 
 
 
 
 
 
1695fdf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from transformers import AutoModelForCausalLM, AutoTokenizer

app = FastAPI()

# Load your fine-tuned model and tokenizer
model = AutoModelForCausalLM.from_pretrained("Hadeel11/fine-tuned-model")
tokenizer = AutoTokenizer.from_pretrained("Hadeel11/fine-tuned-model")



@app.post("/query/")
async def query_rag(request: Request):
    data = await request.json()
    question = data.get("question", "")
    contexts = query_qdrant(question, top_k=2)
    answer = generate_answer(question, contexts)
    return {"question": question, "contexts": contexts, "answer": answer}