Download app.py from mgbam/AI_SQL: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/spaces/mgbam/AI_SQL/resolve/c3c6e00fab45dd3c6de3fed5858d98d8c472b1f7/app.py
- Command line
-
hf download hf://spaces/mgbam/AI_SQL@c3c6e00fab45dd3c6de3fed5858d98d8c472b1f7/app.py
-
curl -L -o app.py https://huggingface.co/spaces/mgbam/AI_SQL/resolve/c3c6e00fab45dd3c6de3fed5858d98d8c472b1f7/app.py
1.04 kB
| import gradio as gr | |
| from mcp import StdioServerParameters | |
| from smolagents import MCPClient, CodeAgent | |
| def respond(prompt, history=[]): | |
| # Launch MCP subprocess | |
| params = StdioServerParameters(command="python", args=["mcp_server.py"]) | |
| with MCPClient(params) as tools: | |
| agent = CodeAgent(tools=tools, model="gpt-4") # Replace with your local or API model | |
| result = agent.run(prompt) | |
| history.append((prompt, result)) | |
| return history, history | |
| with gr.Blocks() as demo: | |
| chat_history = gr.State([]) | |
| chatbot = gr.Chatbot(label="Enterprise SQL Agent") | |
| textbox = gr.Textbox(show_label=False, placeholder="Ask questions like 'List inactive customers in Northeast'") | |
| textbox.submit(respond, [textbox, chat_history], [chatbot, chat_history]) | |
| gr.Markdown(\"\"\"\n | |
| ### Example Prompts: | |
| - Who are my Northeast customers who haven’t ordered in 6 months? | |
| - List customers sorted by last order date. | |
| - Find clients from the West with recent orders. | |
| \"\"\") | |
| demo.launch() | |