@mariozechner/pi-ai 0.5.27 → 0.5.28

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.
Files changed (42) hide show
  1. package/README.md +355 -275
  2. package/dist/generate.d.ts +22 -0
  3. package/dist/generate.d.ts.map +1 -0
  4. package/dist/generate.js +204 -0
  5. package/dist/generate.js.map +1 -0
  6. package/dist/index.d.ts +7 -8
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +7 -12
  9. package/dist/index.js.map +1 -1
  10. package/dist/models.d.ts +10 -71
  11. package/dist/models.d.ts.map +1 -1
  12. package/dist/models.generated.d.ts +3056 -2659
  13. package/dist/models.generated.d.ts.map +1 -1
  14. package/dist/models.generated.js +3063 -2663
  15. package/dist/models.generated.js.map +1 -1
  16. package/dist/models.js +17 -59
  17. package/dist/models.js.map +1 -1
  18. package/dist/providers/anthropic.d.ts +5 -18
  19. package/dist/providers/anthropic.d.ts.map +1 -1
  20. package/dist/providers/anthropic.js +249 -227
  21. package/dist/providers/anthropic.js.map +1 -1
  22. package/dist/providers/google.d.ts +3 -14
  23. package/dist/providers/google.d.ts.map +1 -1
  24. package/dist/providers/google.js +215 -220
  25. package/dist/providers/google.js.map +1 -1
  26. package/dist/providers/openai-completions.d.ts +4 -14
  27. package/dist/providers/openai-completions.d.ts.map +1 -1
  28. package/dist/providers/openai-completions.js +247 -215
  29. package/dist/providers/openai-completions.js.map +1 -1
  30. package/dist/providers/openai-responses.d.ts +6 -13
  31. package/dist/providers/openai-responses.d.ts.map +1 -1
  32. package/dist/providers/openai-responses.js +242 -244
  33. package/dist/providers/openai-responses.js.map +1 -1
  34. package/dist/providers/utils.d.ts +2 -14
  35. package/dist/providers/utils.d.ts.map +1 -1
  36. package/dist/providers/utils.js +2 -15
  37. package/dist/providers/utils.js.map +1 -1
  38. package/dist/types.d.ts +39 -16
  39. package/dist/types.d.ts.map +1 -1
  40. package/dist/types.js +1 -0
  41. package/dist/types.js.map +1 -1
  42. package/package.json +1 -1
package/dist/models.js CHANGED
@@ -1,64 +1,22 @@
1
- import { PROVIDERS } from "./models.generated.js";
2
- import { AnthropicLLM } from "./providers/anthropic.js";
3
- import { GoogleLLM } from "./providers/google.js";
4
- import { OpenAICompletionsLLM } from "./providers/openai-completions.js";
5
- import { OpenAIResponsesLLM } from "./providers/openai-responses.js";
6
- // Provider configuration with factory functions
7
- export const PROVIDER_CONFIG = {
8
- google: {
9
- envKey: "GEMINI_API_KEY",
10
- create: (model, apiKey) => new GoogleLLM(model, apiKey),
11
- },
12
- openai: {
13
- envKey: "OPENAI_API_KEY",
14
- create: (model, apiKey) => new OpenAIResponsesLLM(model, apiKey),
15
- },
16
- anthropic: {
17
- envKey: "ANTHROPIC_API_KEY",
18
- create: (model, apiKey) => new AnthropicLLM(model, apiKey),
19
- },
20
- xai: {
21
- envKey: "XAI_API_KEY",
22
- create: (model, apiKey) => new OpenAICompletionsLLM(model, apiKey),
23
- },
24
- groq: {
25
- envKey: "GROQ_API_KEY",
26
- create: (model, apiKey) => new OpenAICompletionsLLM(model, apiKey),
27
- },
28
- cerebras: {
29
- envKey: "CEREBRAS_API_KEY",
30
- create: (model, apiKey) => new OpenAICompletionsLLM(model, apiKey),
31
- },
32
- openrouter: {
33
- envKey: "OPENROUTER_API_KEY",
34
- create: (model, apiKey) => new OpenAICompletionsLLM(model, apiKey),
35
- },
36
- };
37
- // Single generic factory function
38
- export function createLLM(provider, model, apiKey) {
39
- const config = PROVIDER_CONFIG[provider];
40
- if (!config)
41
- throw new Error(`Unknown provider: ${provider}`);
42
- const providerData = PROVIDERS[provider];
43
- if (!providerData)
44
- throw new Error(`Unknown provider: ${provider}`);
45
- // Type-safe model lookup
46
- const models = providerData.models;
47
- const modelData = models[model];
48
- if (!modelData)
49
- throw new Error(`Unknown model: ${String(model)} for provider ${provider}`);
50
- const key = apiKey || process.env[config.envKey];
51
- if (!key)
52
- throw new Error(`No API key provided for ${provider}. Set ${config.envKey} or pass apiKey.`);
53
- return config.create(modelData, key);
1
+ import { MODELS } from "./models.generated.js";
2
+ const modelRegistry = new Map();
3
+ // Initialize registry from MODELS on module load
4
+ for (const [provider, models] of Object.entries(MODELS)) {
5
+ const providerModels = new Map();
6
+ for (const [id, model] of Object.entries(models)) {
7
+ providerModels.set(id, model);
8
+ }
9
+ modelRegistry.set(provider, providerModels);
54
10
  }
55
- // Helper function to get model info with type-safe model IDs
56
11
  export function getModel(provider, modelId) {
57
- const providerData = PROVIDERS[provider];
58
- if (!providerData)
59
- return undefined;
60
- const models = providerData.models;
61
- return models[modelId];
12
+ return modelRegistry.get(provider)?.get(modelId);
13
+ }
14
+ export function getProviders() {
15
+ return Array.from(modelRegistry.keys());
16
+ }
17
+ export function getModels(provider) {
18
+ const models = modelRegistry.get(provider);
19
+ return models ? Array.from(models.values()) : [];
62
20
  }
63
21
  export function calculateCost(model, usage) {
64
22
  usage.cost.input = (model.cost.input / 1000000) * usage.input;
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAGrE,gDAAgD;AAChD,MAAM,CAAC,MAAM,eAAe,GAAG;IAC9B,MAAM,EAAE;QACP,MAAM,EAAE,gBAAgB;QACxB,MAAM,EAAE,CAAC,KAAY,EAAE,MAAc,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC;KACtE;IACD,MAAM,EAAE;QACP,MAAM,EAAE,gBAAgB;QACxB,MAAM,EAAE,CAAC,KAAY,EAAE,MAAc,EAAE,EAAE,CAAC,IA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C,KAAK,CAAC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC;IAC7E,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC;IACvG,OAAO,KAAK,CAAC,IAAI,CAAC;AACnB,CAAC","sourcesContent":["import { PROVIDERS } from \"./models.generated.js\";\nimport { AnthropicLLM } from \"./providers/anthropic.js\";\nimport { GoogleLLM } from \"./providers/google.js\";\nimport { OpenAICompletionsLLM } from \"./providers/openai-completions.js\";\nimport { OpenAIResponsesLLM } from \"./providers/openai-responses.js\";\nimport type { Model, Usage } from \"./types.js\";\n\n// Provider configuration with factory functions\nexport const PROVIDER_CONFIG = {\n\tgoogle: {\n\t\tenvKey: \"GEMINI_API_KEY\",\n\t\tcreate: (model: Model, apiKey: string) => new GoogleLLM(model, apiKey),\n\t},\n\topenai: {\n\t\tenvKey: \"OPENAI_API_KEY\",\n\t\tcreate: (model: Model, apiKey: string) => new OpenAIResponsesLLM(model, apiKey),\n\t},\n\tanthropic: {\n\t\tenvKey: \"ANTHROPIC_API_KEY\",\n\t\tcreate: (model: Model, apiKey: string) => new AnthropicLLM(model, apiKey),\n\t},\n\txai: {\n\t\tenvKey: \"XAI_API_KEY\",\n\t\tcreate: (model: Model, apiKey: string) => new OpenAICompletionsLLM(model, apiKey),\n\t},\n\tgroq: {\n\t\tenvKey: \"GROQ_API_KEY\",\n\t\tcreate: (model: Model, apiKey: string) => new OpenAICompletionsLLM(model, apiKey),\n\t},\n\tcerebras: {\n\t\tenvKey: \"CEREBRAS_API_KEY\",\n\t\tcreate: (model: Model, apiKey: string) => new OpenAICompletionsLLM(model, apiKey),\n\t},\n\topenrouter: {\n\t\tenvKey: \"OPENROUTER_API_KEY\",\n\t\tcreate: (model: Model, apiKey: string) => new OpenAICompletionsLLM(model, apiKey),\n\t},\n} as const;\n\n// Type mapping from provider to LLM implementation\nexport type ProviderToLLM = {\n\tgoogle: GoogleLLM;\n\topenai: OpenAIResponsesLLM;\n\tanthropic: AnthropicLLM;\n\txai: OpenAICompletionsLLM;\n\tgroq: OpenAICompletionsLLM;\n\tcerebras: OpenAICompletionsLLM;\n\topenrouter: OpenAICompletionsLLM;\n};\n\n// Extract model types for each provider\nexport type GoogleModel = keyof typeof PROVIDERS.google.models;\nexport type OpenAIModel = keyof typeof PROVIDERS.openai.models;\nexport type AnthropicModel = keyof typeof PROVIDERS.anthropic.models;\nexport type XAIModel = keyof typeof PROVIDERS.xai.models;\nexport type GroqModel = keyof typeof PROVIDERS.groq.models;\nexport type CerebrasModel = keyof typeof PROVIDERS.cerebras.models;\nexport type OpenRouterModel = keyof typeof PROVIDERS.openrouter.models;\n\n// Map providers to their model types\nexport type ProviderModels = {\n\tgoogle: GoogleModel;\n\topenai: OpenAIModel;\n\tanthropic: AnthropicModel;\n\txai: XAIModel;\n\tgroq: GroqModel;\n\tcerebras: CerebrasModel;\n\topenrouter: OpenRouterModel;\n};\n\n// Single generic factory function\nexport function createLLM<P extends keyof typeof PROVIDERS, M extends keyof (typeof PROVIDERS)[P][\"models\"]>(\n\tprovider: P,\n\tmodel: M,\n\tapiKey?: string,\n): ProviderToLLM[P] {\n\tconst config = PROVIDER_CONFIG[provider as keyof typeof PROVIDER_CONFIG];\n\tif (!config) throw new Error(`Unknown provider: ${provider}`);\n\n\tconst providerData = PROVIDERS[provider];\n\tif (!providerData) throw new Error(`Unknown provider: ${provider}`);\n\n\t// Type-safe model lookup\n\tconst models = providerData.models as Record<string, Model>;\n\tconst modelData = models[model as string];\n\tif (!modelData) throw new Error(`Unknown model: ${String(model)} for provider ${provider}`);\n\n\tconst key = apiKey || process.env[config.envKey];\n\tif (!key) throw new Error(`No API key provided for ${provider}. Set ${config.envKey} or pass apiKey.`);\n\n\treturn config.create(modelData, key) as ProviderToLLM[P];\n}\n\n// Helper function to get model info with type-safe model IDs\nexport function getModel<P extends keyof typeof PROVIDERS>(\n\tprovider: P,\n\tmodelId: keyof (typeof PROVIDERS)[P][\"models\"],\n): Model | undefined {\n\tconst providerData = PROVIDERS[provider];\n\tif (!providerData) return undefined;\n\tconst models = providerData.models as Record<string, Model>;\n\treturn models[modelId as string];\n}\n\nexport function calculateCost(model: Model, usage: Usage) {\n\tusage.cost.input = (model.cost.input / 1000000) * usage.input;\n\tusage.cost.output = (model.cost.output / 1000000) * usage.output;\n\tusage.cost.cacheRead = (model.cost.cacheRead / 1000000) * usage.cacheRead;\n\tusage.cost.cacheWrite = (model.cost.cacheWrite / 1000000) * usage.cacheWrite;\n\tusage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;\n\treturn usage.cost;\n}\n\n// Re-export Model type for convenience\nexport type { Model };\n"]}
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAG/C,MAAM,aAAa,GAAyC,IAAI,GAAG,EAAE,CAAC;AAEtE,iDAAiD;AACjD,KAAK,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;IACzD,MAAM,cAAc,GAAG,IAAI,GAAG,EAAsB,CAAC;IACrD,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,cAAc,CAAC,GAAG,CAAC,EAAE,EAAE,KAAmB,CAAC,CAAC;IAC7C,CAAC;IACD,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;AAC7C,CAAC;AAOD,MAAM,UAAU,QAAQ,CACvB,QAAmB,EACnB,OAAiB;IAEjB,OAAO,aAAa,CAAC,GA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ELS } from \"./models.generated.js\";\nimport type { Api, KnownProvider, Model, Usage } from \"./types.js\";\n\nconst modelRegistry: Map<string, Map<string, Model<Api>>> = new Map();\n\n// Initialize registry from MODELS on module load\nfor (const [provider, models] of Object.entries(MODELS)) {\n\tconst providerModels = new Map<string, Model<Api>>();\n\tfor (const [id, model] of Object.entries(models)) {\n\t\tproviderModels.set(id, model as Model<Api>);\n\t}\n\tmodelRegistry.set(provider, providerModels);\n}\n\ntype ModelApi<\n\tTProvider extends KnownProvider,\n\tTModelId extends keyof (typeof MODELS)[TProvider],\n> = (typeof MODELS)[TProvider][TModelId] extends { api: infer TApi } ? (TApi extends Api ? TApi : never) : never;\n\nexport function getModel<TProvider extends KnownProvider, TModelId extends keyof (typeof MODELS)[TProvider]>(\n\tprovider: TProvider,\n\tmodelId: TModelId,\n): Model<ModelApi<TProvider, TModelId>> {\n\treturn modelRegistry.get(provider)?.get(modelId as string) as Model<ModelApi<TProvider, TModelId>>;\n}\n\nexport function getProviders(): KnownProvider[] {\n\treturn Array.from(modelRegistry.keys()) as KnownProvider[];\n}\n\nexport function getModels<TProvider extends KnownProvider>(\n\tprovider: TProvider,\n): Model<ModelApi<TProvider, keyof (typeof MODELS)[TProvider]>>[] {\n\tconst models = modelRegistry.get(provider);\n\treturn models ? (Array.from(models.values()) as Model<ModelApi<TProvider, keyof (typeof MODELS)[TProvider]>>[]) : [];\n}\n\nexport function calculateCost<TApi extends Api>(model: Model<TApi>, usage: Usage): Usage[\"cost\"] {\n\tusage.cost.input = (model.cost.input / 1000000) * usage.input;\n\tusage.cost.output = (model.cost.output / 1000000) * usage.output;\n\tusage.cost.cacheRead = (model.cost.cacheRead / 1000000) * usage.cacheRead;\n\tusage.cost.cacheWrite = (model.cost.cacheWrite / 1000000) * usage.cacheWrite;\n\tusage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;\n\treturn usage.cost;\n}\n"]}
@@ -1,24 +1,11 @@
1
- import type { AssistantMessage, Context, LLM, LLMOptions, Model } from "../types.js";
2
- export interface AnthropicLLMOptions extends LLMOptions {
3
- thinking?: {
4
- enabled: boolean;
5
- budgetTokens?: number;
6
- };
1
+ import type { GenerateFunction, GenerateOptions } from "../types.js";
2
+ export interface AnthropicOptions extends GenerateOptions {
3
+ thinkingEnabled?: boolean;
4
+ thinkingBudgetTokens?: number;
7
5
  toolChoice?: "auto" | "any" | "none" | {
8
6
  type: "tool";
9
7
  name: string;
10
8
  };
11
9
  }
12
- export declare class AnthropicLLM implements LLM<AnthropicLLMOptions> {
13
- private client;
14
- private modelInfo;
15
- private isOAuthToken;
16
- constructor(model: Model, apiKey?: string);
17
- getModel(): Model;
18
- getApi(): string;
19
- generate(context: Context, options?: AnthropicLLMOptions): Promise<AssistantMessage>;
20
- private convertMessages;
21
- private convertTools;
22
- private mapStopReason;
23
- }
10
+ export declare const streamAnthropic: GenerateFunction<"anthropic-messages">;
24
11
  //# sourceMappingURL=anthropic.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/providers/anthropic.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACX,gBAAgB,EAChB,OAAO,EACP,GAAG,EACH,UAAU,EAEV,KAAK,EAKL,MAAM,aAAa,CAAC;AAGrB,MAAM,WAAW,mBAAoB,SAAQ,UAAU;IACtD,QAAQ,CAAC,EAAE;QACV,OAAO,EAAE,OAAO,CAAC;QACjB,YAAY,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CACtE;AAED,qBAAa,YAAa,YAAW,GAAG,CAAC,mBAAmB,CAAC;IAC5D,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,YAAY,CAAkB;gBAE1B,KA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