Class: MontyAI::AIClient
- Inherits:
-
Object
- Object
- MontyAI::AIClient
- Defined in:
- lib/monty_ai/ai_client.rb
Instance Method Summary collapse
- #explain_code(code) ⇒ Object
-
#initialize(api_key: nil) ⇒ AIClient
constructor
A new instance of AIClient.
Constructor Details
#initialize(api_key: nil) ⇒ AIClient
Returns a new instance of AIClient.
9 10 11 12 13 14 15 16 |
# File 'lib/monty_ai/ai_client.rb', line 9 def initialize(api_key: nil) @api_key = api_key || MontyAI.configuration.api_key @endpoint = MontyAI.configuration.api_endpoint return unless @api_key.nil? || @api_key.empty? raise Error, "API key is required. Set OPENAI_API_KEY or ANTHROPIC_API_KEY environment variable." end |
Instance Method Details
#explain_code(code) ⇒ Object
18 19 20 21 22 |
# File 'lib/monty_ai/ai_client.rb', line 18 def explain_code(code) prompt = build_prompt(code) response = send_request(prompt) parse_response(response) end |