workers-ai-provider 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +21 -0
- package/README.md +56 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +614 -0
- package/dist/index.js.map +1 -0
- package/package.json +32 -0
- package/src/convert-to-workersai-chat-messages.ts +106 -0
- package/src/index.ts +62 -0
- package/src/map-workersai-finish-reason.ts +17 -0
- package/src/workersai-chat-language-model.ts +283 -0
- package/src/workersai-chat-prompt.ts +33 -0
- package/src/workersai-chat-settings.ts +8 -0
- package/src/workersai-error.ts +17 -0
@@ -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
|
+
});
|