dvwn commited on
Commit
f160d1e
·
1 Parent(s): 91c6f8c

Update interactive mode testing module

Browse files

1. Show results/data return by agent in a tabular format and summarized sentences of the answer
2. Using tabulate lib package

requirements.txt CHANGED
Binary files a/requirements.txt and b/requirements.txt differ
 
src/database/__pycache__/db_manager.cpython-313.pyc CHANGED
Binary files a/src/database/__pycache__/db_manager.cpython-313.pyc and b/src/database/__pycache__/db_manager.cpython-313.pyc differ
 
src/nl2sql/__pycache__/hf_engine.cpython-313.pyc CHANGED
Binary files a/src/nl2sql/__pycache__/hf_engine.cpython-313.pyc and b/src/nl2sql/__pycache__/hf_engine.cpython-313.pyc differ
 
src/nl2sql/sql_agent.py CHANGED
@@ -47,6 +47,7 @@ The database returned the following results: {results}
47
 
48
  Provide a direct, natural language answer to the user's question using ONLY the provided data.
49
  Keep it brief. Do not explain the SQL query or mention the database schema.
 
50
 
51
  Answer:"""
52
 
 
47
 
48
  Provide a direct, natural language answer to the user's question using ONLY the provided data.
49
  Keep it brief. Do not explain the SQL query or mention the database schema.
50
+ If the database returns more than 5 rows, DO NOT list the items individually. Instead, provide a brief summary sentence.
51
 
52
  Answer:"""
53
 
src/scripts/interactive_mode.py CHANGED
@@ -1,5 +1,6 @@
1
  # Path: src/scripts/interactive_mode.py
2
  # Interactive mode: Allows user to manually type questions and see the agent's response
 
3
  from src.nl2sql.sql_agent import nl2sql_agent
4
 
5
  def run_interactiveMode():
@@ -20,6 +21,20 @@ def run_interactiveMode():
20
  print("\n========= Agent Response =========")
21
  if response.get('status') == 'success':
22
  print(f"Answer: {response.get('nl_response')}\n")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  print(f"Generated SQL:\n{response.get('query')}\n")
24
  else:
25
  print(f"Status: {response.get('status')}")
 
1
  # Path: src/scripts/interactive_mode.py
2
  # Interactive mode: Allows user to manually type questions and see the agent's response
3
+ from tabulate import tabulate
4
  from src.nl2sql.sql_agent import nl2sql_agent
5
 
6
  def run_interactiveMode():
 
21
  print("\n========= Agent Response =========")
22
  if response.get('status') == 'success':
23
  print(f"Answer: {response.get('nl_response')}\n")
24
+
25
+ raw_data = response.get('results')
26
+ if raw_data:
27
+ display_data = raw_data
28
+ #display_data = raw_data[:20]
29
+ # Format data returned as a grid table
30
+ table = tabulate(display_data, tablefmt="grid")
31
+
32
+ print("Data Table:")
33
+ print(table)
34
+ print()
35
+ else:
36
+ print("No data returned from the database.")
37
+
38
  print(f"Generated SQL:\n{response.get('query')}\n")
39
  else:
40
  print(f"Status: {response.get('status')}")