Spaces:
Running
Running
fix(tools): make show output button work
Browse files
src/lib/components/chat/ToolUpdate.svelte
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
} from "$lib/utils/messageUpdates";
|
8 |
|
9 |
import CarbonTools from "~icons/carbon/tools";
|
10 |
-
import type
|
11 |
import { page } from "$app/stores";
|
12 |
import { onMount } from "svelte";
|
13 |
import { browser } from "$app/environment";
|
@@ -130,6 +130,23 @@
|
|
130 |
<div class="h-px flex-1 bg-gradient-to-r from-gray-500/20" />
|
131 |
</div>
|
132 |
<p class="text-sm">{toolUpdate.message}</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
{/if}
|
134 |
{/each}
|
135 |
</details>
|
|
|
7 |
} from "$lib/utils/messageUpdates";
|
8 |
|
9 |
import CarbonTools from "~icons/carbon/tools";
|
10 |
+
import { ToolResultStatus, type ToolFront } from "$lib/types/Tool";
|
11 |
import { page } from "$app/stores";
|
12 |
import { onMount } from "svelte";
|
13 |
import { browser } from "$app/environment";
|
|
|
130 |
<div class="h-px flex-1 bg-gradient-to-r from-gray-500/20" />
|
131 |
</div>
|
132 |
<p class="text-sm">{toolUpdate.message}</p>
|
133 |
+
{:else if isMessageToolResultUpdate(toolUpdate) && toolUpdate.result.status === ToolResultStatus.Success && toolUpdate.result.display}
|
134 |
+
<div class="mt-1 flex items-center gap-2 opacity-80">
|
135 |
+
<h3 class="text-sm">Result</h3>
|
136 |
+
<div class="h-px flex-1 bg-gradient-to-r from-gray-500/20" />
|
137 |
+
</div>
|
138 |
+
<ul class="py-1 text-sm">
|
139 |
+
{#each toolUpdate.result.outputs as output}
|
140 |
+
{#each Object.entries(output) as [k, v]}
|
141 |
+
{#if v !== null}
|
142 |
+
<li>
|
143 |
+
<span class="font-semibold">{k}</span>:
|
144 |
+
<span>{v}</span>
|
145 |
+
</li>
|
146 |
+
{/if}
|
147 |
+
{/each}
|
148 |
+
{/each}
|
149 |
+
</ul>
|
150 |
{/if}
|
151 |
{/each}
|
152 |
</details>
|
src/lib/server/textGeneration/tools.ts
CHANGED
@@ -76,7 +76,7 @@ async function* callTool(
|
|
76 |
type: MessageUpdateType.Tool,
|
77 |
subtype: MessageToolUpdateType.Result,
|
78 |
uuid,
|
79 |
-
result: { ...toolResult, call
|
80 |
};
|
81 |
|
82 |
MetricsServer.getMetrics().tool.toolUseDuration.observe(
|
@@ -86,7 +86,7 @@ async function* callTool(
|
|
86 |
|
87 |
await collections.tools.findOneAndUpdate({ _id: tool._id }, { $inc: { useCount: 1 } });
|
88 |
|
89 |
-
return { ...toolResult, call
|
90 |
} catch (error) {
|
91 |
MetricsServer.getMetrics().tool.toolUseCountError.inc({ tool: call.name });
|
92 |
logger.error(error, `Failed while running tool ${call.name}. ${stringifyError(error)}`);
|
|
|
76 |
type: MessageUpdateType.Tool,
|
77 |
subtype: MessageToolUpdateType.Result,
|
78 |
uuid,
|
79 |
+
result: { ...toolResult, call, status: ToolResultStatus.Success },
|
80 |
};
|
81 |
|
82 |
MetricsServer.getMetrics().tool.toolUseDuration.observe(
|
|
|
86 |
|
87 |
await collections.tools.findOneAndUpdate({ _id: tool._id }, { $inc: { useCount: 1 } });
|
88 |
|
89 |
+
return { ...toolResult, call, status: ToolResultStatus.Success };
|
90 |
} catch (error) {
|
91 |
MetricsServer.getMetrics().tool.toolUseCountError.inc({ tool: call.name });
|
92 |
logger.error(error, `Failed while running tool ${call.name}. ${stringifyError(error)}`);
|
src/lib/server/tools/index.ts
CHANGED
@@ -233,7 +233,10 @@ export function getCallMethod(tool: Omit<BaseTool, "call">): BackendCall {
|
|
233 |
outputs[tool.outputComponentIdx] !== undefined &&
|
234 |
typeof outputs[tool.outputComponentIdx] !== "object"
|
235 |
) {
|
236 |
-
return {
|
|
|
|
|
|
|
237 |
}
|
238 |
|
239 |
await Promise.all(
|
|
|
233 |
outputs[tool.outputComponentIdx] !== undefined &&
|
234 |
typeof outputs[tool.outputComponentIdx] !== "object"
|
235 |
) {
|
236 |
+
return {
|
237 |
+
outputs: [{ [tool.name + "-0"]: outputs[tool.outputComponentIdx] }],
|
238 |
+
display: tool.showOutput,
|
239 |
+
};
|
240 |
}
|
241 |
|
242 |
await Promise.all(
|