Skip to content

Commit 043a5de

Browse files
authoredJun 5, 2024··
fix (provider-utils): rename to isParsableJson (#1837)
1 parent 9ec1cf0 commit 043a5de

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed
 

‎.changeset/silent-turkeys-leave.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@ai-sdk/provider-utils': patch
3+
---
4+
5+
fix (provider-utils): rename to isParsableJson

‎packages/openai/src/openai-chat-language-model.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
createEventSourceResponseHandler,
1212
createJsonResponseHandler,
1313
generateId,
14-
isParseableJson,
14+
isParsableJson,
1515
postJsonToApi,
1616
} from '@ai-sdk/provider-utils';
1717
import { z } from 'zod';
@@ -338,7 +338,7 @@ export class OpenAIChatLanguageModel implements LanguageModelV1 {
338338
if (
339339
toolCall.function?.name == null ||
340340
toolCall.function?.arguments == null ||
341-
!isParseableJson(toolCall.function.arguments)
341+
!isParsableJson(toolCall.function.arguments)
342342
) {
343343
continue;
344344
}

‎packages/provider-utils/src/parse-json.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,16 @@ export function safeParseJSON<T>({
108108
}
109109
}
110110

111-
export function isParseableJson(input: string): boolean {
111+
export function isParsableJson(input: string): boolean {
112112
try {
113113
SecureJSON.parse(input);
114114
return true;
115115
} catch {
116116
return false;
117117
}
118118
}
119+
120+
/**
121+
@deprecated Use `isParsableJson` instead.
122+
*/
123+
export const isParseableJson = isParsableJson;

0 commit comments

Comments
 (0)
Please sign in to comment.