Skip to content

Commit

Permalink
chore: update package versions
Browse files Browse the repository at this point in the history
  • Loading branch information
meysamhadeli committed Dec 15, 2024
1 parent 075ca58 commit 6eaaf67
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 95 deletions.
7 changes: 6 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ type RootDependencies struct {
var rootCmd = &cobra.Command{
Use: "codai",
Short: "codai CLI for coding and chatting",
Long: `codai is a CLI tool that assists developers by providing intelligent code suggestions, refactoring, and code reviews based on the full context of your project. It operates in a session-based manner, allowing for continuous context throughout interactions. Codai supports multiple LLMs, including GPT-3.5, GPT-4, and Ollama, to streamline daily development tasks.`,
Long: `Codai is an AI code assistant that helps developers through a session-based CLI, providing intelligent code suggestions, refactoring, and code reviews based on the full context of the project. It supports multiple LLM providers, such as OpenAI, Azure OpenAI, Ollama, Anthropic, and OpenRouter, to streamline daily development tasks.`,
Run: func(cmd *cobra.Command, args []string) {
versionFlag, _ := cmd.Flags().GetBool("version")
if versionFlag {
fmt.Printf("version: %s\n", config.DefaultConfig.Version)
return
}
// Check if any arguments or subcommands were provided
if len(args) == 0 {
err := cmd.Help() // Display help if no subcommand or argument is provided
Expand Down
68 changes: 33 additions & 35 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ type Config struct {
AIProviderConfig *providers.AIProviderConfig `mapstructure:"ai_provider_config"`
}

// Default configuration values
var defaultConfig = Config{
Version: "1.7.5",
// DefaultConfig values
var DefaultConfig = Config{
Version: "1.8.1",
Theme: "dracula",
RAG: true,
AIProviderConfig: &providers.AIProviderConfig{
Expand Down Expand Up @@ -48,23 +48,22 @@ func LoadConfigs(rootCmd *cobra.Command, cwd string) *Config {
var config *Config

// Set default values using Viper
viper.SetDefault("version", defaultConfig.Version)
viper.SetDefault("theme", defaultConfig.Theme)
viper.SetDefault("rag", defaultConfig.RAG)
viper.SetDefault("ai_provider_config.chat_provider_name", defaultConfig.AIProviderConfig.ChatProviderName)
viper.SetDefault("ai_provider_config.embeddings_provider_name", defaultConfig.AIProviderConfig.EmbeddingsProviderName)
viper.SetDefault("ai_provider_config.chat_base_url", defaultConfig.AIProviderConfig.ChatBaseURL)
viper.SetDefault("ai_provider_config.embeddings_base_url", defaultConfig.AIProviderConfig.EmbeddingsBaseURL)
viper.SetDefault("ai_provider_config.chat_model", defaultConfig.AIProviderConfig.ChatModel)
viper.SetDefault("ai_provider_config.embeddings_model", defaultConfig.AIProviderConfig.EmbeddingsModel)
viper.SetDefault("ai_provider_config.encoding_format", defaultConfig.AIProviderConfig.EncodingFormat)
viper.SetDefault("ai_provider_config.temperature", defaultConfig.AIProviderConfig.Temperature)
viper.SetDefault("ai_provider_config.threshold", defaultConfig.AIProviderConfig.Threshold)
viper.SetDefault("ai_provider_config.stream", defaultConfig.AIProviderConfig.Stream)
viper.SetDefault("ai_provider_config.chat_api_key", defaultConfig.AIProviderConfig.ChatApiKey)
viper.SetDefault("ai_provider_config.embeddings_api_key", defaultConfig.AIProviderConfig.EmbeddingsApiKey)
viper.SetDefault("ai_provider_config.chat_api_version", defaultConfig.AIProviderConfig.ChatApiVersion)
viper.SetDefault("ai_provider_config.embeddings_api_version", defaultConfig.AIProviderConfig.EmbeddingsApiVersion)
viper.SetDefault("theme", DefaultConfig.Theme)
viper.SetDefault("rag", DefaultConfig.RAG)
viper.SetDefault("ai_provider_config.chat_provider_name", DefaultConfig.AIProviderConfig.ChatProviderName)
viper.SetDefault("ai_provider_config.embeddings_provider_name", DefaultConfig.AIProviderConfig.EmbeddingsProviderName)
viper.SetDefault("ai_provider_config.chat_base_url", DefaultConfig.AIProviderConfig.ChatBaseURL)
viper.SetDefault("ai_provider_config.embeddings_base_url", DefaultConfig.AIProviderConfig.EmbeddingsBaseURL)
viper.SetDefault("ai_provider_config.chat_model", DefaultConfig.AIProviderConfig.ChatModel)
viper.SetDefault("ai_provider_config.embeddings_model", DefaultConfig.AIProviderConfig.EmbeddingsModel)
viper.SetDefault("ai_provider_config.encoding_format", DefaultConfig.AIProviderConfig.EncodingFormat)
viper.SetDefault("ai_provider_config.temperature", DefaultConfig.AIProviderConfig.Temperature)
viper.SetDefault("ai_provider_config.threshold", DefaultConfig.AIProviderConfig.Threshold)
viper.SetDefault("ai_provider_config.stream", DefaultConfig.AIProviderConfig.Stream)
viper.SetDefault("ai_provider_config.chat_api_key", DefaultConfig.AIProviderConfig.ChatApiKey)
viper.SetDefault("ai_provider_config.embeddings_api_key", DefaultConfig.AIProviderConfig.EmbeddingsApiKey)
viper.SetDefault("ai_provider_config.chat_api_version", DefaultConfig.AIProviderConfig.ChatApiVersion)
viper.SetDefault("ai_provider_config.embeddings_api_version", DefaultConfig.AIProviderConfig.EmbeddingsApiVersion)

// Automatically read environment variables
viper.AutomaticEnv() // This will look for variables that match config keys directly
Expand Down Expand Up @@ -147,19 +146,18 @@ func bindFlags(rootCmd *cobra.Command) {
func InitFlags(rootCmd *cobra.Command) {
// Use PersistentFlags so that these flags are available in all subcommands
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "Specifies the path to a configuration file that contains all the settings for the application. This file can be used to override defaults.")
rootCmd.PersistentFlags().String("theme", defaultConfig.Theme, "Set customize theme for buffering response from ai. (e.g., 'dracula', 'light', 'dark')")
rootCmd.PersistentFlags().Bool("rag", defaultConfig.RAG, "Enable Retrieval-Augmented Generation (RAG) for enhanced responses using relevant data retrieval (e.g., default is 'enabled' and just retrieve related context base on user request).")
rootCmd.PersistentFlags().StringP("version", "v", defaultConfig.Version, "Specifies the version of the application or service. This helps to track the release or update of the software.")
rootCmd.PersistentFlags().String("chat_provider_name", defaultConfig.AIProviderConfig.ChatProviderName, "Specifies the name of the chat AI service provider (e.g., 'openai' or 'ollama'). This determines which service or API will be used for AI-related functions.")
rootCmd.PersistentFlags().String("embeddings_provider_name", defaultConfig.AIProviderConfig.EmbeddingsProviderName, "Specifies the name of the embeddings AI service provider (e.g., 'openai' or 'ollama'). This determines which service or API will be used for AI-related functions.")
rootCmd.PersistentFlags().String("chat_base_url", defaultConfig.AIProviderConfig.ChatBaseURL, "The chat base URL of AI Provider (e.g., default is 'https://api.openai.com'.")
rootCmd.PersistentFlags().String("embeddings_base_url", defaultConfig.AIProviderConfig.EmbeddingsBaseURL, "The embeddings base URL of AI Provider (e.g., default is 'https://api.openai.com'.")
rootCmd.PersistentFlags().String("chat_model", defaultConfig.AIProviderConfig.ChatModel, "The name of the model used for chat completions, such as 'gpt-4o'. Different models offer varying levels of performance and capabilities.")
rootCmd.PersistentFlags().String("embeddings_model", defaultConfig.AIProviderConfig.EmbeddingsModel, "Specifies the AI model used for generating text embeddings (e.g., 'text-embedding-ada-002'). This model converts text into vector representations for similarity comparisons.")
rootCmd.PersistentFlags().Float32("temperature", defaultConfig.AIProviderConfig.Temperature, "Adjusts the AI model’s creativity by setting a temperature value. Higher values result in more creative or varied responses, while lower values make them more focused (e.g., value should be between '0 - 1' and default is '0.2').")
rootCmd.PersistentFlags().Float64("threshold", defaultConfig.AIProviderConfig.Threshold, "Sets the threshold for similarity calculations in AI systems. Higher values will require closer matches and should be careful not to lose matches, while lower values provide a wider range of results to prevent losing any matches. (e.g., value should be between '0.2 - 1' and default is '0.3').")
rootCmd.PersistentFlags().String("chat_api_key", defaultConfig.AIProviderConfig.ChatApiKey, "The chat API key used to authenticate with the AI service provider.")
rootCmd.PersistentFlags().String("embeddings_api_key", defaultConfig.AIProviderConfig.EmbeddingsApiKey, "The embeddings API key used to authenticate with the AI service provider.")
rootCmd.PersistentFlags().String("chat_api_version", defaultConfig.AIProviderConfig.ChatApiVersion, "The API version used to authenticate with the chat AI service provider.")
rootCmd.PersistentFlags().String("embeddings_api_version", defaultConfig.AIProviderConfig.EmbeddingsApiVersion, "The API version used to authenticate with the embeddings AI service provider.")
rootCmd.PersistentFlags().String("theme", DefaultConfig.Theme, "Set customize theme for buffering response from ai. (e.g., 'dracula', 'light', 'dark')")
rootCmd.PersistentFlags().Bool("rag", DefaultConfig.RAG, "Enable Retrieval-Augmented Generation (RAG) for enhanced responses using relevant data retrieval (e.g., default is 'enabled' and just retrieve related context base on user request).")
rootCmd.Flags().BoolP("version", "v", false, "Specifies the version of the application.")
rootCmd.PersistentFlags().String("embeddings_provider_name", DefaultConfig.AIProviderConfig.EmbeddingsProviderName, "Specifies the name of the embeddings AI service provider (e.g., 'openai' or 'ollama'). This determines which service or API will be used for AI-related functions.")
rootCmd.PersistentFlags().String("chat_base_url", DefaultConfig.AIProviderConfig.ChatBaseURL, "The chat base URL of AI Provider (e.g., default is 'https://api.openai.com'.")
rootCmd.PersistentFlags().String("embeddings_base_url", DefaultConfig.AIProviderConfig.EmbeddingsBaseURL, "The embeddings base URL of AI Provider (e.g., default is 'https://api.openai.com'.")
rootCmd.PersistentFlags().String("chat_model", DefaultConfig.AIProviderConfig.ChatModel, "The name of the model used for chat completions, such as 'gpt-4o'. Different models offer varying levels of performance and capabilities.")
rootCmd.PersistentFlags().String("embeddings_model", DefaultConfig.AIProviderConfig.EmbeddingsModel, "Specifies the AI model used for generating text embeddings (e.g., 'text-embedding-ada-002'). This model converts text into vector representations for similarity comparisons.")
rootCmd.PersistentFlags().Float32("temperature", DefaultConfig.AIProviderConfig.Temperature, "Adjusts the AI model’s creativity by setting a temperature value. Higher values result in more creative or varied responses, while lower values make them more focused (e.g., value should be between '0 - 1' and default is '0.2').")
rootCmd.PersistentFlags().Float64("threshold", DefaultConfig.AIProviderConfig.Threshold, "Sets the threshold for similarity calculations in AI systems. Higher values will require closer matches and should be careful not to lose matches, while lower values provide a wider range of results to prevent losing any matches. (e.g., value should be between '0.2 - 1' and default is '0.3').")
rootCmd.PersistentFlags().String("chat_api_key", DefaultConfig.AIProviderConfig.ChatApiKey, "The chat API key used to authenticate with the AI service provider.")
rootCmd.PersistentFlags().String("embeddings_api_key", DefaultConfig.AIProviderConfig.EmbeddingsApiKey, "The embeddings API key used to authenticate with the AI service provider.")
rootCmd.PersistentFlags().String("chat_api_version", DefaultConfig.AIProviderConfig.ChatApiVersion, "The API version used to authenticate with the chat AI service provider.")
rootCmd.PersistentFlags().String("embeddings_api_version", DefaultConfig.AIProviderConfig.EmbeddingsApiVersion, "The API version used to authenticate with the embeddings AI service provider.")
}
36 changes: 17 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module github.com/meysamhadeli/codai

go 1.23.2
go 1.23.4

require (
github.com/alecthomas/chroma/v2 v2.14.0
github.com/charmbracelet/lipgloss v1.0.0
github.com/pkoukk/tiktoken-go v0.1.7
github.com/pterm/pterm v0.12.79
github.com/pterm/pterm v0.12.80
github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
Expand All @@ -18,41 +18,39 @@ require (
atomicgo.dev/keyboard v0.2.9 // indirect
atomicgo.dev/schedule v0.1.0 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/x/ansi v0.4.5 // indirect
github.com/containerd/console v1.0.3 // indirect
github.com/charmbracelet/x/ansi v0.6.0 // indirect
github.com/containerd/console v1.0.4 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dlclark/regexp2 v1.11.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/dlclark/regexp2 v1.11.4 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gookit/color v1.5.4 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/lithammer/fuzzysearch v1.1.8 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/magiconair/properties v1.8.9 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sergi/go-diff v1.3.1 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.19.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20241215155358-4a5509556b9e // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit 6eaaf67

Please sign in to comment.