diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 28ffb89..987fb72 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,27 +4,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
@@ -83,23 +64,23 @@
- {
+ "keyToString": {
+ "ASKED_ADD_EXTERNAL_FILES": "true",
+ "RunOnceActivity.OpenProjectViewOnStart": "true",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "WebServerToolWindowFactoryState": "false",
+ "git-widget-placeholder": "gptsql",
+ "last_opened_file_path": "/home/overlordx/PycharmProjects/imagine",
+ "node.js.detected.package.eslint": "true",
+ "node.js.detected.package.tslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "node.js.selected.package.tslint": "(autodetect)",
+ "nodejs_package_manager_path": "npm",
+ "settings.editor.selected.configurable": "PyConsoleConfigurable.Python Console",
+ "vue.rearranger.settings.migration": "true"
}
-}]]>
+}
@@ -439,7 +432,14 @@
1684978897714
-
+
+ 1685027496027
+
+
+
+ 1685027496027
+
+
@@ -479,21 +479,12 @@
-
+
+
-
- file://$PROJECT_DIR$/python/dataspoon/onehotdb.py
- 446
-
-
-
- file://$PROJECT_DIR$/python/dataspoon/onehotdb.py
- 640
-
-
file://$PROJECT_DIR$/python/gptsql/file_system_tools.py
24
@@ -533,15 +524,15 @@
-
-
-
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/data/mysql.pkl b/data/mysql.pkl
index 015e230..bd331d9 100644
Binary files a/data/mysql.pkl and b/data/mysql.pkl differ
diff --git a/default.ini b/default.ini
index 0e34620..b79c7b0 100644
--- a/default.ini
+++ b/default.ini
@@ -3,7 +3,7 @@ ini_file_path = default.ini
user = bilbo
passwd = baggins
port = 3306
-host = localhost
+host = 192.168.1.64
database_name = dbtool_db
table_name = dbtool_table
onehotdb_name = onehotwords
diff --git a/python/dataspoon/dbtool.py b/python/dataspoon/dbtool.py
index 7552cc9..210c738 100644
--- a/python/dataspoon/dbtool.py
+++ b/python/dataspoon/dbtool.py
@@ -55,7 +55,7 @@ def __init__(self, _database_name=None, _table_name=None, _config_key=None):
"""
self.base_dir = ROOT_DIR.rsplit('/', 0)[0] + '/'
try:
- open('default.ini', 'r+')
+ open('../../default.ini', 'r+')
except FileNotFoundError:
config_tool = ConfigTool('default')
config_tool.write_default_configs()
@@ -600,7 +600,8 @@ def test_static_operation():
def test_put():
- dbtool = DBTool('dbtool_test_db', 'dbtool_test_table')
+ dbtool = DBTool()
+ # dbtool = DBTool('dbtool_test_db', 'dbtool_test_table')
row_1 = dbtool.put('link_key_1')
row_1 = dbtool.put('link_key_1', 'first_key', 'link_key_1_first_value')
row_1 = dbtool.put('link_key_1', 'second_key', 'link_key_1_second_value')
@@ -633,20 +634,20 @@ def test_get():
if __name__ == '__main__':
test_put()
- test_get()
- test_onehotwords()
- test_static_operation()
- test_get_html_unescape()
- test_init()
- test_get_row_number()
- test_get_row_count()
- create_simple_pkl()
- test_add_data_frame()
- test_get_clean_key()
- github_demo_1()
- test_to_pickle()
- test_delete_database()
- test_delete_table()
+ # test_get()
+ # test_onehotwords()
+ # test_static_operation()
+ # test_get_html_unescape()
+ # test_init()
+ # test_get_row_number()
+ # test_get_row_count()
+ # create_simple_pkl()
+ # test_add_data_frame()
+ # test_get_clean_key()
+ # github_demo_1()
+ # test_to_pickle()
+ # test_delete_database()
+ # test_delete_table()
# the following line is not reached because of sys.exit() in python()
print("dbtool done!")
diff --git a/python/gptsql/gpttool_app.py b/python/gptsql/gpttool_app.py
index 69dcaf0..6278132 100644
--- a/python/gptsql/gpttool_app.py
+++ b/python/gptsql/gpttool_app.py
@@ -1,4 +1,8 @@
import gradio as gr
+from langchain import SQLDatabase, OpenAI
+from langchain.agents import create_sql_agent
+from langchain.agents.agent_toolkits import SQLDatabaseToolkit
+from langchain.callbacks.tracers import schemas
from langchain.tools import Tool
from langchain.utilities import PythonREPL
@@ -10,10 +14,28 @@ def put_data(database_name, table_name, unique_id, key, value):
gpt_tool.put(unique_id, key, value)
return "Data inserted successfully!"
-def get_data(database_name, table_name, unique_id, key):
- gpt_tool = GptTool(database_name, table_name)
- value = gpt_tool.get(unique_id, key)
- return value
+
+def get_data(_database_name, _table_name, _unique_id, _key):
+ # Create a SQLDatabase instance
+ database_uri = "mysql+mysqlconnector://bilbo:baggins@localhost:3306/"+database_name
+ db = SQLDatabase.from_uri(database_uri)
+
+ # Create the OpenAI language model instance
+ llm = OpenAI(temperature=0)
+
+ # Create a SQLDatabaseToolkit instance with the llm argument
+ toolkit = SQLDatabaseToolkit(db=db, llm=llm)
+
+ # Create the SQL agent
+ agent_executor = create_sql_agent(
+ llm=llm,
+ toolkit=toolkit,
+ verbose=True
+ )
+
+ result = agent_executor.run("return the value using the key equal " + _key + "from table " + _table_name + " for the record that has link_key equal " + unique_id)
+ return result
+
def chat_bot(message):
# Your chatbot logic here
@@ -69,7 +91,7 @@ def test_button(message):
with gr.Row():
get_output = gr.outputs.Textbox(label="Output")
with gr.Row():
- btn = gr.Button("Get Data").style(full_width=True)
+ btn = gr.Button("Get Value (Warning This Uses OpenAI API credits)").style(full_width=True)
btn.click(get_data, inputs=[database_name, table_name, unique_id, key], outputs=[get_output])
demo.launch()