-
Notifications
You must be signed in to change notification settings - Fork 243
/
Copy pathassistant.go
114 lines (101 loc) · 2.68 KB
/
assistant.go
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package cmd
import (
"github.com/joho/godotenv"
"github.com/sashabaranov/go-openai"
"github.com/spf13/cobra"
"github.com/tmc/langchaingo/jsonschema"
)
var assistantCmd = &cobra.Command{
Use: "assistant",
Short: "DNA CLI assistant for database design and normalization",
Long: `Database Normalization Assistant (DNA) helps with database design and normalization.
It provides interactive guidance for schema design, normalization, and best practices.`,
}
func init() {
// Load .env file if it exists
godotenv.Load()
rootCmd.AddCommand(assistantCmd)
// Add subcommands
assistantCmd.AddCommand(newAssistantChatCmd())
assistantCmd.AddCommand(newAssistantDoctorCmd())
assistantCmd.AddCommand(newAssistantSchemaCmd())
}
// Environment variables
const (
EnvDNAProvider = "DNA_PROVIDER"
EnvDNAAPIKey = "DNA_API_KEY"
EnvDNAModel = "DNA_MODEL"
EnvDNATemperature = "DNA_TEMPERATURE"
// Add Postgres connection constants
EnvPGHost = "PGHOST"
EnvPGPort = "PGPORT"
EnvPGDatabase = "PGDATABASE"
EnvPGUser = "PGUSER"
EnvPGPassword = "PGPASSWORD"
)
// Default values
var defaultConfig = struct {
Provider string
Model string
Temperature float32
}{
Provider: "openai",
Model: "gpt-4",
Temperature: 0.7,
}
var functions = []openai.FunctionDefinition{
{
Name: "search_supabase_docs",
Description: "Search Supabase documentation",
Parameters: jsonschema.Definition{
Type: jsonschema.Object,
Properties: map[string]jsonschema.Definition{
"query": {
Type: jsonschema.String,
Description: "The search query",
},
"topic": {
Type: jsonschema.String,
Description: "Optional topic to filter results",
},
},
},
},
{
Name: "analyze_schema",
// ... existing schema analysis function
},
{
Name: "get_cli_help",
Description: "Get help information for DNA CLI commands",
Parameters: jsonschema.Definition{
Type: jsonschema.Object,
Properties: map[string]jsonschema.Definition{
"command": {
Type: jsonschema.String,
Description: "The command to get help for (e.g., 'db', 'assistant'). Empty for root help.",
},
},
},
},
}
func newAssistantSchemaCmd() *cobra.Command {
return &cobra.Command{
Use: "schema",
Short: "Get schema information about your database",
RunE: func(cmd *cobra.Command, args []string) error {
return nil // TODO: Implement schema command
},
}
}
func newAssistantCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "assistant",
Short: "DNA CLI assistant for database design and normalization",
}
cmd.AddCommand(
newAssistantChatCmd(),
// Migration commands removed - these belong in main CLI
)
return cmd
}