-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.go
More file actions
38 lines (31 loc) · 1.09 KB
/
main.go
File metadata and controls
38 lines (31 loc) · 1.09 KB
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
package main
import (
"context"
"dagger/database-agent/internal/dagger"
)
type DatabaseAgent struct{}
// Ask the database agent a question and get a response
func (m *DatabaseAgent) Ask(
ctx context.Context,
// The database connection URL to use
dbURL *dagger.Secret,
// The question to ask the database agent
// +optional
question string,
) (string, error) {
// create the sql module that we will use to inspect the database
sql := dag.SQL(dbURL)
// create an environment for the agent to use
env := dag.Env().
WithStringInput("question", question, "The question about the database being asked").
WithSQLInput("sql", sql, "The SQL module to use to inspect the database")
// create the agent and run it
return dag.LLM().
WithEnv(env).
WithPrompt(`You are an expert database administrator. You have been given
a SQL module that already has tools with credentials and the ability to connect to the database to run SQL queries.
Always show the SQL query you used to get the result.
The question is: $question
DO NOT STOP UNTIL YOU HAVE ANSWERED THE QUESTION COMPLETELY.`).
LastReply(ctx)
}