Selcan Yukcu commited on
Commit
c792fba
·
1 Parent(s): 734767d

refactor: new TODO's added

Browse files
gradio_app.py CHANGED
@@ -18,7 +18,7 @@ def load_db_configs():
18
 
19
  # Async-compatible wrapper
20
  async def run_agent(request):
21
- # configs = load_db_configs() # Optional if needed
22
  final_answer, last_tool_answer, = await pg_mcp_exec(request)
23
  return final_answer, last_tool_answer
24
 
@@ -31,7 +31,7 @@ demo = gr.Interface(
31
  ),
32
  outputs=gr.Textbox(label="SQL Query / Result"),
33
  title="PostgreSQL Query Agent",
34
- description="Ask your database in natural language and get results using the smolagent executor."
35
  )
36
 
37
  if __name__ == "__main__":
 
18
 
19
  # Async-compatible wrapper
20
  async def run_agent(request):
21
+ # configs = load_db_configs()
22
  final_answer, last_tool_answer, = await pg_mcp_exec(request)
23
  return final_answer, last_tool_answer
24
 
 
31
  ),
32
  outputs=gr.Textbox(label="SQL Query / Result"),
33
  title="PostgreSQL Query Agent",
34
+ description="Ask your database in natural language and get results."
35
  )
36
 
37
  if __name__ == "__main__":
main.py CHANGED
@@ -7,6 +7,7 @@ import logging
7
 
8
  #logger = logging.getLogger(__name__)
9
  # TODO add config
 
10
  def load_db_configs():
11
  """Load database configurations from databases.yaml"""
12
  configs_path = Path("configs.yaml")
@@ -23,7 +24,7 @@ def load_db_configs():
23
  async def main():
24
  #configs = load_db_configs()
25
 
26
- request = "Show me the table of join posts and users tables."
27
  await pg_mcp_exec(request)
28
 
29
 
 
7
 
8
  #logger = logging.getLogger(__name__)
9
  # TODO add config
10
+ # TODO add README
11
  def load_db_configs():
12
  """Load database configurations from databases.yaml"""
13
  configs_path = Path("configs.yaml")
 
24
  async def main():
25
  #configs = load_db_configs()
26
 
27
+ request = "send the table"
28
  await pg_mcp_exec(request)
29
 
30
 
postgre_mcp_client.py CHANGED
@@ -1,4 +1,6 @@
1
  import os.path
 
 
2
  from mcp import ClientSession, StdioServerParameters
3
  from mcp.client.stdio import stdio_client
4
  from langchain_mcp_adapters.tools import load_mcp_tools
@@ -10,7 +12,7 @@ import logging
10
 
11
  logger = logging.getLogger(__name__)
12
 
13
- async def pg_mcp_exec(request: str) -> str:
14
  """
15
  Execute the full PostgreSQL MCP pipeline: load summary, connect session,
16
  load memory and tools, build prompt, run agent, update memory.
@@ -27,7 +29,7 @@ async def pg_mcp_exec(request: str) -> str:
27
  server_params = get_server_params()
28
 
29
  # TODO: give key from env
30
- llm = init_chat_model(model="gemini-2.0-flash-lite", model_provider="google_genai",
31
  api_key="AIzaSyAuxYmci0DVU5l5L_YcxLlxHzR5MLn70js")
32
 
33
  async with stdio_client(server_params) as (read, write):
 
1
  import os.path
2
+ from typing import Tuple, Any
3
+
4
  from mcp import ClientSession, StdioServerParameters
5
  from mcp.client.stdio import stdio_client
6
  from langchain_mcp_adapters.tools import load_mcp_tools
 
12
 
13
  logger = logging.getLogger(__name__)
14
 
15
+ async def pg_mcp_exec(request: str) -> tuple[Any, Any]:
16
  """
17
  Execute the full PostgreSQL MCP pipeline: load summary, connect session,
18
  load memory and tools, build prompt, run agent, update memory.
 
29
  server_params = get_server_params()
30
 
31
  # TODO: give key from env
32
+ llm = init_chat_model(model="gemini-1.5-flash", model_provider="google_genai",
33
  api_key="AIzaSyAuxYmci0DVU5l5L_YcxLlxHzR5MLn70js")
34
 
35
  async with stdio_client(server_params) as (read, write):
postgre_smolagent_clinet.py CHANGED
@@ -45,6 +45,7 @@ async def pg_mcp_smolagent_exec(request: str) -> str:
45
  prompt = await build_prompt(session, intent, request, tools, past_data)
46
  agent_response = agent.run(task=prompt, stream=False)
47
 
 
48
 
49
  #parsed_steps, _ = parse_mcp_output(agent_response)
50
  #memory.update_from_parsed(parsed_steps, request)
 
45
  prompt = await build_prompt(session, intent, request, tools, past_data)
46
  agent_response = agent.run(task=prompt, stream=False)
47
 
48
+ # TODO: add a smolagent output parser
49
 
50
  #parsed_steps, _ = parse_mcp_output(agent_response)
51
  #memory.update_from_parsed(parsed_steps, request)
streamlit_app.py CHANGED
@@ -26,7 +26,7 @@ def run_agent(message):
26
 
27
  # Streamlit UI
28
  st.title("PostgreSQL Query Agent")
29
- st.write("Ask your database in natural language and get results using the smolagent executor.")
30
 
31
  user_input = st.text_input("Natural Language Request", placeholder="e.g., Show me the table of join posts and users tables.")
32
 
 
26
 
27
  # Streamlit UI
28
  st.title("PostgreSQL Query Agent")
29
+ st.write("Ask your database in natural language and get results.")
30
 
31
  user_input = st.text_input("Natural Language Request", placeholder="e.g., Show me the table of join posts and users tables.")
32