Merge pull request #21 from langchain-ai/brace/show-empty-tool-calls

fix: Render tool calls with no args
This commit is contained in:
Brace Sproul
2025-03-05 14:37:23 -08:00
committed by GitHub

View File

@@ -18,8 +18,7 @@ export function ToolCalls({
<div className="space-y-4"> <div className="space-y-4">
{toolCalls.map((tc, idx) => { {toolCalls.map((tc, idx) => {
const args = tc.args as Record<string, any>; const args = tc.args as Record<string, any>;
if (!tc.args || Object.keys(args).length === 0) return null; const hasArgs = Object.keys(args).length > 0;
return ( return (
<div <div
key={idx} key={idx}
@@ -35,26 +34,30 @@ export function ToolCalls({
)} )}
</h3> </h3>
</div> </div>
<table className="min-w-full divide-y divide-gray-200"> {hasArgs ? (
<tbody className="divide-y divide-gray-200"> <table className="min-w-full divide-y divide-gray-200">
{Object.entries(args).map(([key, value], argIdx) => ( <tbody className="divide-y divide-gray-200">
<tr key={argIdx}> {Object.entries(args).map(([key, value], argIdx) => (
<td className="px-4 py-2 text-sm font-medium text-gray-900 whitespace-nowrap"> <tr key={argIdx}>
{key} <td className="px-4 py-2 text-sm font-medium text-gray-900 whitespace-nowrap">
</td> {key}
<td className="px-4 py-2 text-sm text-gray-500"> </td>
{isComplexValue(value) ? ( <td className="px-4 py-2 text-sm text-gray-500">
<code className="bg-gray-50 rounded px-2 py-1 font-mono text-sm"> {isComplexValue(value) ? (
{JSON.stringify(value, null, 2)} <code className="bg-gray-50 rounded px-2 py-1 font-mono text-sm">
</code> {JSON.stringify(value, null, 2)}
) : ( </code>
String(value) ) : (
)} String(value)
</td> )}
</tr> </td>
))} </tr>
</tbody> ))}
</table> </tbody>
</table>
) : (
<code className="text-sm block p-3">{"{}"}</code>
)}
</div> </div>
); );
})} })}