Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/dna assistant #3192

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

114 changes: 114 additions & 0 deletions cmd/assistant.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
}
Loading
Loading