bhaveshgoel07 commited on
Commit
4ea1753
·
1 Parent(s): ff2355a
Files changed (1) hide show
  1. app.py +17 -10
app.py CHANGED
@@ -24,22 +24,29 @@ gemma_lm = GemmaCausalLM.from_preset("hf://bhaveshgoel07/MedCode")
24
 
25
  # Gradio app function
26
  def generate_response(prompt):
27
- prompt = "you are a medical coder who's job is to help medical coders with ICD 10 codes"
28
  template = "Instruction:\n{instruction}\n\nResponse:\n{response}"
29
  formatted_prompt = template.format(instruction=prompt, response="")
30
 
31
  # Generate output
32
- output = gemma_lm.generate(prompt+formatted_prompt, max_length=100)
33
 
34
  return output
35
 
36
- # Gradio interface
37
- interface = gr.Interface(
38
- fn=generate_response,
39
- inputs=gr.Textbox(label="Enter your prompt"),
40
- outputs=gr.Textbox(label="Response"),
41
- title="Fine-tuned GemmaCausalLM Chatbot",
42
- description="Enter a prompt to get a response from the fine-tuned GemmaCausalLM model.",
43
- )
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  interface.launch()
 
24
 
25
  # Gradio app function
26
  def generate_response(prompt):
 
27
  template = "Instruction:\n{instruction}\n\nResponse:\n{response}"
28
  formatted_prompt = template.format(instruction=prompt, response="")
29
 
30
  # Generate output
31
+ output = gemma_lm.generate(formatted_prompt, max_length=100)
32
 
33
  return output
34
 
 
 
 
 
 
 
 
 
35
 
36
+ # Use Gradio Blocks for more layout control
37
+ with gr.Blocks() as interface:
38
+ gr.Markdown("## Fine-tuned GemmaCausalLM Chatbot")
39
+ gr.Markdown("Enter a prompt to get a response from the fine-tuned GemmaCausalLM model.")
40
+
41
+ with gr.Row():
42
+ prompt_input = gr.Textbox(label="Enter your prompt")
43
+ response_output = gr.Textbox(label="Response")
44
+
45
+ generate_button = gr.Button("Generate")
46
+ generate_button.click(generate_response, inputs=prompt_input, outputs=response_output)
47
+
48
+ # Add footer text at the bottom
49
+ gr.Markdown("Some Examples:\n 1. Cholera due to Vibrio cholerae 01, biovar cholerae ICD Code:A00.0\n 2. Cholera, Unspecified ICD Code:A00.9\n 3. Typhoid pneumonia, Typhoid Fever ICD Code:A01.03")
50
+
51
+ # Launch the interface
52
  interface.launch()