Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,7 +19,7 @@ def generate_response(prompt_template, **kwargs):
|
|
| 19 |
response = ""
|
| 20 |
for chunk in stream:
|
| 21 |
response += chunk.choices[0].delta.content
|
| 22 |
-
yield response # Yield incrementally
|
| 23 |
|
| 24 |
# Wrapper function for Gradio compatibility
|
| 25 |
def stream_response(prompt_template, **kwargs):
|
|
@@ -28,7 +28,7 @@ def stream_response(prompt_template, **kwargs):
|
|
| 28 |
# Gradio app interface
|
| 29 |
with gr.Blocks() as app:
|
| 30 |
gr.Markdown("## Mathematical Insight Tutor")
|
| 31 |
-
gr.Markdown("An advanced AI-powered tutor to help you master math concepts.")
|
| 32 |
|
| 33 |
def create_tab(tab_name, prompt_template, inputs):
|
| 34 |
with gr.Tab(tab_name):
|
|
@@ -48,7 +48,7 @@ with gr.Blocks() as app:
|
|
| 48 |
)
|
| 49 |
# Button and output
|
| 50 |
button = gr.Button(f"{tab_name} Execute")
|
| 51 |
-
output = gr.
|
| 52 |
# Link button to the response wrapper
|
| 53 |
button.click(
|
| 54 |
fn=lambda *args: stream_response(prompt_template, **dict(zip([inp["key"] for inp in inputs], args))),
|
|
@@ -103,5 +103,14 @@ with gr.Blocks() as app:
|
|
| 103 |
]
|
| 104 |
)
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
# Launch the app
|
| 107 |
-
app.launch(debug=True)
|
|
|
|
| 19 |
response = ""
|
| 20 |
for chunk in stream:
|
| 21 |
response += chunk.choices[0].delta.content
|
| 22 |
+
yield response # Yield incrementally for streaming
|
| 23 |
|
| 24 |
# Wrapper function for Gradio compatibility
|
| 25 |
def stream_response(prompt_template, **kwargs):
|
|
|
|
| 28 |
# Gradio app interface
|
| 29 |
with gr.Blocks() as app:
|
| 30 |
gr.Markdown("## Mathematical Insight Tutor")
|
| 31 |
+
gr.Markdown("An advanced AI-powered tutor to help you master math concepts with step-by-step explanations and LaTeX rendering.")
|
| 32 |
|
| 33 |
def create_tab(tab_name, prompt_template, inputs):
|
| 34 |
with gr.Tab(tab_name):
|
|
|
|
| 48 |
)
|
| 49 |
# Button and output
|
| 50 |
button = gr.Button(f"{tab_name} Execute")
|
| 51 |
+
output = gr.Markdown(label="Output", elem_id="latex-output")
|
| 52 |
# Link button to the response wrapper
|
| 53 |
button.click(
|
| 54 |
fn=lambda *args: stream_response(prompt_template, **dict(zip([inp["key"] for inp in inputs], args))),
|
|
|
|
| 103 |
]
|
| 104 |
)
|
| 105 |
|
| 106 |
+
# Add custom CSS for LaTeX rendering
|
| 107 |
+
app.css = """
|
| 108 |
+
#latex-output {
|
| 109 |
+
font-family: "Computer Modern", serif;
|
| 110 |
+
font-size: 16px;
|
| 111 |
+
line-height: 1.5;
|
| 112 |
+
}
|
| 113 |
+
"""
|
| 114 |
+
|
| 115 |
# Launch the app
|
| 116 |
+
app.launch(debug=True)
|