refac
This commit is contained in:
@@ -1344,9 +1344,7 @@ async def chat_completion(
|
||||
user_message = metadata.get('user_message') or {}
|
||||
selected_chat_models = user_message.get('models') if isinstance(user_message, dict) else None
|
||||
if not isinstance(selected_chat_models, list) or not selected_chat_models:
|
||||
selected_chat_models = [
|
||||
entry.get('model_id') for entry in message_ids if entry.get('model_id')
|
||||
]
|
||||
selected_chat_models = [entry.get('model_id') for entry in message_ids if entry.get('model_id')]
|
||||
|
||||
# Persist chat-level fields the frontend used to save on every message.
|
||||
# The old frontend saveChatHandler did this on every message;
|
||||
|
||||
@@ -89,9 +89,7 @@ def _convert_column_to_json(table: str, column: str):
|
||||
parsed = None
|
||||
|
||||
conn.execute(
|
||||
sa.update(
|
||||
sa.table(table, sa.column('id'), sa.column(f'{column}_json', sa.JSON))
|
||||
)
|
||||
sa.update(sa.table(table, sa.column('id'), sa.column(f'{column}_json', sa.JSON)))
|
||||
.where(sa.column('id') == uid)
|
||||
.values({f'{column}_json': parsed})
|
||||
)
|
||||
@@ -122,9 +120,7 @@ def _convert_column_to_text(table: str, column: str):
|
||||
|
||||
for uid, raw in rows:
|
||||
conn.execute(
|
||||
sa.update(
|
||||
sa.table(table, sa.column('id'), sa.column(f'{column}_text', sa.Text))
|
||||
)
|
||||
sa.update(sa.table(table, sa.column('id'), sa.column(f'{column}_text', sa.Text)))
|
||||
.where(sa.column('id') == uid)
|
||||
.values({f'{column}_text': json.dumps(raw) if raw is not None else None})
|
||||
)
|
||||
|
||||
@@ -648,9 +648,7 @@ async def _transcribe_openai(request, file_path, filename, languages, file_dir,
|
||||
session = await get_session()
|
||||
api_key = await Config.get('audio.stt.openai.api_key')
|
||||
api_base_url = await Config.get('audio.stt.openai.api_base_url')
|
||||
request_format = (
|
||||
await Config.get('audio.stt.openai.api_request_format') or 'multipart'
|
||||
).lower()
|
||||
request_format = (await Config.get('audio.stt.openai.api_request_format') or 'multipart').lower()
|
||||
|
||||
headers = {'Authorization': f'Bearer {api_key}'}
|
||||
if user and ENABLE_FORWARD_USER_INFO_HEADERS:
|
||||
|
||||
@@ -3471,7 +3471,6 @@ async def non_streaming_chat_response_handler(response, ctx):
|
||||
content = choices[0].get('message', {}).get('content') if choices else ''
|
||||
|
||||
if choices and (content or response_output):
|
||||
|
||||
if content or response_output:
|
||||
await event_emitter(
|
||||
{
|
||||
@@ -4307,11 +4306,7 @@ async def streaming_chat_response_handler(response, ctx):
|
||||
if reasoning_content or reasoning_details:
|
||||
reasoning_item = (
|
||||
next(
|
||||
(
|
||||
item
|
||||
for item in reversed(output)
|
||||
if item.get('type') == 'reasoning'
|
||||
),
|
||||
(item for item in reversed(output) if item.get('type') == 'reasoning'),
|
||||
None,
|
||||
)
|
||||
if reasoning_details and not reasoning_content
|
||||
|
||||
Reference in New Issue
Block a user