Update app.py
Browse files12345678910111213141516171819202122# app.pyimport gradio as grfrom prices_server import get_gold_pricedef metal_agent(message, history):if "gold" in message.lower():data = get_gold_price()reply = f"π° **Gold Live Price:** ${data['live_price']}\n\nπ **Next 7 Days Prediction:**\n"for date, price in data["predicted"].items():reply += f"- {date}: ${price}\n"return replyelse:return "I can currently predict only gold prices."iface = gr.ChatInterface(metal_agent,title="Gold Price AI Agent (MCP + Yahoo Finance)",description="Get live gold price and 7-day prediction powered by MCP + Yahoo Finance.")if __name__ == "__main__":iface.launch()12345678910111213141516171819202122232425# app.pyimport gradio as grfrom prices_server import get_reportdef metal_agent(message, history):message = message.lower().strip()if "gold" in message or "xau" in message:live_price, hist, pred = get_report("XAU")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)}"elif "silver" in message or "xag" in message:live_price, hist, pred = get_report("XAG")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)}"else:reply = "Please mention either 'gold' or 'silver' to get rates and predictions."return replychatbot = gr.ChatInterface(fn=metal_agent,title="π Metal AI Agent",description="Get live & predicted prices for Gold/Silver using 30 days of historical data.",theme="soft",)if __name__ == "__main__":chatbot.launch(server_name="0.0.0.0", server_port=7860, share=True)
app.py+16-13