workers-ai-provider 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
2
+ import { z } from "zod";
3
+
4
+ const workersAIErrorDataSchema = z.object({
5
+ object: z.literal("error"),
6
+ message: z.string(),
7
+ type: z.string(),
8
+ param: z.string().nullable(),
9
+ code: z.string().nullable(),
10
+ });
11
+
12
+ export type WorkersAIErrorData = z.infer<typeof workersAIErrorDataSchema>;
13
+
14
+ export const workersAIFailedResponseHandler = createJsonErrorResponseHandler({
15
+ errorSchema: workersAIErrorDataSchema,
16
+ errorToMessage: (data) => data.message,
17
+ });