Skip to content

Commit

Permalink
fix: fix tool response being read repeatedly.
Browse files Browse the repository at this point in the history
  • Loading branch information
adolphnov committed Nov 28, 2024
1 parent 3e3a631 commit 3602647
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/tools/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,10 @@ export function executeTool(toolName: string) {
if (!result.ok) {
throw new Error(`Tool call error: ${result.statusText}}`);
}
const contentType = await result.headers.get('content-type');
if (contentType?.includes('json')) {
result = await result.json();
} else {
try {
result = await result.json();
} catch (e) {
result = await result.text();
}
try {
result = await result.clone().json();
} catch (e) {
result = await result.text();
}

const middleHandler = async (data: any) => {
Expand Down

0 comments on commit 3602647

Please sign in to comment.