Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -104,6 +104,11 @@ def create_bibtex_entry(data):
|
|
104 |
bibtex = bibtex.rstrip(',\n') + "\n}"
|
105 |
return bibtex
|
106 |
|
|
|
|
|
|
|
|
|
|
|
107 |
class CombinedProcessor:
|
108 |
def process(self, user_message):
|
109 |
editorial_text = re.sub("\n", " ¶ ", user_message)
|
@@ -159,7 +164,12 @@ with gr.Blocks(theme='JohnSmith9982/small_and_pretty') as demo:
|
|
159 |
text_input = gr.Textbox(label="Your text", type="text", lines=10)
|
160 |
text_button = gr.Button("Process Text")
|
161 |
bibtex_output = gr.Textbox(label="BibTeX Entries", lines=15)
|
|
|
|
|
|
|
|
|
162 |
text_button.click(processor.process, inputs=text_input, outputs=[bibtex_output])
|
|
|
163 |
|
164 |
if __name__ == "__main__":
|
165 |
demo.queue().launch()
|
|
|
104 |
bibtex = bibtex.rstrip(',\n') + "\n}"
|
105 |
return bibtex
|
106 |
|
107 |
+
def save_bibtex(bibtex_content):
|
108 |
+
with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.bib') as temp_file:
|
109 |
+
temp_file.write(bibtex_content)
|
110 |
+
return temp_file.name
|
111 |
+
|
112 |
class CombinedProcessor:
|
113 |
def process(self, user_message):
|
114 |
editorial_text = re.sub("\n", " ¶ ", user_message)
|
|
|
164 |
text_input = gr.Textbox(label="Your text", type="text", lines=10)
|
165 |
text_button = gr.Button("Process Text")
|
166 |
bibtex_output = gr.Textbox(label="BibTeX Entries", lines=15)
|
167 |
+
|
168 |
+
export_button = gr.Button("Export BibTeX")
|
169 |
+
export_output = gr.File(label="Exported BibTeX File")
|
170 |
+
|
171 |
text_button.click(processor.process, inputs=text_input, outputs=[bibtex_output])
|
172 |
+
export_button.click(save_bibtex, inputs=[bibtex_output], outputs=[export_output])
|
173 |
|
174 |
if __name__ == "__main__":
|
175 |
demo.queue().launch()
|