feat: Add article messages along with bot responses (#7993)

ref: https://linear.app/chatwoot/issue/CW-2464/bot-should-also-return-links-to-the-information
This commit is contained in:
Sojan Jose
2023-10-04 15:40:59 -07:00
committed by GitHub
parent 5c9ab21617
commit 6f19546c3c
5 changed files with 60 additions and 48 deletions

View File

@@ -8,7 +8,7 @@ class Openai::EmbeddingsService
def fetch_embeddings(input)
url = 'https://api.openai.com/v1/embeddings'
headers = {
'Authorization' => "Bearer #{ENV.fetch('OPENAI_API_KEY')}",
'Authorization' => "Bearer #{ENV.fetch('OPENAI_API_KEY', '')}",
'Content-Type' => 'application/json'
}
data = {
@@ -17,6 +17,6 @@ class Openai::EmbeddingsService
}
response = Net::HTTP.post(URI(url), data.to_json, headers)
JSON.parse(response.body)['data'].pick('embedding')
JSON.parse(response.body)['data']&.pick('embedding')
end
end