@bitlerjs/openai 0.1.17

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.
@@ -0,0 +1,10 @@
1
+ import { z } from '@bitlerjs/core';
2
+ declare const openAIConfig: import("@bitlerjs/core").ConfigItem<z.ZodObject<{
3
+ apiKey: z.ZodString;
4
+ }, "strip", z.ZodTypeAny, {
5
+ apiKey: string;
6
+ }, {
7
+ apiKey: string;
8
+ }>>;
9
+ export { openAIConfig };
10
+ //# sourceMappingURL=configs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../src/configs/configs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,CAAC,EAAE,MAAM,gBAAgB,CAAC;AAErD,QAAA,MAAM,YAAY;;;;;;GAQhB,CAAC;AAEH,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { createConfigItem, z } from '@bitlerjs/core';
2
+ const openAIConfig = createConfigItem({
3
+ kind: 'openai',
4
+ name: 'OpenAI',
5
+ group: 'Model Providers',
6
+ description: 'OpenAI configuration',
7
+ schema: z.object({
8
+ apiKey: z.string(),
9
+ }),
10
+ });
11
+ export { openAIConfig };
12
+ //# sourceMappingURL=configs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configs.js","sourceRoot":"","sources":["../../src/configs/configs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,CAAC,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,YAAY,GAAG,gBAAgB,CAAC;IACpC,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,iBAAiB;IACxB,WAAW,EAAE,sBAAsB;IACnC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;KACnB,CAAC;CACH,CAAC,CAAC;AAEH,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const openai: import("@bitlerjs/core").Extension;
2
+ export { openai };
3
+ //# sourceMappingURL=exports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,MAAM,oCA4BV,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ import OpenAI from 'openai';
2
+ import { Configs, createExtension } from '@bitlerjs/core';
3
+ import { createModel, Models } from '@bitlerjs/llm';
4
+ import { openAIConfig } from './configs/configs.js';
5
+ const openai = createExtension({
6
+ setup: async ({ container }) => {
7
+ const configsService = container.get(Configs);
8
+ const modelsService = container.get(Models);
9
+ configsService.register([openAIConfig]);
10
+ configsService.use(openAIConfig, async (config) => {
11
+ if (config) {
12
+ const client = new OpenAI({
13
+ apiKey: config.apiKey,
14
+ });
15
+ const openAIModels = await client.models.list();
16
+ const models = openAIModels.getPaginatedItems();
17
+ modelsService.register(models.map((model) => createModel({
18
+ kind: `openai-${model.id}`,
19
+ name: model.id,
20
+ modelName: model.id,
21
+ provider: 'openai',
22
+ apiKey: config.apiKey,
23
+ })));
24
+ }
25
+ });
26
+ },
27
+ });
28
+ export { openai };
29
+ //# sourceMappingURL=exports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,MAAM,MAAM,GAAG,eAAe,CAAC;IAC7B,KAAK,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;QAC7B,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC9C,MAAM,aAAa,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAE5C,cAAc,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;QAExC,cAAc,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YAChD,IAAI,MAAM,EAAE,CAAC;gBACX,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;oBACxB,MAAM,EAAE,MAAM,CAAC,MAAM;iBACtB,CAAC,CAAC;gBACH,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gBAChD,MAAM,MAAM,GAAG,YAAY,CAAC,iBAAiB,EAAE,CAAC;gBAChD,aAAa,CAAC,QAAQ,CACpB,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACnB,WAAW,CAAC;oBACV,IAAI,EAAE,UAAU,KAAK,CAAC,EAAE,EAAE;oBAC1B,IAAI,EAAE,KAAK,CAAC,EAAE;oBACd,SAAS,EAAE,KAAK,CAAC,EAAE;oBACnB,QAAQ,EAAE,QAAQ;oBAClB,MAAM,EAAE,MAAM,CAAC,MAAM;iBACtB,CAAC,CACH,CACF,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ {"root":["../src/exports.ts","../src/configs/configs.ts"],"version":"5.7.2"}
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@bitlerjs/openai",
3
+ "version": "0.1.17",
4
+ "main": "dist/exports.js",
5
+ "type": "module",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "devDependencies": {
10
+ "typescript": "^5.7.2",
11
+ "@bitlerjs/configs": "0.1.17"
12
+ },
13
+ "dependencies": {
14
+ "openai": "^4.77.0",
15
+ "@bitlerjs/core": "0.1.17",
16
+ "@bitlerjs/llm": "0.1.17"
17
+ },
18
+ "scripts": {
19
+ "build": "tsc --build",
20
+ "dev": "tsc --build --watch"
21
+ }
22
+ }