@genkit-ai/compat-oai 1.35.0 → 1.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/audio.mjs +1 -1
- package/lib/audio.mjs.map +1 -1
- package/lib/deepseek/deepseek.js +1 -1
- package/lib/deepseek/deepseek.js.map +1 -1
- package/lib/deepseek/deepseek.mjs +1 -1
- package/lib/deepseek/deepseek.mjs.map +1 -1
- package/lib/deepseek/index.mjs +3 -3
- package/lib/deepseek/index.mjs.map +1 -1
- package/lib/embedder.mjs +1 -1
- package/lib/embedder.mjs.map +1 -1
- package/lib/image.mjs +1 -1
- package/lib/image.mjs.map +1 -1
- package/lib/index.mjs +7 -7
- package/lib/index.mjs.map +1 -1
- package/lib/model.mjs +1 -1
- package/lib/model.mjs.map +1 -1
- package/lib/openai/dalle.js +1 -1
- package/lib/openai/dalle.js.map +1 -1
- package/lib/openai/dalle.mjs +1 -1
- package/lib/openai/dalle.mjs.map +1 -1
- package/lib/openai/gpt.js +1 -1
- package/lib/openai/gpt.js.map +1 -1
- package/lib/openai/gpt.mjs +4 -1
- package/lib/openai/gpt.mjs.map +1 -1
- package/lib/openai/index.mjs +11 -11
- package/lib/openai/index.mjs.map +1 -1
- package/lib/openai/stt.js +1 -1
- package/lib/openai/stt.js.map +1 -1
- package/lib/openai/stt.mjs +1 -1
- package/lib/openai/stt.mjs.map +1 -1
- package/lib/openai/tts.js +1 -1
- package/lib/openai/tts.js.map +1 -1
- package/lib/openai/tts.mjs +1 -1
- package/lib/openai/tts.mjs.map +1 -1
- package/lib/openai/whisper.mjs +3 -3
- package/lib/openai/whisper.mjs.map +1 -1
- package/lib/translate.mjs +1 -1
- package/lib/translate.mjs.map +1 -1
- package/lib/xai/grok-image.js +1 -1
- package/lib/xai/grok-image.js.map +1 -1
- package/lib/xai/grok-image.mjs +1 -1
- package/lib/xai/grok-image.mjs.map +1 -1
- package/lib/xai/grok.js +1 -1
- package/lib/xai/grok.js.map +1 -1
- package/lib/xai/grok.mjs +1 -1
- package/lib/xai/grok.mjs.map +1 -1
- package/lib/xai/index.mjs +5 -5
- package/lib/xai/index.mjs.map +1 -1
- package/package.json +2 -2
package/lib/xai/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/xai/index.ts"],"sourcesContent":["/**\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\nimport {\n ActionMetadata,\n GenkitError,\n modelActionMetadata,\n ModelReference,\n z,\n} from 'genkit';\nimport { logger } from 'genkit/logging';\nimport { ResolvableAction, type GenkitPluginV2 } from 'genkit/plugin';\nimport { ActionType } from 'genkit/registry';\nimport OpenAI from 'openai';\nimport {\n defineCompatOpenAIImageModel,\n ImageGenerationCommonConfigSchema,\n} from '../image.
|
|
1
|
+
{"version":3,"sources":["../../src/xai/index.ts"],"sourcesContent":["/**\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\nimport {\n ActionMetadata,\n GenkitError,\n modelActionMetadata,\n ModelReference,\n z,\n} from 'genkit';\nimport { logger } from 'genkit/logging';\nimport { ResolvableAction, type GenkitPluginV2 } from 'genkit/plugin';\nimport { ActionType } from 'genkit/registry';\nimport OpenAI from 'openai';\nimport {\n defineCompatOpenAIImageModel,\n ImageGenerationCommonConfigSchema,\n} from '../image.mjs';\nimport { openAICompatible, PluginOptions } from '../index.mjs';\nimport { defineCompatOpenAIModel } from '../model.mjs';\nimport { SUPPORTED_IMAGE_MODELS, xaiImageModelRef } from './grok-image.mjs';\nimport {\n grokRequestBuilder,\n SUPPORTED_LANGUAGE_MODELS,\n XaiChatCompletionConfigSchema,\n xaiModelRef,\n} from './grok.mjs';\n\nexport type XAIPluginOptions = Omit<PluginOptions, 'name' | 'baseURL'>;\n\nfunction createResolver(pluginOptions: PluginOptions) {\n return async (client: OpenAI, actionType: ActionType, actionName: string) => {\n if (actionType === 'model') {\n const modelRef = xaiModelRef({ name: actionName });\n return defineCompatOpenAIModel({\n name: modelRef.name,\n client,\n pluginOptions,\n modelRef,\n requestBuilder: grokRequestBuilder,\n });\n } else {\n logger.warn('Only model actions are supported by the XAI plugin');\n }\n return undefined;\n };\n}\n\nconst listActions = async (client: OpenAI): Promise<ActionMetadata[]> => {\n return await client.models.list().then((response) =>\n response.data\n .filter((model) => model.object === 'model')\n .map((model: OpenAI.Model) => {\n if (model.id.includes('image')) {\n const modelRef =\n SUPPORTED_IMAGE_MODELS[model.id] ??\n xaiImageModelRef({ name: model.id });\n return modelActionMetadata({\n name: modelRef.name,\n info: modelRef.info,\n configSchema: modelRef.configSchema,\n });\n } else {\n const modelRef =\n SUPPORTED_LANGUAGE_MODELS[model.id] ??\n xaiModelRef({ name: model.id });\n return modelActionMetadata({\n name: modelRef.name,\n info: modelRef.info,\n configSchema: modelRef.configSchema,\n });\n }\n })\n );\n};\n\nexport function xAIPlugin(options?: XAIPluginOptions): GenkitPluginV2 {\n const apiKey = options?.apiKey ?? process.env.XAI_API_KEY;\n if (!apiKey) {\n throw new GenkitError({\n status: 'FAILED_PRECONDITION',\n message:\n 'Please pass in the API key or set the XAI_API_KEY environment variable.',\n });\n }\n const pluginOptions = { name: 'xai', ...options };\n return openAICompatible({\n name: 'xai',\n baseURL: 'https://api.x.ai/v1',\n apiKey,\n ...options,\n initializer: async (client) => {\n const models = [] as ResolvableAction[];\n models.push(\n ...Object.values(SUPPORTED_LANGUAGE_MODELS).map((modelRef) =>\n defineCompatOpenAIModel({\n name: modelRef.name,\n client,\n pluginOptions,\n modelRef,\n requestBuilder: grokRequestBuilder,\n })\n )\n );\n models.push(\n ...Object.values(SUPPORTED_IMAGE_MODELS).map((modelRef) =>\n defineCompatOpenAIImageModel({\n name: modelRef.name,\n client,\n pluginOptions,\n modelRef,\n })\n )\n );\n return models;\n },\n resolver: createResolver(pluginOptions),\n listActions,\n });\n}\n\nexport type XAIPlugin = {\n (params?: XAIPluginOptions): GenkitPluginV2;\n model(\n name: keyof typeof SUPPORTED_LANGUAGE_MODELS,\n config?: z.infer<typeof XaiChatCompletionConfigSchema>\n ): ModelReference<typeof XaiChatCompletionConfigSchema>;\n model(\n name: keyof typeof SUPPORTED_IMAGE_MODELS,\n config?: z.infer<typeof ImageGenerationCommonConfigSchema>\n ): ModelReference<typeof ImageGenerationCommonConfigSchema>;\n model(name: string, config?: any): ModelReference<z.ZodTypeAny>;\n};\n\nconst model = ((name: string, config?: any): ModelReference<z.ZodTypeAny> => {\n if (name.includes('image')) {\n return xaiImageModelRef({\n name,\n config,\n });\n }\n return xaiModelRef({\n name,\n config,\n });\n}) as XAIPlugin['model'];\n\n/**\n * This module provides an interface to the XAI models through the Genkit\n * plugin system. It allows users to interact with various models by providing\n * an API key and optional configuration.\n *\n * The main export is the `xai` plugin, which can be configured with an API\n * key either directly or through environment variables. It initializes the\n * OpenAI client and makes available the models for use.\n *\n * Exports:\n * - xAI: The main plugin function to interact with XAI, via OpenAI\n * compatible API.\n *\n * Usage: To use the models, initialize the xAI plugin inside\n * `configureGenkit` and pass the configuration options. If no API key is\n * provided in the options, the environment variable `XAI_API_KEY` must be\n * set.\n *\n * Example:\n * ```\n * import { xAI } from '@genkit-ai/compat-oai/xai';\n *\n * export default configureGenkit({\n * plugins: [\n * xAI()\n * ... // other plugins\n * ]\n * });\n * ```\n */\nexport const xAI: XAIPlugin = Object.assign(xAIPlugin, {\n model,\n});\n\nexport default xAI;\n"],"mappings":"AAgBA;AAAA,EAEE;AAAA,EACA;AAAA,OAGK;AACP,SAAS,cAAc;AAIvB;AAAA,EACE;AAAA,OAEK;AACP,SAAS,wBAAuC;AAChD,SAAS,+BAA+B;AACxC,SAAS,wBAAwB,wBAAwB;AACzD;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAIP,SAAS,eAAe,eAA8B;AACpD,SAAO,OAAO,QAAgB,YAAwB,eAAuB;AAC3E,QAAI,eAAe,SAAS;AAC1B,YAAM,WAAW,YAAY,EAAE,MAAM,WAAW,CAAC;AACjD,aAAO,wBAAwB;AAAA,QAC7B,MAAM,SAAS;AAAA,QACf;AAAA,QACA;AAAA,QACA;AAAA,QACA,gBAAgB;AAAA,MAClB,CAAC;AAAA,IACH,OAAO;AACL,aAAO,KAAK,oDAAoD;AAAA,IAClE;AACA,WAAO;AAAA,EACT;AACF;AAEA,MAAM,cAAc,OAAO,WAA8C;AACvE,SAAO,MAAM,OAAO,OAAO,KAAK,EAAE;AAAA,IAAK,CAAC,aACtC,SAAS,KACN,OAAO,CAACA,WAAUA,OAAM,WAAW,OAAO,EAC1C,IAAI,CAACA,WAAwB;AAC5B,UAAIA,OAAM,GAAG,SAAS,OAAO,GAAG;AAC9B,cAAM,WACJ,uBAAuBA,OAAM,EAAE,KAC/B,iBAAiB,EAAE,MAAMA,OAAM,GAAG,CAAC;AACrC,eAAO,oBAAoB;AAAA,UACzB,MAAM,SAAS;AAAA,UACf,MAAM,SAAS;AAAA,UACf,cAAc,SAAS;AAAA,QACzB,CAAC;AAAA,MACH,OAAO;AACL,cAAM,WACJ,0BAA0BA,OAAM,EAAE,KAClC,YAAY,EAAE,MAAMA,OAAM,GAAG,CAAC;AAChC,eAAO,oBAAoB;AAAA,UACzB,MAAM,SAAS;AAAA,UACf,MAA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
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"genai",
|
|
12
12
|
"generative-ai"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.36.0",
|
|
15
15
|
"type": "commonjs",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"openai": "^4.95.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"genkit": "^1.
|
|
27
|
+
"genkit": "^1.36.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@jest/globals": "^29.7.0",
|