krish10 commited on
Commit
b58c7c1
·
verified ·
1 Parent(s): c2a32a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -15,7 +15,6 @@ model = AutoModelForCausalLM.from_pretrained(
15
  )
16
  model.eval()
17
 
18
- # Optional: prepend this system instruction to guide assistant behavior
19
  SYSTEM_PROMPT = "You are an expert biomedical assistant trained to identify randomized controlled trials (RCTs). Include RCTs and exclude non-RCTs."
20
 
21
  @spaces.GPU(duration=120)
@@ -57,10 +56,19 @@ def chat_with_llm(message, history):
57
 
58
  return reply
59
 
 
 
 
 
 
 
60
  chatbot = gr.ChatInterface(
61
  fn=chat_with_llm,
 
 
 
62
  title="🧠 RCT Classifier Demonstration",
63
  )
64
 
65
  if __name__ == "__main__":
66
- chatbot.launch()
 
15
  )
16
  model.eval()
17
 
 
18
  SYSTEM_PROMPT = "You are an expert biomedical assistant trained to identify randomized controlled trials (RCTs). Include RCTs and exclude non-RCTs."
19
 
20
  @spaces.GPU(duration=120)
 
56
 
57
  return reply
58
 
59
+ def format_message(title, abstract):
60
+ return f"Title: {title.strip()}\nAbstract: {abstract.strip()}"
61
+
62
+ title_input = gr.Textbox(label="Title", placeholder="Enter the title of the article")
63
+ abstract_input = gr.Textbox(label="Abstract", placeholder="Enter the abstract", lines=6)
64
+
65
  chatbot = gr.ChatInterface(
66
  fn=chat_with_llm,
67
+ textbox=gr.Textbox(visible=False), # Hide default textbox
68
+ additional_inputs=[title_input, abstract_input],
69
+ submit_fn=lambda title, abstract: format_message(title, abstract),
70
  title="🧠 RCT Classifier Demonstration",
71
  )
72
 
73
  if __name__ == "__main__":
74
+ chatbot.launch()