lib/intelli_agent/openai.rb in intelli_agent-0.2.2 vs lib/intelli_agent/openai.rb in intelli_agent-0.2.3

- old
+ new

@@ -44,11 +44,12 @@ end end def self.embed(input, model: 'text-embedding-3-large') response = OpenAI::Client.new.embeddings(parameters: { input:, model: }) - response.dig('data', 0, 'embedding') + def response.embedding = dig('data', 0, 'embedding') + response end def self.vision(prompt:, image_url:, model: :advanced, response_format: nil, max_tokens: MAX_TOKENS) model = select_model(model) messages = [{ type: :text, text: prompt }, @@ -57,10 +58,12 @@ parameters = { model: model, messages: [{ role: :user, content: messages }], max_tokens: } parameters[:response_format] = { type: 'json_object' } if response_format.eql?(:json) response = OpenAI::Client.new.chat(parameters:) - response.dig('choices', 0, 'message', 'content').strip + def response.content = dig('choices', 0, 'message', 'content').strip + + response end def self.single_prompt(prompt:, model: :basic, response_format: nil, max_tokens: MAX_TOKENS, tools: nil, function_run_context: self) chat(messages: [{ user: prompt }], model:, response_format:, max_tokens:, tools:, function_run_context:) end \ No newline at end of file