Skip to content

Commit

Permalink
fix: dont pass tools in final generation, instead deduce tools from t…
Browse files Browse the repository at this point in the history
…ool results
  • Loading branch information
nsarrazin committed Jan 3, 2025
1 parent 06a763a commit e0adc68
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/lib/server/endpoints/anthropic/endpointAnthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ export async function endpointAnthropic(
}

let tokenId = 0;
if (tools.length === 0 && toolResults.length > 0) {
const toolNames = new Set(toolResults.map((tool) => tool.call.name));
tools = Array.from(toolNames).map((name) => ({
name,
description: "",
inputs: [],
})) as unknown as Tool[];
}

const parameters = { ...model.parameters, ...generateSettings };

Expand Down
2 changes: 1 addition & 1 deletion src/lib/server/textGeneration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ async function* textGenerationWithoutTitle(
}

const processedMessages = await preprocessMessages(messages, webSearchResult, convId);
yield* generate({ ...ctx, messages: processedMessages }, toolResults, preprompt, tools);
yield* generate({ ...ctx, messages: processedMessages }, toolResults, preprompt);
done.abort();
}

0 comments on commit e0adc68

Please sign in to comment.