{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Copyright 2024 Bloom Labs Inc\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\nimport type { Genkit } from 'genkit';\nimport { genkitPlugin } from 'genkit/plugin';\nimport { CohereClient } from 'cohere-ai';\n\nimport {\n  cohereEmbedder,\n  SUPPORTED_EMBEDDING_MODELS,\n  embedMultilingual4,\n} from './embedder';\nimport { commandModel, SUPPORTED_COMMAND_MODELS } from './command';\n\nexport {\n  command,\n  commandLight,\n  commandR,\n  commandRPlus,\n  commandA,\n} from './command';\nexport {\n  embedMultilingual4,\n  embedEnglish3,\n  embedEnglishLight3,\n  embedMultilingual3,\n  embedMultilingualLight3,\n} from './embedder';\nexport interface PluginOptions {\n  apiKey?: string;\n}\n\nexport const cohere = (options?: PluginOptions) =>\n  genkitPlugin('cohere', async (ai: Genkit) => {\n    let apiKey = options?.apiKey || process.env.COHERE_API_KEY;\n    if (!apiKey)\n      throw new Error(\n        'Please pass in the API key or set the COHERE_API_KEY environment variable'\n      );\n    const client = new CohereClient({ token: apiKey });\n\n    for (const name of Object.keys(SUPPORTED_COMMAND_MODELS)) {\n      commandModel(ai, name, client);\n    }\n\n    for (const name of Object.keys(SUPPORTED_EMBEDDING_MODELS)) {\n      cohereEmbedder(ai, name, options);\n    }\n  });\n\nexport default cohere;\n"],"mappings":";;;AAiBA,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAE7B;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,cAAc,gCAAgC;AAEvD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE,sBAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAKA,MAAM,SAAS,CAAC,YACrB,aAAa,UAAU,CAAO,OAAe;AAC3C,MAAI,UAAS,mCAAS,WAAU,QAAQ,IAAI;AAC5C,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,QAAM,SAAS,IAAI,aAAa,EAAE,OAAO,OAAO,CAAC;AAEjD,aAAW,QAAQ,OAAO,KAAK,wBAAwB,GAAG;AACxD,iBAAa,IAAI,MAAM,MAAM;AAAA,EAC/B;AAEA,aAAW,QAAQ,OAAO,KAAK,0BAA0B,GAAG;AAC1D,mBAAe,IAAI,MAAM,OAAO;AAAA,EAClC;AACF,EAAC;AAEH,IAAO,cAAQ;","names":["embedMultilingual4"]}