Class: AiAgents::LLMClient

Inherits:
Object
  • Object
show all
Defined in:
app/services/ai_agents/llm_client.rb

Defined Under Namespace

Classes: APIError, AuthenticationError, LLMError, RateLimitError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model: nil, config: {}) ⇒ LLMClient

Returns a new instance of LLMClient.



13
14
15
16
# File 'app/services/ai_agents/llm_client.rb', line 13

def initialize(model: nil, config: {})
  @model = model || RailsAiAgents.configuration.default_model
  @config = config || {}
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



11
12
13
# File 'app/services/ai_agents/llm_client.rb', line 11

def config
  @config
end

#modelObject (readonly)

Returns the value of attribute model.



11
12
13
# File 'app/services/ai_agents/llm_client.rb', line 11

def model
  @model
end

Instance Method Details

#complete(prompt) ⇒ Object



18
19
20
21
22
23
24
25
# File 'app/services/ai_agents/llm_client.rb', line 18

def complete(prompt)
  case RailsAiAgents.configuration.llm_provider
  when :openai
    complete_with_openai(prompt)
  else
    raise LLMError, "Unsupported LLM provider: #{RailsAiAgents.configuration.llm_provider}"
  end
end