Class: LLM::Shell
- Inherits:
-
Object
- Object
- LLM::Shell
- Defined in:
- lib/llm/shell.rb,
lib/llm/shell/repl.rb,
lib/llm/shell/config.rb,
lib/llm/shell/command.rb,
lib/llm/shell/default.rb,
lib/llm/shell/options.rb,
lib/llm/shell/version.rb,
lib/llm/shell/markdown.rb,
lib/llm/shell/renderer.rb,
lib/llm/shell/formatter.rb,
lib/llm/shell/completion.rb,
lib/llm/shell/commands/help.rb,
lib/llm/shell/commands/show_chat.rb,
lib/llm/shell/commands/debug_mode.rb,
lib/llm/shell/commands/dir_import.rb,
lib/llm/shell/commands/enable_tool.rb,
lib/llm/shell/commands/file_import.rb,
lib/llm/shell/commands/clear_screen.rb,
lib/llm/shell/commands/disable_tool.rb,
lib/llm/shell/commands/show_version.rb,
lib/llm/shell/commands/system_prompt.rb
Defined Under Namespace
Modules: Tools Classes: Command, Completion, Config, Default, Formatter, Markdown, Options, REPL, Renderer
Constant Summary collapse
- VERSION =
"0.10.0"
Class Method Summary collapse
- .commands ⇒ Array<LLM::Command>
-
.find_command(name) ⇒ LLM::Command?
Returns an instance of LLM::Command, or nil.
-
.home_config ⇒ String
Returns the directory where configuration files are kept.
-
.home_data ⇒ String
Returns the directory where commands and tools are kept.
-
.pager ⇒ void
Opens a pager.
- .pattern ⇒ Regexp
-
.root ⇒ String
Returns the lib/ directory.
- .tools ⇒ Array<LLM::Tool>
Instance Method Summary collapse
- #initialize(opts) ⇒ LLM::Shell constructor
-
#start ⇒ void
Start the shell.
Constructor Details
Class Method Details
.commands ⇒ Array<LLM::Command>
58 59 60 |
# File 'lib/llm/shell.rb', line 58 def self.commands @commands ||= [] end |
.find_command(name) ⇒ LLM::Command?
Returns an instance of LLM::Command, or nil.
71 72 73 |
# File 'lib/llm/shell.rb', line 71 def self.find_command(name) commands.find { _1.name == name } end |
.home_config ⇒ String
Returns the directory where configuration files are kept
37 38 39 40 41 42 43 |
# File 'lib/llm/shell.rb', line 37 def self.home_config if ENV.key?("XDG_CONFIG_HOME") ENV["XDG_CONFIG_HOME"] else File.join Dir.home, ".config" end end |
.home_data ⇒ String
Returns the directory where commands and tools are kept
48 49 50 51 52 53 54 |
# File 'lib/llm/shell.rb', line 48 def self.home_data if ENV.key?("XDG_DATA_HOME") File.join ENV["XDG_DATA_HOME"], ".llm-shell" else File.join Dir.home, ".local", "share", ".llm-shell" end end |
.pager ⇒ void
This method returns an undefined value.
Opens a pager
84 85 86 |
# File 'lib/llm/shell.rb', line 84 def self.pager(...) IO.popen("less -FRX", "w", ...) end |
.pattern ⇒ Regexp
77 78 79 |
# File 'lib/llm/shell.rb', line 77 def self.pattern /\A<file path=(.+?)>/ end |
.root ⇒ String
Returns the lib/ directory
30 31 32 |
# File 'lib/llm/shell.rb', line 30 def self.root __dir__ end |
.tools ⇒ Array<LLM::Tool>
64 65 66 |
# File 'lib/llm/shell.rb', line 64 def self.tools @tools ||= [] end |
Instance Method Details
#start ⇒ void
This method returns an undefined value.
Start the shell
108 109 110 111 |
# File 'lib/llm/shell.rb', line 108 def start repl.setup repl.start end |