Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -188,7 +188,9 @@ def generate_rag(
|
|
188 |
| XMLOutputParser()
|
189 |
)
|
190 |
result = rag_chain.invoke({"input": prompt})
|
191 |
-
|
|
|
|
|
192 |
|
193 |
|
194 |
def process_input(topic, length, tone, format_, pdfs):
|
@@ -208,11 +210,7 @@ def process_input(topic, length, tone, format_, pdfs):
|
|
208 |
sys_message=""
|
209 |
)
|
210 |
|
211 |
-
|
212 |
-
generated_text = rag_output.get('answer', '')
|
213 |
-
citations = rag_output.get('citations', '')
|
214 |
-
|
215 |
-
return generated_text, citations
|
216 |
|
217 |
|
218 |
def generate(
|
@@ -230,7 +228,7 @@ def generate(
|
|
230 |
|
231 |
def create_app():
|
232 |
with gr.Blocks() as app:
|
233 |
-
with gr.
|
234 |
topic_input = gr.Textbox(
|
235 |
label="Topic",
|
236 |
placeholder="Enter the main topic of your article",
|
@@ -279,18 +277,18 @@ def create_app():
|
|
279 |
elem_classes="input-highlight-turquoise",
|
280 |
)
|
281 |
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
|
288 |
-
generate_button.click(
|
289 |
-
fn=process_input,
|
290 |
-
inputs=[topic_input, length_input, tone_input, format_input, pdf_input],
|
291 |
-
outputs=[generated_text_output, citations_output]
|
292 |
-
)
|
293 |
-
|
294 |
return app
|
295 |
|
296 |
# Run the app
|
|
|
188 |
| XMLOutputParser()
|
189 |
)
|
190 |
result = rag_chain.invoke({"input": prompt})
|
191 |
+
from pprint import pprint
|
192 |
+
pprint(result)
|
193 |
+
return result['cited_answer'][0]['answer'], result['cited_answer'][1]['citations']
|
194 |
|
195 |
|
196 |
def process_input(topic, length, tone, format_, pdfs):
|
|
|
210 |
sys_message=""
|
211 |
)
|
212 |
|
213 |
+
return rag_output
|
|
|
|
|
|
|
|
|
214 |
|
215 |
|
216 |
def generate(
|
|
|
228 |
|
229 |
def create_app():
|
230 |
with gr.Blocks() as app:
|
231 |
+
with gr.Column():
|
232 |
topic_input = gr.Textbox(
|
233 |
label="Topic",
|
234 |
placeholder="Enter the main topic of your article",
|
|
|
277 |
elem_classes="input-highlight-turquoise",
|
278 |
)
|
279 |
|
280 |
+
pdf_input = gr.File(label="Upload PDFs", file_types=["pdf"], file_count="multiple")
|
281 |
+
generate_button = gr.Button("Generate")
|
282 |
+
with gr.Column():
|
283 |
+
generated_text_output = gr.Textbox(label="Generated Text", lines=10)
|
284 |
+
citations_output = gr.Textbox(label="Citations", lines=10)
|
285 |
+
|
286 |
+
generate_button.click(
|
287 |
+
fn=process_input,
|
288 |
+
inputs=[topic_input, length_input, tone_input, format_input, pdf_input],
|
289 |
+
outputs=[generated_text_output, citations_output]
|
290 |
+
)
|
291 |
|
|
|
|
|
|
|
|
|
|
|
|
|
292 |
return app
|
293 |
|
294 |
# Run the app
|