From db5744bbc4bd0915447c28e26621ad252b1f8986 Mon Sep 17 00:00:00 2001
From: Frank
{modifiedPart.text}
+ {hasMoreLines && !expandedSystemMessage() && (
+
- {part.text}
+
+
+ part.type !== "step-start",
+ )}
+ >
+ {(part) => {
+ if (part.type === "text") {
+ //{
+ // "type": "text",
+ // "text": "Hello! How can I help you today?"
+ //}
+ return (
+
+ [{part.type}] {part.text}{" "}
- ) : (
+ )
+ }
+ if (part.type === "reasoning") {
+ //{
+ // "type": "reasoning",
+ // "text": "The user asked for a weather forecast. I should call the 'getWeather' tool with the location 'San Francisco'.",
+ // "providerMetadata": { "step_id": "reason_step_1" }
+ //}
+ return (
+
+ [{part.type}] {part.text}
+
+ )
+ }
+ if (part.type === "tool-invocation") {
+ return (
-
- Part type: {part.type}
-
-
- {JSON.stringify(part, null, 2)}
-
+
+
+ [{part.type}]
+ {" "}
+ Tool:{" "}
+
+ {part.toolInvocation.toolName}
+
+
+ {parsed.metadata?.tool?.[
+ part.toolInvocation.toolCallId
+ ]?.time?.start &&
+ parsed.metadata?.tool?.[
+ part.toolInvocation.toolCallId
+ ]?.time?.end && (
+
+ {(
+ (new Date(
+ parsed.metadata?.tool?.[
+ part.toolInvocation.toolCallId
+ ].time.end,
+ ) -
+ new Date(
+ parsed.metadata?.tool?.[
+ part.toolInvocation.toolCallId
+ ].time.start,
+ )) /
+ 1000
+ ).toFixed(2)}
+ s
+
+ )}
+
+ {(() => {
+ if (
+ part.toolInvocation.state ===
+ "partial-call"
+ ) {
+ //{
+ // "type": "tool-invocation",
+ // "toolInvocation": {
+ // "state": "partial-call",
+ // "toolCallId": "tool_abc123",
+ // "toolName": "searchWeb",
+ // "argsTextDelta": "{\"query\":\"latest AI news"
+ // }
+ //}
+ return (
+ <>
+
+ {
+ part.toolInvocation
+ .argsTextDelta
+ }
+
+ ...
+ >
+ )
+ }
+ if (
+ part.toolInvocation.state ===
+ "call"
+ ) {
+ //{
+ // "type": "tool-invocation",
+ // "toolInvocation": {
+ // "state": "call",
+ // "toolCallId": "tool_abc123",
+ // "toolName": "searchWeb",
+ // "args": { "query": "latest AI news", "count": 3 }
+ // }
+ //}
+ return (
+
+ {JSON.stringify(
+ part.toolInvocation.args,
+ null,
+ 2,
+ )}
+
+ )
+ }
+ if (
+ part.toolInvocation.state ===
+ "result"
+ ) {
+ //{
+ // "type": "tool-invocation",
+ // "toolInvocation": {
+ // "state": "result",
+ // "toolCallId": "tool_abc123",
+ // "toolName": "searchWeb",
+ // "args": { "query": "latest AI news", "count": 3 },
+ // "result": [
+ // { "title": "AI SDK v5 Announced", "url": "..." },
+ // { "title": "New LLM Achieves SOTA", "url": "..." }
+ // ]
+ // }
+ //}
+ return (
+ <>
+
+ {JSON.stringify(
+ part.toolInvocation
+ .args,
+ null,
+ 2,
+ )}
+
+
+ {JSON.stringify(
+ part.toolInvocation
+ .result,
+ null,
+ 2,
+ )}
+
+ >
+ )
+ }
+ if (
+ part.toolInvocation.state ===
+ "error"
+ ) {
+ //{
+ // "type": "tool-invocation",
+ // "toolInvocation": {
+ // "state": "error",
+ // "toolCallId": "tool_abc123",
+ // "toolName": "searchWeb",
+ // "args": { "query": "latest AI news", "count": 3 },
+ // "errorMessage": "API limit exceeded for searchWeb tool."
+ // }
+ //}
+ return (
+ <>
+
+ {JSON.stringify(
+ part.toolInvocation
+ .args,
+ null,
+ 2,
+ )}
+
+
+ {
+ part.toolInvocation
+ .errorMessage
+ }
+
+ >
+ )
+ }
+ })()}
- )}
- [{part.type}]
+
+
+ Source:{" "}
+ {part.source.title ||
+ part.source.id}
+
+ [{part.type}]
+
+ File: {part.filename}
+ {part.mediaType}
+