Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,7 +19,16 @@ def generate_response(prompt_template, **kwargs):
|
|
| 19 |
)
|
| 20 |
response_content = response.choices[0].message["content"]
|
| 21 |
print(response_content)
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
# Gradio app interface
|
| 25 |
with gr.Blocks() as app:
|
|
@@ -44,7 +53,7 @@ with gr.Blocks() as app:
|
|
| 44 |
)
|
| 45 |
# Button and output
|
| 46 |
button = gr.Button(f"{tab_name} Execute")
|
| 47 |
-
output = gr.
|
| 48 |
# Link button to the response wrapper
|
| 49 |
button.click(
|
| 50 |
fn=lambda *args: generate_response(prompt_template, **dict(zip([inp["key"] for inp in inputs], args))),
|
|
@@ -99,14 +108,6 @@ with gr.Blocks() as app:
|
|
| 99 |
]
|
| 100 |
)
|
| 101 |
|
| 102 |
-
# Add custom CSS for LaTeX rendering
|
| 103 |
-
app.css = """
|
| 104 |
-
#latex-output {
|
| 105 |
-
font-family: "Computer Modern", serif;
|
| 106 |
-
font-size: 16px;
|
| 107 |
-
line-height: 1.5;
|
| 108 |
-
}
|
| 109 |
-
"""
|
| 110 |
|
| 111 |
# Launch the app
|
| 112 |
app.launch(debug=True)
|
|
|
|
| 19 |
)
|
| 20 |
response_content = response.choices[0].message["content"]
|
| 21 |
print(response_content)
|
| 22 |
+
html = markdown.markdown(
|
| 23 |
+
response_content,
|
| 24 |
+
extensions=[
|
| 25 |
+
"markdown.extensions.fenced_code",
|
| 26 |
+
"markdown.extensions.tables",
|
| 27 |
+
"markdown.extensions.attr_list",
|
| 28 |
+
]
|
| 29 |
+
)
|
| 30 |
+
return f"""<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML"></script>
|
| 31 |
+
{html}"""
|
| 32 |
|
| 33 |
# Gradio app interface
|
| 34 |
with gr.Blocks() as app:
|
|
|
|
| 53 |
)
|
| 54 |
# Button and output
|
| 55 |
button = gr.Button(f"{tab_name} Execute")
|
| 56 |
+
output = gr.HTML()
|
| 57 |
# Link button to the response wrapper
|
| 58 |
button.click(
|
| 59 |
fn=lambda *args: generate_response(prompt_template, **dict(zip([inp["key"] for inp in inputs], args))),
|
|
|
|
| 108 |
]
|
| 109 |
)
|
| 110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
# Launch the app
|
| 113 |
app.launch(debug=True)
|