This PR is the first of many to simplify the process of building an assistant. The new flow will only require the user’s website. We’ll automatically crawl it, identify the business name and what the business does, and then generate a suggested assistant persona, complete with a proposed name and description. This service returns the following. Example: tooljet.com <img width="795" height="217" alt="Screenshot 2025-10-25 at 2 55 04 PM" src="https://github.com/user-attachments/assets/9cb3594a-9c9c-4970-a0a1-4c9c8869c193" /> Example: replit.com <img width="797" height="176" alt="Screenshot 2025-10-25 at 2 56 42 PM" src="https://github.com/user-attachments/assets/6a1b4266-aab6-455f-a5e3-696d3a8243c9" />
28 lines
756 B
Ruby
28 lines
756 B
Ruby
class Llm::BaseOpenAiService
|
|
DEFAULT_MODEL = 'gpt-4o-mini'.freeze
|
|
attr_reader :client, :model
|
|
|
|
def initialize
|
|
@client = OpenAI::Client.new(
|
|
access_token: InstallationConfig.find_by!(name: 'CAPTAIN_OPEN_AI_API_KEY').value,
|
|
uri_base: uri_base,
|
|
log_errors: Rails.env.development?
|
|
)
|
|
setup_model
|
|
rescue StandardError => e
|
|
raise "Failed to initialize OpenAI client: #{e.message}"
|
|
end
|
|
|
|
private
|
|
|
|
def uri_base
|
|
endpoint = InstallationConfig.find_by(name: 'CAPTAIN_OPEN_AI_ENDPOINT')&.value
|
|
endpoint.presence || 'https://api.openai.com/'
|
|
end
|
|
|
|
def setup_model
|
|
config_value = InstallationConfig.find_by(name: 'CAPTAIN_OPEN_AI_MODEL')&.value
|
|
@model = (config_value.presence || DEFAULT_MODEL)
|
|
end
|
|
end
|