Spaces:
Sleeping
Sleeping
= commited on
Commit ·
670ca0b
1
Parent(s): eb457ae
Fix Gradio compatibility issues: move theme to Blocks, add api_name, update Gradio version
Browse files- app.py +12 -4
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -119,7 +119,13 @@ def reset_chat():
|
|
| 119 |
return []
|
| 120 |
|
| 121 |
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
gr.Markdown("""
|
| 124 |
# 🌾 Agricultural Research AI Agent
|
| 125 |
|
|
@@ -183,13 +189,15 @@ with gr.Blocks(title="Agricultural Research AI Agent") as demo:
|
|
| 183 |
submit_btn.click(
|
| 184 |
fn=chat_with_agent,
|
| 185 |
inputs=[msg, chatbot, api_key_input],
|
| 186 |
-
outputs=[msg, chatbot]
|
|
|
|
| 187 |
)
|
| 188 |
|
| 189 |
msg.submit(
|
| 190 |
fn=chat_with_agent,
|
| 191 |
inputs=[msg, chatbot, api_key_input],
|
| 192 |
-
outputs=[msg, chatbot]
|
|
|
|
| 193 |
)
|
| 194 |
|
| 195 |
reset_btn.click(
|
|
@@ -208,5 +216,5 @@ with gr.Blocks(title="Agricultural Research AI Agent") as demo:
|
|
| 208 |
""")
|
| 209 |
|
| 210 |
if __name__ == "__main__":
|
| 211 |
-
demo.launch(share=False, server_name="0.0.0.0", server_port=7860
|
| 212 |
|
|
|
|
| 119 |
return []
|
| 120 |
|
| 121 |
|
| 122 |
+
try:
|
| 123 |
+
theme = gr.themes.Soft()
|
| 124 |
+
blocks_kwargs = {"title": "Agricultural Research AI Agent", "theme": theme}
|
| 125 |
+
except (AttributeError, ImportError):
|
| 126 |
+
blocks_kwargs = {"title": "Agricultural Research AI Agent"}
|
| 127 |
+
|
| 128 |
+
with gr.Blocks(**blocks_kwargs) as demo:
|
| 129 |
gr.Markdown("""
|
| 130 |
# 🌾 Agricultural Research AI Agent
|
| 131 |
|
|
|
|
| 189 |
submit_btn.click(
|
| 190 |
fn=chat_with_agent,
|
| 191 |
inputs=[msg, chatbot, api_key_input],
|
| 192 |
+
outputs=[msg, chatbot],
|
| 193 |
+
api_name="chat_with_agent_submit"
|
| 194 |
)
|
| 195 |
|
| 196 |
msg.submit(
|
| 197 |
fn=chat_with_agent,
|
| 198 |
inputs=[msg, chatbot, api_key_input],
|
| 199 |
+
outputs=[msg, chatbot],
|
| 200 |
+
api_name="chat_with_agent_enter"
|
| 201 |
)
|
| 202 |
|
| 203 |
reset_btn.click(
|
|
|
|
| 216 |
""")
|
| 217 |
|
| 218 |
if __name__ == "__main__":
|
| 219 |
+
demo.launch(share=False, server_name="0.0.0.0", server_port=7860)
|
| 220 |
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
gradio>=4.
|
| 2 |
litellm>=1.0.0
|
| 3 |
python-dotenv>=1.0.0
|
| 4 |
datasets>=2.14.0
|
|
|
|
| 1 |
+
gradio>=4.44.0
|
| 2 |
litellm>=1.0.0
|
| 3 |
python-dotenv>=1.0.0
|
| 4 |
datasets>=2.14.0
|