Skip to content

Commit 02fe01f

Browse files
committed
Improve detection of embedding requests
1 parent 90359e4 commit 02fe01f

File tree

1 file changed

+7
-4
lines changed
  • packages/core/src/tracing/openai

1 file changed

+7
-4
lines changed

packages/core/src/tracing/openai/utils.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,14 @@ export function isResponsesApiResponse(response: unknown): response is OpenAIRes
9090
* Check if response is an Embeddings API object
9191
*/
9292
export function isEmbeddingsResponse(response: unknown): response is OpenAICreateEmbeddingsObject {
93+
if (response === null || typeof response !== 'object' || !('object' in response)) {
94+
return false;
95+
}
96+
const responseObject = response as Record<string, unknown>;
9397
return (
94-
response !== null &&
95-
typeof response === 'object' &&
96-
'object' in response &&
97-
(response as Record<string, unknown>).object === 'list'
98+
responseObject.object === 'list' &&
99+
typeof responseObject.model === 'string' &&
100+
(responseObject.model as string).toLowerCase().includes('embedding')
98101
);
99102
}
100103

0 commit comments

Comments
 (0)