Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,25 @@
|
|
| 1 |
# app.py
|
| 2 |
import gradio as gr
|
| 3 |
-
from prices_server import
|
| 4 |
|
| 5 |
def metal_agent(message, history):
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
| 12 |
else:
|
| 13 |
-
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
metal_agent,
|
| 17 |
-
title="
|
| 18 |
-
description="Get live
|
|
|
|
| 19 |
)
|
| 20 |
|
| 21 |
if __name__ == "__main__":
|
| 22 |
-
|
|
|
|
| 1 |
# app.py
|
| 2 |
import gradio as gr
|
| 3 |
+
from prices_server import get_report
|
| 4 |
|
| 5 |
def metal_agent(message, history):
|
| 6 |
+
message = message.lower().strip()
|
| 7 |
+
if "gold" in message or "xau" in message:
|
| 8 |
+
live_price, hist, pred = get_report("XAU")
|
| 9 |
+
reply = f"💰 **Gold (XAU)**\n\nLive Price: **${live_price:.2f}**\n\nLast 5 Days:\n{hist.to_string(index=False)}\n\n📈 Predicted Next 7 Days:\n{pred.to_string(index=False)}"
|
| 10 |
+
elif "silver" in message or "xag" in message:
|
| 11 |
+
live_price, hist, pred = get_report("XAG")
|
| 12 |
+
reply = f"💰 **Silver (XAG)**\n\nLive Price: **${live_price:.2f}**\n\nLast 5 Days:\n{hist.to_string(index=False)}\n\n📈 Predicted Next 7 Days:\n{pred.to_string(index=False)}"
|
| 13 |
else:
|
| 14 |
+
reply = "Please mention either 'gold' or 'silver' to get rates and predictions."
|
| 15 |
+
return reply
|
| 16 |
|
| 17 |
+
chatbot = gr.ChatInterface(
|
| 18 |
+
fn=metal_agent,
|
| 19 |
+
title="💎 Metal AI Agent",
|
| 20 |
+
description="Get live & predicted prices for Gold/Silver using 30 days of historical data.",
|
| 21 |
+
theme="soft",
|
| 22 |
)
|
| 23 |
|
| 24 |
if __name__ == "__main__":
|
| 25 |
+
chatbot.launch(server_name="0.0.0.0", server_port=7860, share=True)
|