chat completion, testing

# What does this PR do?


## Test Plan
# What does this PR do?


## Test Plan
This commit is contained in:
Eric Huang 2025-05-22 21:44:14 -07:00
parent 8feb1827c8
commit ecd8f2113a
27 changed files with 6729 additions and 38 deletions

View file

@ -0,0 +1,33 @@
/**
* Formats a tool_call object into a string representation.
* Example: "functionName(argumentsString)"
* @param toolCall The tool_call object, expected to have a `function` property
* with `name` and `arguments`.
* @returns A formatted string or an empty string if data is malformed.
*/
export function formatToolCallToString(toolCall: any): string {
if (
!toolCall ||
!toolCall.function ||
typeof toolCall.function.name !== "string" ||
toolCall.function.arguments === undefined
) {
return "";
}
const name = toolCall.function.name;
const args = toolCall.function.arguments;
let argsString: string;
if (typeof args === "string") {
argsString = args;
} else {
try {
argsString = JSON.stringify(args);
} catch (error) {
return "";
}
}
return `${name}(${argsString})`;
}