File size: 794 Bytes
c71db97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

# Load IndicBERT Model
tokenizer = AutoTokenizer.from_pretrained("ai4bharat/indic-bert")
model = AutoModelForSequenceClassification.from_pretrained("ai4bharat/indic-bert")

def process_query(query):
    inputs = tokenizer(query, return_tensors="pt")
    with torch.no_grad():
        outputs = model(**inputs)
    predicted_label = torch.argmax(outputs.logits).item()
    # Basic intent handling (customize as needed)
    if "appointment" in query.lower():
        return "I can help you book an appointment with a doctor."
    elif "health" in query.lower():
        return "Can you describe your health concern?"
    else:
        return "Sorry, I didn’t understand. Can you please rephrase?"