lib/webshaker/ai.rb in webshaker-0.0.3 vs lib/webshaker/ai.rb in webshaker-0.0.4

- old
+ new

@@ -4,11 +4,11 @@ def initialize(html_content) @html_content = html_content end - def analyze(with_prompt:, respond_with: :text, temperature: 0.8) + def analyze(with_prompt:, respond_with: :text, temperature: 0.8, full_response: false) response = ai_client.chat( parameters: { model: Webshaker.config.model, messages: messages(with_prompt).concat((respond_with.to_sym == :json) ? [{role: "user", content: "respond with json"}] : []), temperature: @@ -16,10 +16,10 @@ (respond_with == :json) ? {response_format: {type: "json_object"}} : {} ) ) # Return full response from the ai client if the respond_with is set to :full - return response if respond_with === :full + return response if full_response response = response["choices"][0]["message"]["content"] response = JSON.parse(response) if respond_with === :json response end