Module: RubyTodo::OpenAIApiInteraction

Includes:
OpenAIContextBuilding, OpenAIResponseHandling
Included in:
OpenAIIntegration
Defined in:
lib/ruby_todo/ai_assistant/openai_integration.rb

Overview

Module for OpenAI API interaction

Constant Summary

Constants included from OpenAIDocumentation

RubyTodo::OpenAIDocumentation::CLI_DOCUMENTATION

Instance Method Summary collapse

Methods included from OpenAIResponseHandling

#extract_command_explanation, #handle_openai_error, #handle_openai_response, #parse_openai_response_content

Instance Method Details

#query_openai(prompt, context, api_key) ⇒ Object



324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/ruby_todo/ai_assistant/openai_integration.rb', line 324

def query_openai(prompt, context, api_key)
  # Build the context for the AI
  message_context = build_prompt_context(context)

  # Extract available commands from CLI documentation
  available_commands = build_available_commands

  # Prepare system message with context and available commands
  system_message = prepare_system_message(message_context, available_commands)

  # Build user message
  user_message = build_user_message(prompt)

  # Configure and make OpenAI API call
  make_openai_api_call(system_message, user_message, api_key)
end