fix: inconsistent OpenAI cache interface (#10009)

Signed-off-by: Shivam Mishra <scm.mymail@gmail.com>
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
Shivam Mishra
2024-08-22 23:04:14 +05:30
committed by GitHub
parent a48f98de9d
commit abc511d00f
4 changed files with 23 additions and 5 deletions

View File

@@ -12,7 +12,12 @@ class Api::V1::Accounts::Integrations::HooksController < Api::V1::Accounts::Base
def process_event
response = @hook.process_event(params[:event])
if response[:error]
# for cases like an invalid event, or when conversation does not have enough messages
# for a label suggestion, the response is nil
if response.nil?
render json: { message: nil }
elsif response[:error]
render json: { error: response[:error] }, status: :unprocessable_entity
else
render json: { message: response[:message] }