mirror of
https://github.com/enricoros/big-AGI.git
synced 2026-05-10 21:50:14 -07:00
AIX: Anthropic: trace bash_code_execution ops
This commit is contained in:
@@ -397,8 +397,9 @@ export function createAnthropicMessageParser(): ChatGenerateParseFunction {
|
||||
if (stoppedBlock.input)
|
||||
try {
|
||||
const input = typeof stoppedBlock.input === 'string' ? JSON.parse(stoppedBlock.input) : stoppedBlock.input;
|
||||
if (typeof input === 'object' && typeof input.code === 'string')
|
||||
iTexts = [_ellipsizeContext(input.code)];
|
||||
const codeOrCommandText = typeof input === 'object' ? (typeof input.code === 'string' ? input.code : typeof input.command === 'string' ? input.command : undefined) : undefined;
|
||||
if (codeOrCommandText)
|
||||
iTexts = [_ellipsizeContext(codeOrCommandText)];
|
||||
} catch { /* ignore parse errors */ }
|
||||
const execText = stoppedBlock.name === 'bash_code_execution' ? 'Executing bash script...' : 'Executing code...';
|
||||
pt.sendOperationState('code-exec', execText, { opId: stoppedBlock.id, ...iTexts && { iTexts } });
|
||||
@@ -826,7 +827,12 @@ function _handleCBS_BashCodeExecutionToolResult(pt: IParticleTransmitter, block:
|
||||
const opId = block.tool_use_id;
|
||||
switch (block.content.type) {
|
||||
case 'bash_code_execution_result':
|
||||
pt.sendOperationState('code-exec', 'Bash executed', { opId, state: 'done' });
|
||||
const oTexts: string[] = [];
|
||||
if (block.content.stdout)
|
||||
oTexts.push(_ellipsizeContext(block.content.stdout));
|
||||
if (block.content.stderr)
|
||||
oTexts.push('stderr: ' + _ellipsizeContext(block.content.stderr));
|
||||
pt.sendOperationState('code-exec', 'Bash executed', { opId, state: 'done', ...oTexts.length ? { oTexts } : undefined });
|
||||
|
||||
// add text if there are generated files in content array
|
||||
const fileIds: string[] = [];
|
||||
|
||||
@@ -274,7 +274,9 @@ export namespace AnthropicWire_Blocks {
|
||||
input: z.union([
|
||||
z.object({ query: z.string() }), // web_search
|
||||
z.object({ url: z.string() }), // web_fetch
|
||||
z.object({ code: z.string() }), // code_execution, bash_code_execution, text_editor_code_execution
|
||||
z.object({ code: z.string() }), // code_execution
|
||||
z.object({ command: z.string() }), // bash_code_execution
|
||||
// we don't know about the text_editor_code_execution and others
|
||||
]).or(z.any()), // see the comment on ToolUseBlock_schema.input
|
||||
caller: _ToolUseCaller_schema.optional(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user