Class: RubyLLM::Providers::Codex
- Inherits:
-
Provider
- Object
- Provider
- RubyLLM::Providers::Codex
- Defined in:
- lib/ruby_llm/providers/codex.rb
Overview
A local RubyLLM provider backed by codex exec and ChatGPT authentication.
This provider is deliberately narrow: non-streaming text generation and structured output are supported; RubyLLM tools and attachments are not.
Defined Under Namespace
Classes: Error, TimeoutError, UnsupportedFeatureError
Constant Summary collapse
- DEFAULT_SANDBOX =
"read-only"- DEFAULT_TIMEOUT =
300- DEFAULT_SHELL_ENVIRONMENT_INHERIT =
"none"- MINIMUM_CLI_VERSION =
"0.144.5"- RESERVED_CONFIG_KEYS =
%w[ developer_instructions features.shell_snapshot model_reasoning_effort shell_environment_policy.inherit ].freeze
Class Method Summary collapse
- .assume_models_exist? ⇒ Boolean
- .configuration_options ⇒ Object
- .configuration_requirements ⇒ Object
- .local? ⇒ Boolean
Instance Method Summary collapse
- #api_base ⇒ Object
-
#complete(messages, tools:, temperature:, model:, params: {}, headers: {}, schema: nil, thinking: nil, tool_prefs: nil, &stream) ⇒ Object
rubocop:disable Metrics/ParameterLists.
- #headers ⇒ Object
-
#list_models ⇒ Object
rubocop:enable Metrics/ParameterLists.
Class Method Details
.assume_models_exist? ⇒ Boolean
69 70 71 |
# File 'lib/ruby_llm/providers/codex.rb', line 69 def assume_models_exist? true end |
.configuration_options ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/ruby_llm/providers/codex.rb', line 73 def %i[ codex_cli_path codex_working_directory codex_profile codex_home codex_ignore_user_config codex_ephemeral codex_timeout codex_shell_environment_inherit ] end |
.configuration_requirements ⇒ Object
86 87 88 |
# File 'lib/ruby_llm/providers/codex.rb', line 86 def configuration_requirements [] end |
.local? ⇒ Boolean
65 66 67 |
# File 'lib/ruby_llm/providers/codex.rb', line 65 def local? true end |
Instance Method Details
#api_base ⇒ Object
31 32 33 |
# File 'lib/ruby_llm/providers/codex.rb', line 31 def api_base "http://127.0.0.1" end |
#complete(messages, tools:, temperature:, model:, params: {}, headers: {}, schema: nil, thinking: nil, tool_prefs: nil, &stream) ⇒ Object
rubocop:disable Metrics/ParameterLists
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ruby_llm/providers/codex.rb', line 40 def complete(, tools:, temperature:, model:, params: {}, headers: {}, schema: nil, thinking: nil, tool_prefs: nil, &stream) validate_request!(tools:, temperature:, headers:, stream:) = (params) developer_instructions, prompt = build_prompt() request = { model: model.id, prompt:, developer_instructions:, schema:, thinking: } with_working_directory() do |working_directory| run_codex(request, working_directory:, options:) end end |
#headers ⇒ Object
35 36 37 |
# File 'lib/ruby_llm/providers/codex.rb', line 35 def headers {} end |
#list_models ⇒ Object
rubocop:enable Metrics/ParameterLists
60 61 62 |
# File 'lib/ruby_llm/providers/codex.rb', line 60 def list_models [] end |