( modelId: string, reqPayload: z.infer<typeof chatCompletionInputReqPayload>, )
| 28 | } |
| 29 | |
| 30 | export function hashRequest( |
| 31 | modelId: string, |
| 32 | reqPayload: z.infer<typeof chatCompletionInputReqPayload>, |
| 33 | ): string { |
| 34 | const obj = { |
| 35 | modelId, |
| 36 | messages: reqPayload.messages, |
| 37 | function_call: reqPayload.function_call, |
| 38 | functions: reqPayload.functions, |
| 39 | tool_choice: reqPayload.tool_choice, |
| 40 | tools: reqPayload.tools, |
| 41 | max_tokens: reqPayload.max_tokens, |
| 42 | response_format: reqPayload.response_format, |
| 43 | }; |
| 44 | return hashObject(obj as JsonValue); |
| 45 | } |
| 46 | |
| 47 | export default function hashObject(obj: JsonValue): string { |
| 48 | // Sort object keys recursively |
no test coverage detected