@alumnium/openai 0.0.0-stage → 0.24.0-alpha.2

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/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Alexey Rodionov, Tatiana Shepeleva
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
- # Temporary Holding Version
1
+ # @alumnium/openai
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Alumnium OpenAI LLM provider. See [the main `alumnium` package page](https://www.npmjs.com/package/alumnium) for more details.
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "@alumnium/openai",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.24.0-alpha.2",
4
+ "description": "Alumnium OpenAI LLM provider",
5
+ "license": "MIT",
6
+ "author": "Alex Rodionov <p0deje@gmail.com>",
7
+ "contributors": [
8
+ "Alex Rodionov <p0deje@gmail.com>",
9
+ "Sasha Koss <koss@nocorp.me>",
10
+ "Tatiana Shepeleva <tati.shep@gmail.com>"
11
+ ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/alumnium-hq/alumnium.git"
15
+ },
16
+ "files": [
17
+ "src",
18
+ "README.md",
19
+ "LICENSE.md"
20
+ ],
21
+ "type": "module",
22
+ "exports": {
23
+ ".": {
24
+ "import": {
25
+ "types": "./src/index.d.ts",
26
+ "default": "./src/index.js"
27
+ },
28
+ "require": {
29
+ "types": "./src/index.d.ts",
30
+ "default": "./src/index.cjs"
31
+ }
32
+ }
33
+ },
34
+ "dependencies": {
35
+ "@ai-sdk/openai": "^4.0.46",
36
+ "@ai-sdk/provider": "^4.0.7",
37
+ "@alumnium/core": "0.24.0-alpha.2",
38
+ "ai": "^7.0.78"
39
+ }
40
+ }
package/src/index.cjs ADDED
@@ -0,0 +1,77 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ function __accessProp(key) {
6
+ return this[key];
7
+ }
8
+ var __toCommonJS = (from) => {
9
+ var entry = (__moduleCache ??= new WeakMap()).get(from),
10
+ desc;
11
+ if (entry) return entry;
12
+ entry = __defProp({}, "__esModule", { value: true });
13
+ if ((from && typeof from === "object") || typeof from === "function") {
14
+ for (var key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(entry, key))
16
+ __defProp(entry, key, {
17
+ get: __accessProp.bind(from, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
19
+ });
20
+ }
21
+ __moduleCache.set(from, entry);
22
+ return entry;
23
+ };
24
+ var __moduleCache;
25
+ var __returnValue = (v) => v;
26
+ function __exportSetter(name, newValue) {
27
+ this[name] = __returnValue.bind(null, newValue);
28
+ }
29
+ var __export = (target, all) => {
30
+ for (var name in all)
31
+ __defProp(target, name, {
32
+ get: all[name],
33
+ enumerable: true,
34
+ configurable: true,
35
+ set: __exportSetter.bind(all, name),
36
+ });
37
+ };
38
+
39
+ // openai/src/index.ts
40
+ var exports_src = {};
41
+ __export(exports_src, {
42
+ createOpenAiLlm: () => createOpenAiLlm,
43
+ openAiProviders: () => openAiProviders,
44
+ });
45
+ module.exports = __toCommonJS(exports_src);
46
+
47
+ // openai/src/llm/openAiProviders.ts
48
+ var import_openai = require("@ai-sdk/openai");
49
+ var import_internal = require("@alumnium/core/internal");
50
+ var logger = import_internal.Logger.get(
51
+ "packages/typescript/openai/src/llm/openAiProviders.ts",
52
+ );
53
+ function createOpenAiLlm(model) {
54
+ logger.debug(`Creating OpenAI LLM with model ${model.name}`);
55
+ const customURL = import_internal.Env.OPENAI_CUSTOM_URL;
56
+ const provider = import_openai.createOpenAI({
57
+ ...import_internal.apiKeyField(import_internal.Env.OPENAI_API_KEY),
58
+ ...(customURL ? { baseURL: customURL } : {}),
59
+ ...(import_internal.Env.OPENAI_DEFAULT_HEADERS
60
+ ? { headers: import_internal.Env.OPENAI_DEFAULT_HEADERS }
61
+ : {}),
62
+ });
63
+ const llm = customURL ? provider.chat(model.name) : provider(model.name);
64
+ return model.name.includes("gpt-4o")
65
+ ? llm
66
+ : import_internal.withCallDefaults(llm, {
67
+ reasoning: "low",
68
+ providerOptions: { openai: { reasoningSummary: "auto" } },
69
+ });
70
+ }
71
+ var openAiProviders = {
72
+ openai: createOpenAiLlm,
73
+ };
74
+ import_internal.LlmFactory.register(openAiProviders);
75
+
76
+ //# debugId=DFE699A2347166DC64756E2164756E21
77
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../openai/src/llm/openAiProviders.ts"],
4
+ "sourcesContent": [
5
+ "import { createOpenAI } from \"@ai-sdk/openai\";\nimport type { LanguageModelV4 } from \"@ai-sdk/provider\";\nimport {\n apiKeyField,\n LlmFactory,\n withCallDefaults,\n Env,\n Logger,\n type Model,\n} from \"@alumnium/core/internal\";\n\nconst logger = Logger.get(\"packages/typescript/openai/src/llm/openAiProviders.ts\");\n\nexport function createOpenAiLlm(model: Model): LanguageModelV4 {\n logger.debug(`Creating OpenAI LLM with model ${model.name}`);\n const customURL = Env.OPENAI_CUSTOM_URL;\n const provider = createOpenAI({\n ...apiKeyField(Env.OPENAI_API_KEY),\n ...(customURL ? { baseURL: customURL } : {}),\n ...(Env.OPENAI_DEFAULT_HEADERS\n ? { headers: Env.OPENAI_DEFAULT_HEADERS }\n : {}),\n });\n const llm = customURL ? provider.chat(model.name) : provider(model.name);\n return model.name.includes(\"gpt-4o\")\n ? llm\n : withCallDefaults(llm, {\n reasoning: \"low\",\n providerOptions: { openai: { reasoningSummary: \"auto\" } },\n });\n}\n\nexport const openAiProviders: LlmFactory.Providers = {\n openai: createOpenAiLlm,\n};\n\nLlmFactory.register(openAiProviders);\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA6B,IAA7B;AASO,IAPP;AASA,IAAM,SAAS,uBAAO,IAAI,uDAAuD;AAE1E,SAAS,eAAe,CAAC,OAA+B;AAAA,EAC7D,OAAO,MAAM,kCAAkC,MAAM,MAAM;AAAA,EAC3D,MAAM,YAAY,oBAAI;AAAA,EACtB,MAAM,WAAW,2BAAa;AAAA,OACzB,4BAAY,oBAAI,cAAc;AAAA,OAC7B,YAAY,EAAE,SAAS,UAAU,IAAI,CAAC;AAAA,OACtC,oBAAI,yBACJ,EAAE,SAAS,oBAAI,uBAAuB,IACtC,CAAC;AAAA,EACP,CAAC;AAAA,EACD,MAAM,MAAM,YAAY,SAAS,KAAK,MAAM,IAAI,IAAI,SAAS,MAAM,IAAI;AAAA,EACvE,OAAO,MAAM,KAAK,SAAS,QAAQ,IAC/B,MACA,iCAAiB,KAAK;AAAA,IACpB,WAAW;AAAA,IACX,iBAAiB,EAAE,QAAQ,EAAE,kBAAkB,OAAO,EAAE;AAAA,EAC1D,CAAC;AAAA;AAGA,IAAM,kBAAwC;AAAA,EACnD,QAAQ;AACV;AAEA,2BAAW,SAAS,eAAe;",
8
+ "debugId": "DFE699A2347166DC64756E2164756E21",
9
+ "names": []
10
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./llm/openAiProviders.ts";
package/src/index.js ADDED
@@ -0,0 +1,38 @@
1
+ // openai/src/llm/openAiProviders.ts
2
+ import { createOpenAI } from "@ai-sdk/openai";
3
+ import {
4
+ apiKeyField,
5
+ LlmFactory,
6
+ withCallDefaults,
7
+ Env,
8
+ Logger,
9
+ } from "@alumnium/core/internal";
10
+ var logger = Logger.get(
11
+ "packages/typescript/openai/src/llm/openAiProviders.ts",
12
+ );
13
+ function createOpenAiLlm(model) {
14
+ logger.debug(`Creating OpenAI LLM with model ${model.name}`);
15
+ const customURL = Env.OPENAI_CUSTOM_URL;
16
+ const provider = createOpenAI({
17
+ ...apiKeyField(Env.OPENAI_API_KEY),
18
+ ...(customURL ? { baseURL: customURL } : {}),
19
+ ...(Env.OPENAI_DEFAULT_HEADERS
20
+ ? { headers: Env.OPENAI_DEFAULT_HEADERS }
21
+ : {}),
22
+ });
23
+ const llm = customURL ? provider.chat(model.name) : provider(model.name);
24
+ return model.name.includes("gpt-4o")
25
+ ? llm
26
+ : withCallDefaults(llm, {
27
+ reasoning: "low",
28
+ providerOptions: { openai: { reasoningSummary: "auto" } },
29
+ });
30
+ }
31
+ var openAiProviders = {
32
+ openai: createOpenAiLlm,
33
+ };
34
+ LlmFactory.register(openAiProviders);
35
+ export { createOpenAiLlm, openAiProviders };
36
+
37
+ //# debugId=CAD141A0DA302CBE64756E2164756E21
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../openai/src/llm/openAiProviders.ts"],
4
+ "sourcesContent": [
5
+ "import { createOpenAI } from \"@ai-sdk/openai\";\nimport type { LanguageModelV4 } from \"@ai-sdk/provider\";\nimport {\n apiKeyField,\n LlmFactory,\n withCallDefaults,\n Env,\n Logger,\n type Model,\n} from \"@alumnium/core/internal\";\n\nconst logger = Logger.get(\"packages/typescript/openai/src/llm/openAiProviders.ts\");\n\nexport function createOpenAiLlm(model: Model): LanguageModelV4 {\n logger.debug(`Creating OpenAI LLM with model ${model.name}`);\n const customURL = Env.OPENAI_CUSTOM_URL;\n const provider = createOpenAI({\n ...apiKeyField(Env.OPENAI_API_KEY),\n ...(customURL ? { baseURL: customURL } : {}),\n ...(Env.OPENAI_DEFAULT_HEADERS\n ? { headers: Env.OPENAI_DEFAULT_HEADERS }\n : {}),\n });\n const llm = customURL ? provider.chat(model.name) : provider(model.name);\n return model.name.includes(\"gpt-4o\")\n ? llm\n : withCallDefaults(llm, {\n reasoning: \"low\",\n providerOptions: { openai: { reasoningSummary: \"auto\" } },\n });\n}\n\nexport const openAiProviders: LlmFactory.Providers = {\n openai: createOpenAiLlm,\n};\n\nLlmFactory.register(openAiProviders);\n"
6
+ ],
7
+ "mappings": ";AAAA;AAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,IAAM,SAAS,OAAO,IAAI,uDAAuD;AAE1E,SAAS,eAAe,CAAC,OAA+B;AAAA,EAC7D,OAAO,MAAM,kCAAkC,MAAM,MAAM;AAAA,EAC3D,MAAM,YAAY,IAAI;AAAA,EACtB,MAAM,WAAW,aAAa;AAAA,OACzB,YAAY,IAAI,cAAc;AAAA,OAC7B,YAAY,EAAE,SAAS,UAAU,IAAI,CAAC;AAAA,OACtC,IAAI,yBACJ,EAAE,SAAS,IAAI,uBAAuB,IACtC,CAAC;AAAA,EACP,CAAC;AAAA,EACD,MAAM,MAAM,YAAY,SAAS,KAAK,MAAM,IAAI,IAAI,SAAS,MAAM,IAAI;AAAA,EACvE,OAAO,MAAM,KAAK,SAAS,QAAQ,IAC/B,MACA,iBAAiB,KAAK;AAAA,IACpB,WAAW;AAAA,IACX,iBAAiB,EAAE,QAAQ,EAAE,kBAAkB,OAAO,EAAE;AAAA,EAC1D,CAAC;AAAA;AAGA,IAAM,kBAAwC;AAAA,EACnD,QAAQ;AACV;AAEA,WAAW,SAAS,eAAe;",
8
+ "debugId": "CAD141A0DA302CBE64756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,4 @@
1
+ import type { LanguageModelV4 } from "@ai-sdk/provider";
2
+ import { LlmFactory, type Model } from "@alumnium/core/internal";
3
+ export declare function createOpenAiLlm(model: Model): LanguageModelV4;
4
+ export declare const openAiProviders: LlmFactory.Providers;