Class: XAeonAgents::Providers::Cline
- Inherits:
-
RubyLLM::Providers::OpenAI
- Object
- RubyLLM::Providers::OpenAI
- XAeonAgents::Providers::Cline
- Defined in:
- lib/x_aeon_agents/providers/cline.rb
Overview
Cline API integration.
Class Method Summary collapse
-
.configuration_options ⇒ Array<Symbol>
The available configuration keys for the Cline provider.
-
.configuration_requirements ⇒ Array<Symbol>
The required configuration keys for the Cline provider.
Instance Method Summary collapse
-
#api_base ⇒ String
The base API URL.
-
#headers ⇒ Hash{String => String}
HTTP headers to add to the queries.
-
#parse_completion_response(response) ⇒ RubyLLM::Message?
Parses the completion response from the Cline API into a [RubyLLM::Message].
Class Method Details
.configuration_options ⇒ Array<Symbol>
Returns The available configuration keys for the Cline provider.
72 73 74 |
# File 'lib/x_aeon_agents/providers/cline.rb', line 72 def %i[cline_api_base cline_api_key] end |
.configuration_requirements ⇒ Array<Symbol>
Returns The required configuration keys for the Cline provider.
67 68 69 |
# File 'lib/x_aeon_agents/providers/cline.rb', line 67 def configuration_requirements %i[cline_api_base cline_api_key] end |
Instance Method Details
#api_base ⇒ String
Returns The base API URL.
15 16 17 |
# File 'lib/x_aeon_agents/providers/cline.rb', line 15 def api_base @config.cline_api_base || 'https://api.cline.bot/api/v1' end |
#headers ⇒ Hash{String => String}
Returns HTTP headers to add to the queries.
20 21 22 23 24 |
# File 'lib/x_aeon_agents/providers/cline.rb', line 20 def headers { 'Authorization' => "Bearer #{@config.cline_api_key}" } end |
#parse_completion_response(response) ⇒ RubyLLM::Message?
Parses the completion response from the Cline API into a [RubyLLM::Message].
Handles empty responses, API errors, message extraction, content/thinking parsing, token usage tracking (including cached and reasoning tokens), and tool calls.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/x_aeon_agents/providers/cline.rb', line 34 def parse_completion_response(response) data = response.body return if data.empty? raise Error.new(response, data['error']) if data['error'] = data.dig('data', 'choices', 0, 'message') return unless usage = data.dig('data', 'usage') || {} cached_tokens = usage.dig('prompt_tokens_details', 'cached_tokens') thinking_tokens = usage.dig('completion_tokens_details', 'reasoning_tokens') content, thinking_from_blocks = extract_content_and_thinking(['content']) thinking_text = thinking_from_blocks || extract_thinking_text() thinking_signature = extract_thinking_signature() RubyLLM::Message.new( role: :assistant, content: content, thinking: RubyLLM::Thinking.build(text: thinking_text, signature: thinking_signature), tool_calls: parse_tool_calls(['tool_calls']), input_tokens: usage['prompt_tokens'], output_tokens: usage['completion_tokens'], cached_tokens: cached_tokens, cache_creation_tokens: 0, thinking_tokens: thinking_tokens, model_id: data.dig('data', 'model'), raw: response ) end |