chore: Debug ChatGpt response (#8316)
- Add loggers to debug ChatGPT requests and responses
This commit is contained in:
@@ -54,7 +54,9 @@ class ChatGpt
|
|||||||
def request_gpt
|
def request_gpt
|
||||||
headers = { 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{ENV.fetch('OPENAI_API_KEY')}" }
|
headers = { 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{ENV.fetch('OPENAI_API_KEY')}" }
|
||||||
body = { model: @model, messages: @messages }.to_json
|
body = { model: @model, messages: @messages }.to_json
|
||||||
|
Rails.logger.info "Requesting Chat GPT with body: #{body}"
|
||||||
response = HTTParty.post("#{self.class.base_uri}/v1/chat/completions", headers: headers, body: body)
|
response = HTTParty.post("#{self.class.base_uri}/v1/chat/completions", headers: headers, body: body)
|
||||||
|
Rails.logger.info "Chat GPT response: #{response.body}"
|
||||||
JSON.parse(response.body)
|
JSON.parse(response.body)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user