refac
This commit is contained in:
1 parent
4f89617192
commit
7e9d41d664
1 file changed
+5
@@ -911,6 +911,7 @@ async def model_response_handler(request, channel, message, user, db=None):
|
|||||||
|
|
||||||
thread_history = []
|
thread_history = []
|
||||||
images = []
|
images = []
|
||||||
|
files = []
|
||||||
|
|
||||||
# Batch fetch all users in a single query (fixes N+1 problem)
|
# Batch fetch all users in a single query (fixes N+1 problem)
|
||||||
user_ids = list({message.user_id for message in thread_messages})
|
user_ids = list({message.user_id for message in thread_messages})
|
||||||
@@ -937,6 +938,8 @@ async def model_response_handler(request, channel, message, user, db=None):
|
|||||||
image = await get_image_base64_from_file_id(file.get('id', ''), user=user)
|
image = await get_image_base64_from_file_id(file.get('id', ''), user=user)
|
||||||
if image:
|
if image:
|
||||||
images.append(image)
|
images.append(image)
|
||||||
|
elif file.get('id'):
|
||||||
|
files.append(file)
|
||||||
|
|
||||||
thread_history_string = '\n\n'.join(thread_history)
|
thread_history_string = '\n\n'.join(thread_history)
|
||||||
system_message = {
|
system_message = {
|
||||||
@@ -994,6 +997,8 @@ async def model_response_handler(request, channel, message, user, db=None):
|
|||||||
'session_id': f'channel:{channel.id}',
|
'session_id': f'channel:{channel.id}',
|
||||||
'background_tasks': {},
|
'background_tasks': {},
|
||||||
}
|
}
|
||||||
|
if files:
|
||||||
|
form_data['files'] = files
|
||||||
if tool_ids:
|
if tool_ids:
|
||||||
form_data['tool_ids'] = tool_ids
|
form_data['tool_ids'] = tool_ids
|
||||||
if features:
|
if features:
|
||||||
|
|||||||
Reference in new issue
Block a user