mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-11 20:05:19 +00:00
fix formatting
This commit is contained in:
parent
d10a71c298
commit
0422b5e29d
4 changed files with 20 additions and 16 deletions
|
|
@ -374,7 +374,9 @@ ENABLE_REALTIME_CHAT_SAVE = (
|
|||
|
||||
ENABLE_QUERIES_CACHE = os.environ.get("ENABLE_QUERIES_CACHE", "False").lower() == "true"
|
||||
|
||||
ENABLE_WRAP_TOOL_RESULT = os.environ.get("ENABLE_WRAP_TOOL_RESULT", "True").lower() == "true"
|
||||
ENABLE_WRAP_TOOL_RESULT = (
|
||||
os.environ.get("ENABLE_WRAP_TOOL_RESULT", "True").lower() == "true"
|
||||
)
|
||||
|
||||
TOOL_RESULT_INDENT_SIZE = os.environ.get("TOOL_RESULT_INDENT_SIZE", 2)
|
||||
|
||||
|
|
|
|||
|
|
@ -286,10 +286,14 @@ def process_tool_result(
|
|||
|
||||
return tool_result, tool_result_files, tool_result_embeds
|
||||
|
||||
|
||||
def dump_tool_result_to_json(model, ensure_ascii=True):
|
||||
indent_size = None if TOOL_RESULT_INDENT_SIZE == 0 else TOOL_RESULT_INDENT_SIZE
|
||||
separators = None if indent_size and indent_size > 0 else (',', ':')
|
||||
return json.dumps(model, indent=indent_size, separators=separators, ensure_ascii=ensure_ascii)
|
||||
separators = None if indent_size and indent_size > 0 else (",", ":")
|
||||
return json.dumps(
|
||||
model, indent=indent_size, separators=separators, ensure_ascii=ensure_ascii
|
||||
)
|
||||
|
||||
|
||||
async def chat_completion_tools_handler(
|
||||
request: Request, body: dict, extra_params: dict, user: UserModel, models, tools
|
||||
|
|
|
|||
|
|
@ -1877,6 +1877,7 @@
|
|||
for (const message of _messages) {
|
||||
let content = message?.merged?.content ?? message?.content;
|
||||
let processedMessages = processDetailsAndExtractToolCalls(content ?? '');
|
||||
|
||||
let nonToolMesssage = null;
|
||||
let toolCallIndex = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -907,8 +907,7 @@ export const processDetailsAndExtractToolCalls = (content) => {
|
|||
if (finalAssistantMessage.length > 0) {
|
||||
messages.push(finalAssistantMessage);
|
||||
}
|
||||
}
|
||||
else if (content.length > 0) {
|
||||
} else if (content.length > 0) {
|
||||
messages.push(content);
|
||||
}
|
||||
|
||||
|
|
@ -916,14 +915,12 @@ export const processDetailsAndExtractToolCalls = (content) => {
|
|||
};
|
||||
|
||||
function parseDoubleEncodedString(value) {
|
||||
try
|
||||
{
|
||||
try {
|
||||
let parsedValue = JSON.parse(value);
|
||||
if (typeof parsedValue == "string") {
|
||||
return parsedValue;
|
||||
}
|
||||
}
|
||||
catch {}
|
||||
} catch {}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue