mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-05 11:07:55 -05:00
refac
This commit is contained in:
1 parent
924e9885fc
commit
0481ad7c2e
77 files changed
+816
-1067
No files matched your search
@@ -160,7 +160,7 @@ from open_webui.utils.skills import (
|
||||
strip_skill_mentions,
|
||||
)
|
||||
from open_webui.utils.task import (
|
||||
get_task_model_id,
|
||||
get_system_model_id,
|
||||
parse_follow_ups,
|
||||
rag_template,
|
||||
tools_function_calling_generation_template,
|
||||
@@ -1267,7 +1267,7 @@ async def chat_completion_tools_handler(
|
||||
content = response['choices'][0]['message']['content']
|
||||
return content
|
||||
|
||||
def get_tools_function_calling_payload(messages, task_model_id, content):
|
||||
def get_tools_function_calling_payload(messages, system_model_id, content):
|
||||
user_message = get_last_user_message(messages)
|
||||
|
||||
if user_message and messages and messages[-1]['role'] == 'user':
|
||||
@@ -1282,7 +1282,7 @@ async def chat_completion_tools_handler(
|
||||
prompt = f'History:\n{chat_history}\nQuery: {user_message}' if chat_history else f'Query: {user_message}'
|
||||
|
||||
return {
|
||||
'model': task_model_id,
|
||||
'model': system_model_id,
|
||||
'messages': [
|
||||
{'role': 'system', 'content': content},
|
||||
{'role': 'user', 'content': prompt},
|
||||
@@ -1297,14 +1297,14 @@ async def chat_completion_tools_handler(
|
||||
|
||||
# One batched SELECT instead of four sequential round trips.
|
||||
task_config = await Config.get_many(
|
||||
'task.model.default',
|
||||
'task.model.external',
|
||||
'system_model.default',
|
||||
'system_model.external',
|
||||
'task.tools.prompt_template',
|
||||
)
|
||||
task_model_id = get_task_model_id(
|
||||
system_model_id = get_system_model_id(
|
||||
body['model'],
|
||||
task_config.get('task.model.default'),
|
||||
task_config.get('task.model.external'),
|
||||
task_config.get('system_model.default'),
|
||||
task_config.get('system_model.external'),
|
||||
models,
|
||||
)
|
||||
|
||||
@@ -1321,7 +1321,7 @@ async def chat_completion_tools_handler(
|
||||
template = DEFAULT_TOOLS_FUNCTION_CALLING_PROMPT_TEMPLATE
|
||||
|
||||
tools_function_calling_prompt = tools_function_calling_generation_template(template, tools_specs)
|
||||
payload = get_tools_function_calling_payload(body['messages'], task_model_id, tools_function_calling_prompt)
|
||||
payload = get_tools_function_calling_payload(body['messages'], system_model_id, tools_function_calling_prompt)
|
||||
|
||||
try:
|
||||
response = await generate_chat_completion(request, form_data=payload, user=user)
|
||||
@@ -2519,10 +2519,10 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
||||
|
||||
models = await add_tether_model(request, user, form_data.get('model'))
|
||||
|
||||
task_model_id = get_task_model_id(
|
||||
system_model_id = get_system_model_id(
|
||||
form_data['model'],
|
||||
await Config.get('task.model.default'),
|
||||
await Config.get('task.model.external'),
|
||||
await Config.get('system_model.default'),
|
||||
await Config.get('system_model.external'),
|
||||
models,
|
||||
)
|
||||
|
||||
@@ -3003,7 +3003,7 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
||||
user,
|
||||
{
|
||||
**extra_params,
|
||||
'__model__': models[task_model_id],
|
||||
'__model__': models[system_model_id],
|
||||
'__messages__': form_data['messages'],
|
||||
'__files__': metadata.get('files') or [],
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user