ZennyKenny commited on
Commit
042246b
·
verified ·
1 Parent(s): 1f7ee11

change tool order

Browse files
Files changed (1) hide show
  1. app.py +24 -24
app.py CHANGED
@@ -7,6 +7,30 @@ import spaces
7
  # Import the persistent database
8
  from database import engine, receipts
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  @tool
11
  def query_sql(user_query: str) -> str:
12
  """
@@ -47,30 +71,6 @@ agent = CodeAgent(
47
  model=HfApiModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct"),
48
  )
49
 
50
- @tool
51
- def sql_engine(query: str) -> str:
52
- """
53
- Executes an SQL query on the 'receipts' table and returns formatted results.
54
-
55
- Args:
56
- query: The SQL query to execute.
57
-
58
- Returns:
59
- Query result as a formatted string.
60
- """
61
- try:
62
- with engine.connect() as con:
63
- rows = con.execute(text(query)).fetchall()
64
-
65
- if not rows:
66
- return "No results found."
67
-
68
- # Convert results into a readable string format
69
- return "\n".join([", ".join(map(str, row)) for row in rows])
70
-
71
- except Exception as e:
72
- return f"Error: {str(e)}"
73
-
74
  # Define Gradio interface
75
  demo = gr.Interface(
76
  fn=query_sql,
 
7
  # Import the persistent database
8
  from database import engine, receipts
9
 
10
+ @tool
11
+ def sql_engine(query: str) -> str:
12
+ """
13
+ Executes an SQL query on the 'receipts' table and returns formatted results.
14
+
15
+ Args:
16
+ query: The SQL query to execute.
17
+
18
+ Returns:
19
+ Query result as a formatted string.
20
+ """
21
+ try:
22
+ with engine.connect() as con:
23
+ rows = con.execute(text(query)).fetchall()
24
+
25
+ if not rows:
26
+ return "No results found."
27
+
28
+ # Convert results into a readable string format
29
+ return "\n".join([", ".join(map(str, row)) for row in rows])
30
+
31
+ except Exception as e:
32
+ return f"Error: {str(e)}"
33
+
34
  @tool
35
  def query_sql(user_query: str) -> str:
36
  """
 
71
  model=HfApiModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct"),
72
  )
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  # Define Gradio interface
75
  demo = gr.Interface(
76
  fn=query_sql,