@gensx/vercel-ai-sdk
Version:
Vercel AI SDK for GenSX.
1 lines • 3.18 kB
Source Map (JSON)
{"version":3,"file":"index.cjs","sources":["@gensx/vercel-ai-sdk/../../../../src/index.tsx"],"sourcesContent":["import type { z } from \"zod\";\n\nimport * as gensx from \"@gensx/core\";\nimport { GsxComponent } from \"@gensx/core\";\nimport * as ai from \"ai\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function createGSXComponent<TFn extends (...args: any[]) => any>(\n name: string,\n fn: TFn,\n) {\n return gensx.Component<Parameters<TFn>[0], Awaited<ReturnType<TFn>>>(\n name,\n fn,\n );\n}\n\n// Define a more specific type for StreamObject that allows schema\ntype StreamObjectType = gensx.GsxComponent<\n // Make output optional and allow schema\n Omit<Parameters<typeof ai.streamObject>[0], \"output\"> & {\n output?: \"object\" | \"array\" | \"no-schema\";\n\n schema?: z.ZodType | { _type: unknown };\n },\n Awaited<ReturnType<typeof ai.streamObject>>\n>;\n\n// Cast to the more specific type\nexport const StreamObject = createGSXComponent(\n \"StreamObject\",\n ai.streamObject,\n) as StreamObjectType;\n\nexport const StreamText: GsxComponent<\n Parameters<typeof ai.streamText>[0],\n Awaited<ReturnType<typeof ai.streamText>>\n> = createGSXComponent(\"StreamText\", ai.streamText);\n\nexport const GenerateText: GsxComponent<\n Parameters<typeof ai.generateText>[0],\n Awaited<ReturnType<typeof ai.generateText>>\n> = createGSXComponent(\"GenerateText\", ai.generateText);\n\n// Define a more specific type for GenerateObject that allows schema\ntype GenerateObjectType = GsxComponent<\n // Make output optional and allow schema\n Omit<Parameters<typeof ai.generateObject>[0], \"output\"> & {\n output?: \"object\" | \"array\" | \"no-schema\";\n\n schema?: z.ZodType | { _type: unknown };\n },\n Awaited<ReturnType<typeof ai.generateObject>>\n>;\n\n// Cast to the more specific type\nexport const GenerateObject = createGSXComponent(\n \"GenerateObject\",\n ai.generateObject,\n) as GenerateObjectType;\n\nexport const Embed: GsxComponent<\n Parameters<typeof ai.embed>[0],\n Awaited<ReturnType<typeof ai.embed>>\n> = createGSXComponent(\"Embed\", ai.embed);\n\nexport const EmbedMany: GsxComponent<\n Parameters<typeof ai.embedMany>[0],\n Awaited<ReturnType<typeof ai.embedMany>>\n> = createGSXComponent(\"EmbedMany\", ai.embedMany);\n\nexport const GenerateImage: GsxComponent<\n Parameters<typeof ai.experimental_generateImage>[0],\n Awaited<ReturnType<typeof ai.experimental_generateImage>>\n> = createGSXComponent(\"GenerateImage\", ai.experimental_generateImage);\n"],"names":["gensx","ai"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;AACgB,SAAA,kBAAkB,CAChC,IAAY,EACZ,EAAO,EAAA;IAEP,OAAOA,gBAAK,CAAC,SAAS,CACpB,IAAI,EACJ,EAAE,CACH;AACH;AAaA;AACO,MAAM,YAAY,GAAG,kBAAkB,CAC5C,cAAc,EACdC,aAAE,CAAC,YAAY;AAGV,MAAM,UAAU,GAGnB,kBAAkB,CAAC,YAAY,EAAEA,aAAE,CAAC,UAAU;AAE3C,MAAM,YAAY,GAGrB,kBAAkB,CAAC,cAAc,EAAEA,aAAE,CAAC,YAAY;AAatD;AACO,MAAM,cAAc,GAAG,kBAAkB,CAC9C,gBAAgB,EAChBA,aAAE,CAAC,cAAc;AAGZ,MAAM,KAAK,GAGd,kBAAkB,CAAC,OAAO,EAAEA,aAAE,CAAC,KAAK;AAEjC,MAAM,SAAS,GAGlB,kBAAkB,CAAC,WAAW,EAAEA,aAAE,CAAC,SAAS;AAEzC,MAAM,aAAa,GAGtB,kBAAkB,CAAC,eAAe,EAAEA,aAAE,CAAC,0BAA0B;;;;;;;;;;;"}