refac
This commit is contained in:
@@ -444,7 +444,7 @@ def serialize_output(output: list) -> str:
|
||||
files = result_item.get('files')
|
||||
embeds = result_item.get('embeds', '')
|
||||
|
||||
content += f'<details type="tool_calls" done="true" id="{call_id}" name="{name}" arguments="{html.escape(json.dumps(arguments))}" result="{html.escape(json.dumps(result_text, ensure_ascii=False))}" files="{html.escape(json.dumps(files)) if files else ""}" embeds="{html.escape(json.dumps(embeds))}">\n<summary>Tool Executed</summary>\n</details>\n'
|
||||
content += f'<details type="tool_calls" done="true" id="{call_id}" name="{name}" arguments="{html.escape(json.dumps(arguments))}" files="{html.escape(json.dumps(files)) if files else ""}" embeds="{html.escape(json.dumps(embeds))}">\n<summary>Tool Executed</summary>\n{html.escape(json.dumps(result_text, ensure_ascii=False))}\n</details>\n'
|
||||
else:
|
||||
content += f'<details type="tool_calls" done="false" id="{call_id}" name="{name}" arguments="{html.escape(json.dumps(arguments))}">\n<summary>Executing...</summary>\n</details>\n'
|
||||
|
||||
|
||||
@@ -380,6 +380,7 @@
|
||||
<ToolCallDisplay
|
||||
id={`${id}-${tokenIdx}-${detailIdx}-tc`}
|
||||
attributes={detailToken.attributes}
|
||||
resultContent={getDetailTextContent(detailToken)}
|
||||
grouped={true}
|
||||
open={$settings?.expandDetails ?? false}
|
||||
className="w-full space-y-1"
|
||||
@@ -428,6 +429,7 @@
|
||||
<ToolCallDisplay
|
||||
id={`${id}-${tokenIdx}-tc`}
|
||||
attributes={token.attributes}
|
||||
resultContent={getDetailTextContent(token)}
|
||||
open={$settings?.expandDetails ?? false}
|
||||
className="w-full space-y-1"
|
||||
/>
|
||||
|
||||
@@ -77,7 +77,9 @@
|
||||
}
|
||||
|
||||
$: args = decode(attributes?.arguments ?? '');
|
||||
$: result = decode(attributes?.result ?? '');
|
||||
export let resultContent: string = '';
|
||||
|
||||
$: result = resultContent || decode(attributes?.result ?? '');
|
||||
$: files = parseJSONString(decode(attributes?.files ?? ''));
|
||||
$: embeds = parseJSONString(decode(attributes?.embeds ?? ''));
|
||||
$: isDone = attributes?.done === 'true';
|
||||
|
||||
+12
-1
@@ -923,8 +923,19 @@ export const processDetails = (content) => {
|
||||
attributes[attributeMatch[1]] = attributeMatch[2];
|
||||
}
|
||||
|
||||
// New format: result in body content; Old format: result in attribute
|
||||
let resultText = '';
|
||||
if (attributes.result) {
|
||||
content = content.replace(match, unescapeHtml(attributes.result));
|
||||
resultText = unescapeHtml(attributes.result);
|
||||
} else {
|
||||
// Extract body content (strip <summary>...</summary>)
|
||||
const bodyMatch = match.match(/<summary>[\s\S]*?<\/summary>\s*([\s\S]*?)\s*<\/details>/i);
|
||||
if (bodyMatch && bodyMatch[1].trim()) {
|
||||
resultText = unescapeHtml(bodyMatch[1].trim());
|
||||
}
|
||||
}
|
||||
if (resultText) {
|
||||
content = content.replace(match, resultText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ function detailsTokenizer(src: string) {
|
||||
}
|
||||
|
||||
function detailsStart(src: string) {
|
||||
return src.match(/^<details>/) ? 0 : -1;
|
||||
return src.match(/^<details[\s>]/) ? 0 : -1;
|
||||
}
|
||||
|
||||
function detailsRenderer(token: any) {
|
||||
|
||||
Reference in New Issue
Block a user