Timothy Jaeryang Baek 3 months ago
parent
commit
100f5a57e7
1 changed files with 50 additions and 28 deletions
  1. 50 28
      src/lib/components/common/Collapsible.svelte

+ 50 - 28
src/lib/components/common/Collapsible.svelte

@@ -197,41 +197,63 @@
 		</div>
 		</div>
 	{/if}
 	{/if}
 
 
-	{#if !grow}
-		{#if open && !hide}
-			<div transition:slide={{ duration: 300, easing: quintOut, axis: 'y' }}>
-				{#if attributes?.type === 'tool_calls'}
-					{@const args = decode(attributes?.arguments)}
-					{@const result = decode(attributes?.result ?? '')}
-					{@const files = parseJSONString(decode(attributes?.files ?? ''))}
-
-					{#if attributes?.done === 'true'}
-						<Markdown
-							id={`tool-calls-${attributes?.id}-result`}
-							content={`> \`\`\`json
+	{#if attributes?.type === 'tool_calls'}
+		{@const args = decode(attributes?.arguments)}
+		{@const result = decode(attributes?.result ?? '')}
+		{@const files = parseJSONString(decode(attributes?.files ?? ''))}
+
+		{#if !grow}
+			{#if open && !hide}
+				<div transition:slide={{ duration: 300, easing: quintOut, axis: 'y' }}>
+					{#if attributes?.type === 'tool_calls'}
+						{#if attributes?.done === 'true'}
+							<Markdown
+								id={`tool-calls-${attributes?.id}-result`}
+								content={`> \`\`\`json
 > ${formatJSONString(args)}
 > ${formatJSONString(args)}
 > ${formatJSONString(result)}
 > ${formatJSONString(result)}
 > \`\`\``}
 > \`\`\``}
-						/>
-
-						{#if typeof files === 'object'}
-							{#each files ?? [] as file, idx}
-								{#if file.startsWith('data:image/')}
-									<Image id={`tool-calls-${attributes?.id}-result-${idx}`} src={file} alt="Image" />
-								{/if}
-							{/each}
-						{/if}
-					{:else}
-						<Markdown
-							id={`tool-calls-${attributes?.id}-result`}
-							content={`> \`\`\`json
+							/>
+
+							{#if typeof files === 'object'}
+								{#each files ?? [] as file, idx}
+									{#if file.startsWith('data:image/')}
+										<Image
+											id={`tool-calls-${attributes?.id}-result-${idx}`}
+											src={file}
+											alt="Image"
+										/>
+									{/if}
+								{/each}
+							{/if}
+						{:else}
+							<Markdown
+								id={`tool-calls-${attributes?.id}-result`}
+								content={`> \`\`\`json
 > ${formatJSONString(args)}
 > ${formatJSONString(args)}
 > \`\`\``}
 > \`\`\``}
-						/>
+							/>
+						{/if}
+					{:else}
+						<slot name="content" />
 					{/if}
 					{/if}
-				{:else}
-					<slot name="content" />
+				</div>
+			{/if}
+
+			{#if attributes?.done === 'true'}
+				{#if typeof files === 'object'}
+					{#each files ?? [] as file, idx}
+						{#if file.startsWith('data:image/')}
+							<Image id={`tool-calls-${attributes?.id}-result-${idx}`} src={file} alt="Image" />
+						{/if}
+					{/each}
 				{/if}
 				{/if}
+			{/if}
+		{/if}
+	{:else if !grow}
+		{#if open && !hide}
+			<div transition:slide={{ duration: 300, easing: quintOut, axis: 'y' }}>
+				<slot name="content" />
 			</div>
 			</div>
 		{/if}
 		{/if}
 	{/if}
 	{/if}