Class: AiAgents::LLMClient
- Inherits:
-
Object
- Object
- AiAgents::LLMClient
- Defined in:
- app/services/ai_agents/llm_client.rb
Defined Under Namespace
Classes: APIError, AuthenticationError, LLMError, RateLimitError
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #complete(prompt) ⇒ Object
-
#initialize(model: nil, config: {}) ⇒ LLMClient
constructor
A new instance of LLMClient.
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
#config ⇒ Object (readonly)
Returns the value of attribute config.
11 12 13 |
# File 'app/services/ai_agents/llm_client.rb', line 11 def config @config end |
#model ⇒ Object (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 |