Update app.py
Browse files
app.py
CHANGED
@@ -114,39 +114,62 @@ additional_inputs = [
|
|
114 |
gr.Number(precision=0, value=0, label="Seed", info="A starting point to initiate generation, use 0 for random")
|
115 |
]
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
-
def greet(name):
|
119 |
-
return f"Hello, {name}!"
|
120 |
|
|
|
|
|
121 |
|
122 |
|
123 |
-
with gr.Blocks(theme="Nymbo/Alyx_Theme") as demo:
|
124 |
-
# Set the title and description for the app.
|
125 |
-
gr.Markdown("# Simple Gradio Greeter")
|
126 |
-
gr.Markdown("Enter your name and get a personalized greeting!")
|
127 |
-
|
128 |
-
# Define the input component (a text box for the name).
|
129 |
-
name_input = gr.Textbox(
|
130 |
-
lines=2,
|
131 |
-
placeholder="Enter your name here...",
|
132 |
-
label="Your Name"
|
133 |
-
)
|
134 |
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
# The 'fn' argument specifies the function to call.
|
140 |
-
# The 'inputs' argument specifies which component's value to pass to 'fn'.
|
141 |
-
# The 'outputs' argument specifies which component will display the return value of 'fn'.
|
142 |
-
submit_button = gr.Button("Get Greeting")
|
143 |
-
submit_button.click(
|
144 |
-
fn=greet,
|
145 |
-
inputs=name_input,
|
146 |
-
outputs=greeting_output
|
147 |
-
)
|
148 |
|
149 |
-
#
|
150 |
-
#
|
151 |
-
#
|
152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
gr.Number(precision=0, value=0, label="Seed", info="A starting point to initiate generation, use 0 for random")
|
115 |
]
|
116 |
|
117 |
+
# Create the Gradio interface
|
118 |
+
with gr.Blocks(theme="Nymbo/Alyx_Theme") as demo:
|
119 |
+
with gr.Tab("Indexing"):
|
120 |
+
pdf_input = gr.File(label="Upload PDF", file_types=[".pdf"])
|
121 |
+
index_button = gr.Button("Index PDF")
|
122 |
+
load_sample = gr.Button("Alternatively, Load and Index [Attention Is All You Need.pdf] as a Sample")
|
123 |
+
sample_description = gr.Markdown("This sample PDF is a seminal paper in the field of machine learning, titled 'Attention Is All You Need' at https://arxiv.org/abs/1706.03762. It introduces the Transformer model, which has become foundational in natural language processing.")
|
124 |
+
index_output = gr.Textbox(label="Indexing Status")
|
125 |
+
index_button.click(index_pdf, inputs=pdf_input, outputs=index_output)
|
126 |
+
load_sample.click(load_sample_pdf, inputs=None, outputs=index_output)
|
127 |
+
|
128 |
+
with gr.Tab("Chatbot"):
|
129 |
+
gr.ChatInterface(
|
130 |
+
fn=generate_response,
|
131 |
+
chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
|
132 |
+
examples=examples_questions,
|
133 |
+
additional_inputs=additional_inputs,
|
134 |
+
cache_examples=False,
|
135 |
+
)
|
136 |
+
|
137 |
+
# Launch the Gradio app
|
138 |
+
demo.launch()
|
139 |
|
|
|
|
|
140 |
|
141 |
+
# def greet(name):
|
142 |
+
# return f"Hello, {name}!"
|
143 |
|
144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
|
146 |
+
# with gr.Blocks(theme="Nymbo/Alyx_Theme") as demo:
|
147 |
+
# # Set the title and description for the app.
|
148 |
+
# gr.Markdown("# Simple Gradio Greeter")
|
149 |
+
# gr.Markdown("Enter your name and get a personalized greeting!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
+
# # Define the input component (a text box for the name).
|
152 |
+
# name_input = gr.Textbox(
|
153 |
+
# lines=2,
|
154 |
+
# placeholder="Enter your name here...",
|
155 |
+
# label="Your Name"
|
156 |
+
# )
|
157 |
+
|
158 |
+
# # Define the output component (a text box for the greeting).
|
159 |
+
# greeting_output = gr.Textbox(label="Greeting")
|
160 |
+
|
161 |
+
# # Add a button that will trigger the 'greet' function when clicked.
|
162 |
+
# # The 'fn' argument specifies the function to call.
|
163 |
+
# # The 'inputs' argument specifies which component's value to pass to 'fn'.
|
164 |
+
# # The 'outputs' argument specifies which component will display the return value of 'fn'.
|
165 |
+
# submit_button = gr.Button("Get Greeting")
|
166 |
+
# submit_button.click(
|
167 |
+
# fn=greet,
|
168 |
+
# inputs=name_input,
|
169 |
+
# outputs=greeting_output
|
170 |
+
# )
|
171 |
+
|
172 |
+
# # Launch the Gradio app.
|
173 |
+
# # The `share=True` argument creates a public, shareable link (useful for demos).
|
174 |
+
# # In a local environment, it will also open a local URL.
|
175 |
+
# demo.launch()
|