themissingCRAM
commited on
Commit
·
6193310
1
Parent(s):
355085b
blocks experiment
Browse files
app.py
CHANGED
@@ -21,7 +21,8 @@ from dotenv import load_dotenv
|
|
21 |
|
22 |
load_dotenv()
|
23 |
|
24 |
-
# What is the average each customer paid?
|
|
|
25 |
|
26 |
|
27 |
@spaces.GPU
|
@@ -30,7 +31,7 @@ def dummy():
|
|
30 |
|
31 |
|
32 |
@tool
|
33 |
-
def sql_engine_tool(query: str) -> str:
|
34 |
"""
|
35 |
Allows you to perform SQL queries on the table. Returns a string representation of the result.
|
36 |
The table is named 'receipts'. Its description is as follows:
|
@@ -42,7 +43,7 @@ def sql_engine_tool(query: str) -> str:
|
|
42 |
|
43 |
Args:
|
44 |
query: The query to perform. This should be correct SQL.
|
45 |
-
|
46 |
"""
|
47 |
output = ""
|
48 |
print("debug sql_engine_tool")
|
@@ -119,9 +120,6 @@ if __name__ == "__main__":
|
|
119 |
|
120 |
agent = CodeAgent(
|
121 |
tools=[sql_engine_tool],
|
122 |
-
# system_prompt="""
|
123 |
-
# You are a text to sql converter
|
124 |
-
# """,
|
125 |
model=model,
|
126 |
max_steps=1,
|
127 |
verbosity_level=1,
|
@@ -129,20 +127,20 @@ if __name__ == "__main__":
|
|
129 |
# agent.run("What is the average each customer paid?")
|
130 |
# GradioUI(agent).launch()
|
131 |
|
132 |
-
def enter_message(message, chat_history):
|
133 |
print()
|
134 |
print("enter_message debug")
|
135 |
print(message)
|
136 |
print(chat_history)
|
137 |
chat_history.append({"role": "user", "content": message})
|
138 |
-
x = agent.run(message)
|
139 |
print(type(x))
|
140 |
-
print(x)
|
141 |
return "", x
|
142 |
|
143 |
with gr.Blocks() as b:
|
144 |
chatbot = gr.Chatbot(type="messages")
|
145 |
input = gr.Textbox()
|
146 |
button = gr.Button("reply")
|
147 |
-
button.click(enter_message, [input, chatbot], [input, chatbot])
|
148 |
b.launch()
|
|
|
21 |
|
22 |
load_dotenv()
|
23 |
|
24 |
+
# What is the average each customer paid?
|
25 |
+
# Create a sql statement and invoke your sql_engine tool
|
26 |
|
27 |
|
28 |
@spaces.GPU
|
|
|
31 |
|
32 |
|
33 |
@tool
|
34 |
+
def sql_engine_tool(query: str, engine: any) -> str:
|
35 |
"""
|
36 |
Allows you to perform SQL queries on the table. Returns a string representation of the result.
|
37 |
The table is named 'receipts'. Its description is as follows:
|
|
|
43 |
|
44 |
Args:
|
45 |
query: The query to perform. This should be correct SQL.
|
46 |
+
engine: Use the given engine in the additional_args
|
47 |
"""
|
48 |
output = ""
|
49 |
print("debug sql_engine_tool")
|
|
|
120 |
|
121 |
agent = CodeAgent(
|
122 |
tools=[sql_engine_tool],
|
|
|
|
|
|
|
123 |
model=model,
|
124 |
max_steps=1,
|
125 |
verbosity_level=1,
|
|
|
127 |
# agent.run("What is the average each customer paid?")
|
128 |
# GradioUI(agent).launch()
|
129 |
|
130 |
+
def enter_message(message, chat_history, engine):
|
131 |
print()
|
132 |
print("enter_message debug")
|
133 |
print(message)
|
134 |
print(chat_history)
|
135 |
chat_history.append({"role": "user", "content": message})
|
136 |
+
x = agent.run(message, additional_args=dict(engine=engine))
|
137 |
print(type(x))
|
138 |
+
print("\n\n\n", x, "\n\n\n")
|
139 |
return "", x
|
140 |
|
141 |
with gr.Blocks() as b:
|
142 |
chatbot = gr.Chatbot(type="messages")
|
143 |
input = gr.Textbox()
|
144 |
button = gr.Button("reply")
|
145 |
+
button.click(enter_message, [input, chatbot, engine], [input, chatbot, engine])
|
146 |
b.launch()
|