Skip to content

Commit

Permalink
Fix tool call prompt text replacement
Browse files Browse the repository at this point in the history
fixed #14829

Signed-off-by: Jonas Helming <[email protected]>
  • Loading branch information
JonasHelming committed Feb 4, 2025
1 parent b752ea6 commit 2ee2d30
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions packages/ai-core/src/common/language-model-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,4 @@ export const getJsonOfText = (text: string): unknown => {
throw new Error('Invalid response format');
};

export const toolRequestToPromptText = (toolRequest: ToolRequest): string => {
const parameters = toolRequest.parameters;
let paramsText = '';
// parameters are supposed to be as a JSON schema. Thus, derive the parameters from its properties definition
if (parameters) {
const properties = parameters.properties;
paramsText = Object.keys(properties)
.map(key => {
const param = properties[key];
return `${key}: ${param.type}`;
})
.join(', ');
}
const descriptionText = toolRequest.description
? `: ${toolRequest.description}`
: '';
return `You can call function: ${toolRequest.id}(${paramsText})${descriptionText}`;
};
export const toolRequestToPromptText = (toolRequest: ToolRequest): string => `${toolRequest.id}`;

0 comments on commit 2ee2d30

Please sign in to comment.