akashraut commited on
Commit
5d3a8ce
·
verified ·
1 Parent(s): 7eeb38c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -13
app.py CHANGED
@@ -1,22 +1,25 @@
1
  # app.py
2
  import gradio as gr
3
- from prices_server import get_gold_price
4
 
5
  def metal_agent(message, history):
6
- if "gold" in message.lower():
7
- data = get_gold_price()
8
- reply = f"💰 **Gold Live Price:** ${data['live_price']}\n\n📈 **Next 7 Days Prediction:**\n"
9
- for date, price in data["predicted"].items():
10
- reply += f"- {date}: ${price}\n"
11
- return reply
 
12
  else:
13
- return "I can currently predict only gold prices."
 
14
 
15
- iface = gr.ChatInterface(
16
- metal_agent,
17
- title="Gold Price AI Agent (MCP + Yahoo Finance)",
18
- description="Get live gold price and 7-day prediction powered by MCP + Yahoo Finance."
 
19
  )
20
 
21
  if __name__ == "__main__":
22
- iface.launch()
 
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)