savan360 commited on
Commit
6282da4
·
verified ·
1 Parent(s): d865a2c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -21
app.py CHANGED
@@ -1,27 +1,17 @@
1
  import gradio as gr
2
- from transformers import pipeline
3
 
4
- # Load the QA model only once at the start
5
- qa_pipeline = pipeline("question-answering", model="deepset/roberta-base-squad2")
6
-
7
- def get_answer(question):
8
- # Predefined factual context
9
- context = """
10
- Washington, D.C. is the capital of the United States of America.
11
- New Delhi is the capital of India.
12
- London is the capital of the United Kingdom.
13
- """
14
-
15
- answer = qa_pipeline(question=question, context=context)
16
- return answer["answer"]
17
-
18
- # Create Gradio Interface
19
  iface = gr.Interface(
20
- fn=get_answer,
21
- inputs="text",
22
- outputs="text",
23
- title="Ask Any Question",
24
- description="Ask factual questions and get precise answers."
 
 
 
 
25
  )
26
 
 
27
  iface.launch()
 
1
  import gradio as gr
 
2
 
3
+ # Define the Gradio interface
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  iface = gr.Interface(
5
+ fn=generate_response,
6
+ inputs=[
7
+ gr.inputs.Textbox(lines=2, label="Input Prompt"),
8
+ gr.inputs.Slider(minimum=50, maximum=200, step=10, default=100, label="Max Length"),
9
+ gr.inputs.Slider(minimum=0.1, maximum=1.0, step=0.1, default=0.7, label="Temperature")
10
+ ],
11
+ outputs=gr.outputs.Textbox(label="Generated Response"),
12
+ title="Llama 2 Chatbot",
13
+ description="Interact with the Llama 2 model using Gradio."
14
  )
15
 
16
+ # Launch the interface
17
  iface.launch()