@ elsikora/ ai- core (韩语)
ElsiKora软件包和CLI的统一AI运行时间.
这个软件包提供了什么
- 单一适配器供跨供应商生成.
profile基于模块的运行时间配置模式.- 第一次设置的互动配置向导 .
- 类型配置准备合同(
inspectProfile, (中文(简体) ),ensureProfile) (中文(简体) ). - 丢失或无效配置状态的失速输入出错 .
安装
npm install @elsikora/ai-core
配置
创建 .elsikora/ai-core.config.js 在您的项目中 :
export default {
modules: {
"your-module-id": {
model: "gpt-4o",
provider: "openai",
reasoning: {
effort: "medium",
},
responseFormat: {
isStrict: true,
name: "commit_message",
schema: {
type: "object",
properties: {
message: { type: "string" },
},
required: ["message"],
},
type: "json_schema",
},
retries: 3,
shouldRepromptCredentialOnAuthenticationFailure: true,
shouldUseParallelToolCalls: true,
validationRetries: 3,
},
},
};
全权证书由提供方通过环境变量解决(例如: OPENAI_API_KEY) (中文(简体) ).
运行时生成选项
配置和直接生成请求接受提供者中性控制,例如 maxTokens, (中文(简体) ), temperature, (中文(简体) ), topP, (中文(简体) ), topK, (中文(简体) ), seed, (中文(简体) ), stopSequences, (中文(简体) ), timeoutMs, (中文(简体) ), reasoning, (中文(简体) ), responseFormat, (中文(简体) ), tools, (中文(简体) ), toolChoice, (中文(简体) ), shouldUseParallelToolCalls,以及 shouldRepromptCredentialOnAuthenticationFailure。 。 。 .
设定 shouldRepromptCredentialOnAuthenticationFailure: true 当交互式CLI要求替换证书时,如果当前运行时间证书,包括从环境中解决的证书,被提供者拒绝.
提供方特定选项 providerOptions 并且只绘制在基础设施适配器内。 实例包括 OpenAI apiMode, (中文(简体) ), serviceTier, (中文(简体) ), textVerbosity,以及 shouldStore; 安东尼 speed, (中文(简体) ), serviceTier,以及 thinking; 谷歌 thinkingConfig; AWS Bedrock guardrail和性能选项; Cerebras 推理/日志选项; Ollama 推理控制; Vercel AI Gateway 提供者选项.
公共适配器 API
import { AiCoreAdapter, EGenerateMode } from "@elsikora/ai-core";
const adapter = AiCoreAdapter.create();
const inspection = await adapter.inspectProfile("your-module-id");
const profile = await adapter.ensureProfile("your-module-id");
const result = await adapter.generate({
mode: EGenerateMode.PROFILE,
moduleId: "your-module-id",
prompt: "Generate a concise commit message",
});
配置准备行为
inspectProfile(moduleId)从未提示并返回已键入状态 :readymissing_profilemissing_credentialinvalid_profile
ensureProfile(moduleId)应用划线:- 缺少配置 + TTY - > 运行完整的交互式配置
- 缺少证书 + TTY - > 仅是快速证书
- 非 TTY 缺失状态 - > 已键入
ProfileResolutionError
输入配置文件出错
ProfileResolutionError 揭露:
code数字 :missing_profile|missing_credential|invalid_profilemoduleIdprovider(当知道时)environmentVariableName(当知道时)
校验脚本
npm run validate:fastnpm run validate:prnpm run validate:heavy