MCPcopy Index your code
hub / github.com/OpenPipe/OpenPipe / sortKeys

Function sortKeys

app/src/server/utils/hashObject.ts:7–28  ·  view source on GitHub ↗
(obj: JsonValue)

Source from the content-addressed store, hash-verified

5import { type chatCompletionInputReqPayload } from "~/types/shared.types";
6
7function sortKeys(obj: JsonValue): JsonValue {
8 if (typeof obj !== "object" || obj === null) {
9 // Not an object or array, return as is
10 return obj;
11 }
12
13 if (Array.isArray(obj)) {
14 return obj.map(sortKeys);
15 }
16
17 // Get keys and sort them
18 const keys = Object.keys(obj).sort();
19 const sortedObj = {};
20
21 for (const key of keys) {
22 // @ts-expect-error not worth fixing types
23 // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
24 sortedObj[key] = sortKeys(obj[key]);
25 }
26
27 return sortedObj;
28}
29
30export function hashRequest(
31 modelId: string,

Callers 1

hashObjectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected