@genkit-ai/compat-oai
Version:
Genkit AI framework plugin for OpenAI APIs.
1 lines • 2.36 kB
Source Map (JSON)
{"version":3,"sources":["../../src/openai/embedder.ts"],"sourcesContent":["/**\n * Copyright 2024 The Fire Company\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// import { defineEmbedder, embedderRef } from '@genkit-ai/ai/embedder';\n\nimport { EmbedderInfo, embedderRef, EmbedderReference, z } from 'genkit';\n\nexport const TextEmbeddingConfigSchema = z.object({\n dimensions: z.number().optional(),\n encodingFormat: z.union([z.literal('float'), z.literal('base64')]).optional(),\n});\n\nconst COMMON_EMBEDDER_INFO: EmbedderInfo = {\n dimensions: 1536,\n supports: {\n input: ['text'],\n },\n};\n\nfunction commonRef(\n name: string,\n info?: EmbedderInfo\n): EmbedderReference<typeof TextEmbeddingConfigSchema> {\n return embedderRef({\n name,\n configSchema: TextEmbeddingConfigSchema,\n info: {\n ...COMMON_EMBEDDER_INFO,\n ...(info ?? {}),\n },\n });\n}\n\nexport const SUPPORTED_EMBEDDING_MODELS = {\n 'text-embedding-3-small': commonRef('openai/text-embedding-3-small'),\n 'text-embedding-3-large': commonRef('openai/text-embedding-3-large', {\n dimensions: 3072,\n }),\n 'text-embedding-ada-002': commonRef('openai/text-embedding-ada-002'),\n};\n"],"mappings":"AAmBA,SAAuB,aAAgC,SAAS;AAEzD,MAAM,4BAA4B,EAAE,OAAO;AAAA,EAChD,YAAY,EAAE,OAAO,EAAE,SAAS;AAAA,EAChC,gBAAgB,EAAE,MAAM,CAAC,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,QAAQ,CAAC,CAAC,EAAE,SAAS;AAC9E,CAAC;AAED,MAAM,uBAAqC;AAAA,EACzC,YAAY;AAAA,EACZ,UAAU;AAAA,IACR,OAAO,CAAC,MAAM;AAAA,EAChB;AACF;AAEA,SAAS,UACP,MACA,MACqD;AACrD,SAAO,YAAY;AAAA,IACjB;AAAA,IACA,cAAc;AAAA,IACd,MAAM;AAAA,MACJ,GAAG;AAAA,MACH,GAAI,QAAQ,CAAC;AAAA,IACf;AAAA,EACF,CAAC;AACH;AAEO,MAAM,6BAA6B;AAAA,EACxC,0BAA0B,UAAU,+BAA+B;AAAA,EACnE,0BAA0B,UAAU,iCAAiC;AAAA,IACnE,YAAY;AAAA,EACd,CAAC;AAAA,EACD,0BAA0B,UAAU,+BAA+B;AACrE;","names":[]}