@genkit-ai/compat-oai
Version:
Genkit AI framework plugin for OpenAI APIs.
89 lines • 2.87 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var grok_exports = {};
__export(grok_exports, {
SUPPORTED_LANGUAGE_MODELS: () => SUPPORTED_LANGUAGE_MODELS,
XaiChatCompletionConfigSchema: () => XaiChatCompletionConfigSchema,
grokRequestBuilder: () => grokRequestBuilder,
xaiModelRef: () => xaiModelRef
});
module.exports = __toCommonJS(grok_exports);
var import_genkit = require("genkit");
var import_model2 = require("../model");
const XAI_LANGUGAGE_MODEL_INFO = {
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"]
}
};
const XaiChatCompletionConfigSchema = import_model2.ChatCompletionCommonConfigSchema.extend({
deferred: import_genkit.z.boolean().optional(),
reasoningEffort: import_genkit.z.enum(["low", "medium", "high"]).optional(),
webSearchOptions: import_genkit.z.object({}).passthrough().optional()
});
function xaiModelRef(params) {
return (0, import_model2.compatOaiModelRef)({
...params,
info: params.info ?? XAI_LANGUGAGE_MODEL_INFO,
configSchema: XaiChatCompletionConfigSchema
});
}
const grokRequestBuilder = (req, params) => {
const { deferred, webSearchOptions, reasoningEffort } = req.config ?? {};
params.web_search_options = webSearchOptions;
params.reasoning_effort = reasoningEffort;
params.deferred = deferred;
};
const SUPPORTED_LANGUAGE_MODELS = {
"grok-3": xaiModelRef({
name: "xai/grok-3"
}),
"grok-3-fast": xaiModelRef({
name: "xai/grok-3-fast"
}),
"grok-3-mini": xaiModelRef({
name: "xai/grok-3-mini"
}),
"grok-3-mini-fast": xaiModelRef({
name: "xai/grok-3-mini-fast"
}),
"grok-2-vision-1212": xaiModelRef({
name: "xai/grok-2-vision-1212",
info: {
supports: {
multiturn: false,
tools: true,
media: true,
systemRole: false,
output: ["text", "json"]
}
}
})
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
SUPPORTED_LANGUAGE_MODELS,
XaiChatCompletionConfigSchema,
grokRequestBuilder,
xaiModelRef
});
//# sourceMappingURL=grok.js.map