mirror of
https://github.com/open-webui/open-webui
synced 2025-03-25 23:19:32 +00:00
refac
This commit is contained in:
parent
5a168ecc2a
commit
c93a10388b
@ -787,6 +787,7 @@ async def generate_chat_completion(
|
|||||||
):
|
):
|
||||||
payload = {**form_data.model_dump(exclude_none=True)}
|
payload = {**form_data.model_dump(exclude_none=True)}
|
||||||
log.debug(f"{payload = }")
|
log.debug(f"{payload = }")
|
||||||
|
|
||||||
if "metadata" in payload:
|
if "metadata" in payload:
|
||||||
del payload["metadata"]
|
del payload["metadata"]
|
||||||
|
|
||||||
|
@ -448,7 +448,11 @@ async def chat_completion_tools_handler(
|
|||||||
if not content:
|
if not content:
|
||||||
return body, {}
|
return body, {}
|
||||||
|
|
||||||
|
try:
|
||||||
content = content[content.find("{") : content.rfind("}") + 1]
|
content = content[content.find("{") : content.rfind("}") + 1]
|
||||||
|
if not content:
|
||||||
|
raise Exception("No JSON object found in the response")
|
||||||
|
|
||||||
result = json.loads(content)
|
result = json.loads(content)
|
||||||
|
|
||||||
tool_function_name = result.get("name", None)
|
tool_function_name = result.get("name", None)
|
||||||
@ -479,7 +483,9 @@ async def chat_completion_tools_handler(
|
|||||||
|
|
||||||
if isinstance(tool_output, str):
|
if isinstance(tool_output, str):
|
||||||
contexts.append(tool_output)
|
contexts.append(tool_output)
|
||||||
|
except Exception as e:
|
||||||
|
log.exception(f"Error: {e}")
|
||||||
|
content = None
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.exception(f"Error: {e}")
|
log.exception(f"Error: {e}")
|
||||||
content = None
|
content = None
|
||||||
|
Loading…
Reference in New Issue
Block a user