|
import sqlite3
|
|
|
|
def tools_call(session_hash):
|
|
connection = sqlite3.connect(f'data_source_{session_hash}.db')
|
|
print("Querying Database in Tools.py");
|
|
cur=connection.execute('select * from data_source')
|
|
columns = [i[0] for i in cur.description]
|
|
print("COLUMNS 2")
|
|
print(columns)
|
|
cur.close()
|
|
connection.close()
|
|
|
|
return [
|
|
{
|
|
"type": "function",
|
|
"function": {
|
|
"name": "sql_query_func",
|
|
"description": f"This a tool useful to query a SQLite table called 'data_source' with the following Columns: {columns}",
|
|
"parameters": {
|
|
"type": "object",
|
|
"properties": {
|
|
"queries": {
|
|
"type": "array",
|
|
"description": "The query to use in the search. Infer this from the user's message. It should be a question or a statement",
|
|
"items": {
|
|
"type": "string",
|
|
}
|
|
}
|
|
},
|
|
"required": ["question"],
|
|
},
|
|
},
|
|
},
|
|
{
|
|
"type": "function",
|
|
"function": {
|
|
"name": "rag_pipeline_func",
|
|
"description": f"This a tool useful to query a SQLite table called 'data_source' with the following Columns: {columns}",
|
|
"parameters": {
|
|
"type": "object",
|
|
"properties": {
|
|
"queries": {
|
|
"type": "array",
|
|
"description": "The query to use in the search. Infer this from the user's message. It should be a question or a statement",
|
|
"items": {
|
|
"type": "string",
|
|
}
|
|
}
|
|
},
|
|
"required": ["question"],
|
|
},
|
|
},
|
|
},
|
|
{
|
|
"type": "function",
|
|
"function": {
|
|
"name": "chart_generation_func",
|
|
"description": f"This an chart generation tool useful to generate charts and graphs from queried data from our SQL table called 'data_source with the following Columns: {columns}. Returns an iframe string.",
|
|
"parameters": {
|
|
"type": "object",
|
|
"properties": {
|
|
"queries": {
|
|
"type": "array",
|
|
"description": """The data points to use in the chart generation. Infer this from the user's message.
|
|
Send a chart.js dictionary with options that correspond to the users request. But also format this dictionary as a string as this will allow javascript to be interpreted by the API we are using.
|
|
Return nothing else.""",
|
|
"items": {
|
|
"type": "string",
|
|
}
|
|
}
|
|
},
|
|
"required": ["question"],
|
|
},
|
|
},
|
|
}
|
|
] |