class ChatGPT::MagicCommandRunner

Defined in:

chatgpt/magic_command_runner.cr

Constant Summary

Table = [{"name" => "debug", "description" => "Toggle debug mode", "pattern" => "debug", "n_args" => 0, "method" => "debug_mode_toggle"}, {"name" => "model", "description" => "Show model name", "pattern" => "model", "n_args" => 0, "method" => "show_model_name"}, {"name" => "model <model_name>", "description" => "Set model name", "pattern" => /^model\s+(.+)/, "n_args" => 1, "method" => "set_model_name"}, {"name" => "system", "description" => "Show system messages", "pattern" => "system", "n_args" => 0, "method" => "show_system_messages"}, {"name" => "system <message>", "description" => "Set system message", "pattern" => /^system\s+(.+)/, "n_args" => 1, "method" => "set_system_messages"}, {"name" => "edit", "description" => "Show or edit data in JSON", "pattern" => "edit", "n_args" => 0, "method" => "edit_data_json"}, {"name" => "html", "description" => "Show data in the browser", "pattern" => "html", "n_args" => 0, "method" => "html_data"}, {"name" => "html <file_name>", "description" => "Save data to <file_name> and open in the browser", "pattern" => /^html\s+(.+)/, "n_args" => 1, "method" => "html_data"}, {"name" => "clear", "description" => "Clear messages and initialize data", "pattern" => "clear", "n_args" => 0, "method" => "clear_messages"}, {"name" => "write <file_name> or w <file_name>", "description" => "Write last message to <file_name>", "pattern" => /^[write,w]\s+(.+)/, "n_args" => 1, "method" => "write_to_file"}, {"name" => "undo", "description" => "Undo last message and response", "pattern" => "undo", "n_args" => 0, "method" => "undo"}, {"name" => "undo <n>", "description" => "Undo last <n> messages and responses", "pattern" => /^undo\s+(\d+)/, "n_args" => 1, "method" => "undo"}, {"name" => "resume", "description" => "Resume from auto-saved data", "pattern" => "resume", "n_args" => 0, "method" => "resume"}, {"name" => "save", "description" => "Save data to chatgpt-<timestamp>.json", "pattern" => "save", "n_args" => 0, "method" => "save_data_to_json"}, {"name" => "save <file_name>", "description" => "Save data to <file_name>", "pattern" => /^save\s+(.+)/, "n_args" => 1, "method" => "save_data_to_json"}, {"name" => "load", "description" => "Load latest saved data from current directory", "pattern" => "load", "n_args" => 0, "method" => "load_data_from_json"}, {"name" => "load <file_name>", "description" => "Load data from <file_name>", "pattern" => /^load\s+(.+)/, "n_args" => 1, "method" => "load_data_from_json"}, {"name" => "config", "description" => "Edit config file", "pattern" => "config", "n_args" => 0, "method" => "show_config"}, {"name" => "response", "description" => "Show last response in JSON", "pattern" => "response", "n_args" => 0, "method" => "show_response_json"}, {"name" => "tokens", "description" => "Show total tokens used", "pattern" => /^tokens?\s*$/, "n_args" => 0, "method" => "show_total_tokens"}, {"name" => "history", "description" => "Show history", "pattern" => "history", "n_args" => 0, "method" => "show_history"}, {"name" => "webapp", "description" => "Open ChatGPT webapp", "pattern" => "webapp", "n_args" => 0, "method" => "open_webapp"}, {"name" => "help", "description" => "Show this help", "pattern" => "help", "n_args" => 0, "method" => "show_help"}]

Constructors

Instance Method Summary

Constructor Detail

def self.new(data = nil, key : String = "%") #

[View source]

Instance Method Detail

def clear_messages #

[View source]
def data : PostData #

[View source]
def data=(data : PostData) #

[View source]
def debug_mode_toggle #

[View source]
def edit_data_json #

[View source]
def html_data(file_name) #

[View source]
def html_data #

[View source]
def key : String #

[View source]
def load_data_from_json(file_name) #

[View source]
def load_data_from_json #

[View source]
def next? : Bool #

[View source]
def open_webapp #

[View source]
def response_data : ResponseData #

[View source]
def resume #

[View source]
def run(command : String, data : ChatGPT::PostData, response_data : ChatGPT::ResponseData) : Bool #

[View source]
def save_data_to_json(file_name) #

[View source]
def save_data_to_json #

[View source]
def set_model_name(model_name) #

[View source]
def set_system_messages(message) #

[View source]
def show_config #

[View source]
def show_help #

[View source]
def show_history #

[View source]
def show_model_name #

[View source]
def show_response_json #

[View source]
def show_system_messages #

[View source]
def show_total_tokens #

[View source]
def total_tokens : Int32 #

[View source]
def try_run(msg, data, response_data, total_tokens : Int32) #

[View source]
def undo(n) #

[View source]
def undo #

[View source]
def unknown_command_error(command) #

[View source]
def write_to_file(file_name) #

[View source]