mirror of
https://github.com/open-webui/open-webui
synced 2024-11-16 05:24:02 +00:00
fix: function early returns
This commit is contained in:
parent
3978efd710
commit
deec41d29a
@ -291,12 +291,7 @@ def get_params_dict(pipe, form_data, user, extra_params, function_module):
|
||||
return params
|
||||
|
||||
|
||||
async def generate_function_chat_completion(form_data, user):
|
||||
model_id = form_data.get("model")
|
||||
model_info = Models.get_model_by_id(model_id)
|
||||
|
||||
metadata = form_data.pop("metadata", None)
|
||||
|
||||
def get_extra_params(metadata: dict):
|
||||
__event_emitter__ = __event_call__ = __task__ = None
|
||||
|
||||
if metadata:
|
||||
@ -305,9 +300,22 @@ async def generate_function_chat_completion(form_data, user):
|
||||
__event_call__ = get_event_call(metadata)
|
||||
__task__ = metadata.get("task", None)
|
||||
|
||||
if not model_info:
|
||||
return
|
||||
return {
|
||||
"__event_emitter__": __event_emitter__,
|
||||
"__event_call__": __event_call__,
|
||||
"__task__": __task__,
|
||||
}
|
||||
|
||||
|
||||
async def generate_function_chat_completion(form_data, user):
|
||||
print("entry point")
|
||||
model_id = form_data.get("model")
|
||||
model_info = Models.get_model_by_id(model_id)
|
||||
|
||||
metadata = form_data.pop("metadata", None)
|
||||
extra_params = get_extra_params(metadata)
|
||||
|
||||
if model_info:
|
||||
if model_info.base_model_id:
|
||||
form_data["model"] = model_info.base_model_id
|
||||
|
||||
@ -320,7 +328,9 @@ async def generate_function_chat_completion(form_data, user):
|
||||
"max_tokens": int,
|
||||
"frequency_penalty": int,
|
||||
"seed": lambda x: x,
|
||||
"stop": lambda x: [bytes(s, "utf-8").decode("unicode_escape") for s in x],
|
||||
"stop": lambda x: [
|
||||
bytes(s, "utf-8").decode("unicode_escape") for s in x
|
||||
],
|
||||
}
|
||||
|
||||
for key, cast_func in mappings.items():
|
||||
@ -328,9 +338,7 @@ async def generate_function_chat_completion(form_data, user):
|
||||
form_data[key] = cast_func(value)
|
||||
|
||||
system = params.get("system", None)
|
||||
if not system:
|
||||
return
|
||||
|
||||
if system:
|
||||
if user:
|
||||
template_params = {
|
||||
"user_name": user.name,
|
||||
@ -349,13 +357,9 @@ async def generate_function_chat_completion(form_data, user):
|
||||
break
|
||||
else:
|
||||
if form_data.get("messages"):
|
||||
form_data["messages"].insert(0, {"role": "system", "content": system})
|
||||
|
||||
extra_params = {
|
||||
"__event_emitter__": __event_emitter__,
|
||||
"__event_call__": __event_call__,
|
||||
"__task__": __task__,
|
||||
}
|
||||
form_data["messages"].insert(
|
||||
0, {"role": "system", "content": system}
|
||||
)
|
||||
|
||||
async def job():
|
||||
pipe_id = get_pipe_id(form_data)
|
||||
|
Loading…
Reference in New Issue
Block a user