Spaces:
Sleeping
Sleeping
Kelig
Kelig LEFEUVRE
commited on
Add `toolId` to ToolCall and use it in tool results (#1787)
Browse files* Add `toolId` to ToolCall and use it in tool results
* Make `toolId` optional in ToolCall interface
---------
Co-authored-by: Kelig LEFEUVRE <klefeuvre@alpes-controles.fr>
src/lib/server/endpoints/openai/endpointOai.ts
CHANGED
|
@@ -227,7 +227,7 @@ export async function endpointOai(
|
|
| 227 |
const responses: Array<OpenAI.Chat.Completions.ChatCompletionToolMessageParam> = [];
|
| 228 |
|
| 229 |
for (const result of toolResults) {
|
| 230 |
-
const id = uuidv4();
|
| 231 |
|
| 232 |
const toolCallResult: OpenAI.Chat.Completions.ChatCompletionMessageToolCall = {
|
| 233 |
type: "function",
|
|
|
|
| 227 |
const responses: Array<OpenAI.Chat.Completions.ChatCompletionToolMessageParam> = [];
|
| 228 |
|
| 229 |
for (const result of toolResults) {
|
| 230 |
+
const id = result?.call?.toolId || uuidv4();
|
| 231 |
|
| 232 |
const toolCallResult: OpenAI.Chat.Completions.ChatCompletionMessageToolCall = {
|
| 233 |
type: "function",
|
src/lib/server/endpoints/openai/openAIChatToTextGenerationStream.ts
CHANGED
|
@@ -115,6 +115,7 @@ export async function* openAIChatToTextGenerationStream(
|
|
| 115 |
toolCall: {
|
| 116 |
name: tool.function.name,
|
| 117 |
parameters: {},
|
|
|
|
| 118 |
},
|
| 119 |
parameterJsonString: "",
|
| 120 |
};
|
|
|
|
| 115 |
toolCall: {
|
| 116 |
name: tool.function.name,
|
| 117 |
parameters: {},
|
| 118 |
+
toolId: tool.id,
|
| 119 |
},
|
| 120 |
parameterJsonString: "",
|
| 121 |
};
|
src/lib/types/Tool.ts
CHANGED
|
@@ -178,6 +178,7 @@ export type ToolResult = ToolResultSuccess | ToolResultError;
|
|
| 178 |
export interface ToolCall {
|
| 179 |
name: string;
|
| 180 |
parameters: Record<string, string | number | boolean>;
|
|
|
|
| 181 |
}
|
| 182 |
|
| 183 |
export type BackendCall = (
|
|
|
|
| 178 |
export interface ToolCall {
|
| 179 |
name: string;
|
| 180 |
parameters: Record<string, string | number | boolean>;
|
| 181 |
+
toolId?: string;
|
| 182 |
}
|
| 183 |
|
| 184 |
export type BackendCall = (
|