Class: Richat::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/richat/config.rb

Constant Summary collapse

DEFAULT_CONFIG =
{
  "chatgpt" => {
    "api_key" => ENV["OPENAI_API_KEY"],
    "model" => "gpt-3.5-turbo",
    "temperature" => 0.7
  },
  "log" => {
    "enable" => true,
    "log_dir" => "~/.richat/logs",
    "log_file" => nil,
    "user_role" => "USR",
    "ai_role" => "GPT",
    "system_role" => "SYS"
  },
  "shell" => {
    "save_shell_history" => true,
    "enable_chat_context" => true,
    "show_welcome_info" => true,
    "shell_history_file" => "~/.richat/history.txt",
    "exit_keywords" => ["/exit", "q", "quit", "exit"],
    "chat_context_indicator" => "💡",
    "user_content_color" => "green"
  },
  "sys_cmd" => {
    "activate_keywords" => [">", "!"],
    "deactivate_keywords" => ["q", "quit", "exit"]
  },
  "prompt" => {
    "prompt_dir" => "~/.richat/prompts",
    "default" => ""
  }
}.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject (readonly)

Returns the value of attribute config.



39
40
41
# File 'lib/richat/config.rb', line 39

def config
  @config
end

Class Method Details

.get(*keys) ⇒ Object



45
46
47
# File 'lib/richat/config.rb', line 45

def get(*keys)
  get_config.dig(*keys)
end

.get_configObject



41
42
43
# File 'lib/richat/config.rb', line 41

def get_config
  (@config ||= merge_config)
end

.override_with(other_config) ⇒ Object



49
50
51
# File 'lib/richat/config.rb', line 49

def override_with(other_config)
  @config = Utils.deep_merge_hash(get_config, other_config)
end