Class: Ask::Providers::OpenCodeGo
- Inherits:
-
OpenAI
- Object
- Ask::Provider
- OpenAI
- Ask::Providers::OpenCodeGo
show all
- Defined in:
- lib/ask/provider/opencode_go.rb
Overview
OpenCode Go API — an OpenAI-compatible provider at opencode.ai/zen/go
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from OpenAI
assume_models_exist?, capabilities, #chat, #embed, #initialize, #list_models, #parse_error
Class Method Details
.configuration_options ⇒ Object
20
|
# File 'lib/ask/provider/opencode_go.rb', line 20
def configuration_options; %i[api_key base_url]; end
|
.configuration_requirements ⇒ Object
21
|
# File 'lib/ask/provider/opencode_go.rb', line 21
def configuration_requirements; %i[api_key]; end
|
22
23
24
25
26
|
# File 'lib/ask/provider/opencode_go.rb', line 22
def configured?(config)
key = config.respond_to?(:api_key) ? config.api_key : nil
key ||= ENV["OPENCODE_API_KEY"] || ENV["OPENCODE_GO_API_KEY"]
key.to_s.length > 0
end
|
.slug ⇒ Object
19
|
# File 'lib/ask/provider/opencode_go.rb', line 19
def slug; "opencode_go"; end
|
Instance Method Details
#api_base ⇒ Object
7
8
9
|
# File 'lib/ask/provider/opencode_go.rb', line 7
def api_base
@config.base_url || ENV["OPENCODE_GO_API_BASE"] || "https://opencode.ai/zen/go/v1"
end
|
11
12
13
14
15
16
|
# File 'lib/ask/provider/opencode_go.rb', line 11
def
key = @config.api_key || ENV["OPENCODE_API_KEY"] || ENV["OPENCODE_GO_API_KEY"]
h = { "Content-Type" => "application/json" }
h["Authorization"] = "Bearer #{key}" if key
h
end
|