-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* setup sql agent graph * Refactor the sub-graph prompt injection * Move prompts over to examples * Update graph for sql agent
- Loading branch information
1 parent
487e16c
commit f908bc8
Showing
28 changed files
with
422 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
- When defining tools in prompt metadata, users can _interpolate_ tool parameters into the `commands` section of a container definition. For example, in the following definition of a sqlite tool, the `database` and `sql` parameters from the tool definition will be used to create the container. | ||
``` | ||
- name: sqlite | ||
description: run the sqlite command | ||
parameters: | ||
type: object | ||
properties: | ||
database: | ||
type: string | ||
description: the path to the database | ||
sql: | ||
type: string | ||
description: the sql statement to run | ||
container: | ||
image: vonwig/sqlite:latest | ||
command: | ||
- "{{database}}" | ||
- "{{sql|safe}}" | ||
``` | ||
- You can also splice array parameters into the command definition using the `into` filter keyword: | ||
``` | ||
- name: docker | ||
description: run any docker command with arguments | ||
parameters: | ||
type: object | ||
properties: | ||
args: | ||
type: array | ||
items: | ||
type: string | ||
description: arguments to pass to the docker CLI | ||
container: | ||
image: docker:cli | ||
command: | ||
- "{{args|into}}" | ||
``` | ||
In this example, the array of strings passed to the `args` parameter of the function will be spliced into the `command` parameter of the container definition. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
agent: sql | ||
--- | ||
|
||
# prompt user | ||
|
||
find all artists in database ./Chinook.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
tools: | ||
- name: sqlite3 | ||
description: execute the DB query | ||
parameters: | ||
type: object | ||
properties: | ||
sql: | ||
type: string | ||
description: the sql statement to run | ||
container: | ||
image: vonwig/sqlite:latest | ||
command: | ||
- "./Chinook.db" | ||
- "{{sql}}" | ||
--- | ||
|
||
# prompt system | ||
|
||
You are a SQL expert with a strong attention to detail. | ||
Double check the SQLite query for common mistakes, including: | ||
- Using NOT IN with NULL values | ||
- Using UNION when UNION ALL should have been used | ||
- Using BETWEEN for exclusive ranges | ||
- Data type mismatch in predicates | ||
- Properly quoting identifiers | ||
- Using the correct number of arguments for functions | ||
- Casting to the correct data type | ||
- Using the proper columns for joins | ||
|
||
If there are any of the above mistakes, rewrite the query. If there are no mistakes, just reproduce the original query. | ||
|
||
You will call the appropriate tool to execute the query after running this check. | ||
|
||
# prompt user | ||
|
||
SELECT * FROM Artist LIMIT 10; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
--- | ||
|
||
# prompt system | ||
|
||
You are a SQL expert with a strong attention to detail. | ||
|
||
Given an input question, output a syntactically correct SQLite query to run, then look at the results of the query and return the answer. | ||
|
||
DO NOT call any tool besides SubmitFinalAnswer to submit the final answer. | ||
|
||
When generating the query: | ||
|
||
Output the SQL query that answers the input question without a tool call. | ||
|
||
Unless the user specifies a specific number of examples they wish to obtain, always limit your query to at most 5 results. | ||
You can order the results by a relevant column to return the most interesting examples in the database. | ||
Never query for all the columns from a specific table, only ask for the relevant columns given the question. | ||
|
||
If you get an error while executing a query, rewrite the query and try again. | ||
|
||
If you get an empty result set, you should try to rewrite the query to get a non-empty result set. | ||
NEVER make stuff up if you don't have enough information to answer the query... just say you don't have enough information. | ||
|
||
If you have enough information to answer the input question, simply invoke the appropriate tool to submit the final answer to the user. | ||
|
||
DO NOT make any DML statements (INSERT, UPDATE, DELETE, DROP etc.) to the database. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
# SQLite | ||
|
||
## sqlite list tables | ||
|
||
With sqlite, how do I figure out what tables are present? | ||
How do I run sqlite with a file and a sql command? | ||
|
||
``` | ||
docker run --rm -v $PWD:/workdir --workdir /workdir vonwig/sqlite:latest ./Chinook.db ".tables" | ||
``` | ||
|
||
``` | ||
Album Employee InvoiceLine PlaylistTrack | ||
Artist Genre MediaType Track | ||
Customer Invoice Playlist | ||
[Process exited 0] | ||
``` | ||
|
||
## sqlite get db schema for table | ||
|
||
How do I get the schema for a table in sqlite? | ||
|
||
``` | ||
docker run --rm -v $PWD:/workdir --workdir /workdir vonwig/sqlite:latest ./Chinook.db ".schema Album" | ||
``` | ||
|
||
``` | ||
CREATE TABLE [Album] | ||
( | ||
[AlbumId] INTEGER NOT NULL, | ||
[Title] NVARCHAR(160) NOT NULL, | ||
[ArtistId] INTEGER NOT NULL, | ||
CONSTRAINT [PK_Album] PRIMARY KEY ([AlbumId]), | ||
FOREIGN KEY ([ArtistId]) REFERENCES [Artist] ([ArtistId]) | ||
ON DELETE NO ACTION ON UPDATE NO ACTION | ||
); | ||
CREATE INDEX [IFK_AlbumArtistId] ON [Album] ([ArtistId]); | ||
``` | ||
|
||
## sqlite execute query | ||
|
||
``` | ||
docker run --rm -v $PWD:/workdir --workdir /workdir vonwig/sqlite:latest ./Chinook.db "SELECT * FROM Album LIMIT 5" | ||
``` | ||
|
||
|
Oops, something went wrong.