Skip to content

Commit c1cb24e

Browse files
fix: Error handling for 'answer' variable (#1343)
1 parent 9ecf2b7 commit c1cb24e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

code/backend/batch/utilities/orchestrator/open_ai_functions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,18 @@ async def orchestrate(
125125
prompt_tokens=answer.prompt_tokens,
126126
completion_tokens=answer.completion_tokens,
127127
)
128+
else:
129+
logger.info("Unknown function call detected")
130+
text = result.choices[0].message.content
131+
answer = Answer(question=user_message, answer=text)
128132
else:
129133
logger.info("No function call detected")
130134
text = result.choices[0].message.content
131135
answer = Answer(question=user_message, answer=text)
132136

137+
if answer.answer is None:
138+
answer.answer = "The requested information is not available in the retrieved data. Please try another query or topic."
139+
133140
# Call Content Safety tool
134141
if self.config.prompts.enable_content_safety:
135142
if response := self.call_content_safety_output(user_message, answer.answer):

0 commit comments

Comments
 (0)