Behathenimro commited on
Commit
2b6c76f
·
verified ·
1 Parent(s): 49988f8

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForCausalLM
3
+ import torch
4
+
5
+ # Load your model and tokenizer
6
+ tokenizer = AutoTokenizer.from_pretrained("Behathenimro/mediQ-chat")
7
+ model = AutoModelForCausalLM.from_pretrained("Behathenimro/mediQ-chat")
8
+ model.eval()
9
+
10
+ # Define chat function
11
+ def mediq_chat(message, history=[]):
12
+ # You can optionally join past conversation to provide more context
13
+ input_ids = tokenizer.encode(message, return_tensors="pt")
14
+ with torch.no_grad():
15
+ output = model.generate(
16
+ input_ids,
17
+ max_new_tokens=200,
18
+ do_sample=True,
19
+ temperature=0.7,
20
+ top_p=0.9
21
+ )
22
+ response = tokenizer.decode(output[0], skip_special_tokens=True)
23
+ return response
24
+
25
+ # Create the Gradio chat interface
26
+ gr.ChatInterface(
27
+ fn=mediq_chat,
28
+ title="🧠 MediQ - Clinical Reasoning Chatbot",
29
+ description="Ask clinical questions. The model will respond based on its training.",
30
+ theme="default"
31
+ ).launch()