forked from gptscript-ai/structured-data-querier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtool.gpt
83 lines (63 loc) · 3.97 KB
/
tool.gpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
tools: load-data, read-query, write-query
export: export-result
description: build a duckdb query against structured data. Also support exporting data from the duckdb database into a structured file format such as csv, json, or xlsx. This tool cannot be ran in parallel with itself. Only provide the file argument when attempting to load new data into duckdb.
args: file: (Optional) The complete path to the structured file to query
args: prompt: The natural language prompt that will be transformed into a duckdb query. This prompt should not be written in sql.
context: github.com/drpebcak/structured-data-querier/query-context.txt
context: github.com/drpebcak/structured-data-querier/naming-conventions.txt
If a file is provided, load it into a duckdb database using the `load-data` tool before attempting to do any queries.
When no file is provided, assume the user is trying to query a pre-existing duckdb database.
---
name: load-data
description: takes a file and uses context tool to load it into a duckdb database. returns the path to the database file as well as the table name and schema information
args: file: The filename of the structured file to load into duckdb
context: context with $file
Return the created database filename, table name, and schema information.
---
name: read-query
description: Executes a read-only query against a duckdb database
args: query: The duckdb query to be executed
args: dbFile: The filename of the existing duckdb database. This must have a .duckdb extension
args: readonly: Should always be 'true'
#!/usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/query.py
---
name: write-query
description: Executes a query that writes to a duckdb database. This tool should be used whenever the database is going to be changed.
args: query: The duckdb query to be executed
args: dbFile: The filename of the existing duckdb database. This must have a .duckdb extension
#!/usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/query.py
---
name: context
description: read the schema of a structured file and load it into a duckdb database
context: github.com/drpebcak/structured-data-querier/naming-conventions.txt
tools: create-database-file, read-schema
args: file: the filename of the structured file to read
Do these steps one at a time, do not move on until the previous step is complete. Do not exit until all steps are finished.
Create a database file for the structured file based of the name of the file being read.
Next, load the schema of the structured file into the database.
Return the name of the database file, table, and the schema created.
---
name: read-schema
description: read the schema of a structured file (json, csv, or xlsx) and load it into a duckdb database
args: file: the filename of the structured file to read
args: dbFile: The filename of the existing duckdb database
#!/usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/read_schema.py
---
name: create-database-file
description: creates a new duckdb database file if one does not exist
args: dbFile: The filename of the duckdb database to create
#!/usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/create_database_file.py
---
name: export-result
tools: read-query, pwd
context: github.com/drpebcak/structured-data-querier/export-context.txt
context: github.com/drpebcak/structured-data-querier/naming-conventions.txt
description: creates duckdb queries that writes the contents of a database to a structured file
args: prompt: The natural language prompt that will be transformed into a duckdb query to write a file. This prompt should not be written in sql.
args: dbFile: The filename of the existing duckdb database
args: file: The name of the structured file to write the results to
Write a duckdb query based on the prompt provided that will dump the contents of the database to a structured file in the specified format. The files it writes should always be written to the user's current working directory.
---
name: pwd
description: returns the absolute path for the user's current working directory
#!/usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/pwd.py