@bitlerjs/ollama 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.
- package/dist/configs/configs.d.ts +10 -0
- package/dist/configs/configs.d.ts.map +1 -0
- package/dist/configs/configs.js +20 -0
- package/dist/configs/configs.js.map +1 -0
- package/dist/exports.d.ts +3 -0
- package/dist/exports.d.ts.map +1 -0
- package/dist/exports.js +31 -0
- package/dist/exports.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +22 -0
@@ -0,0 +1,10 @@
|
|
1
|
+
import { z } from '@bitlerjs/core';
|
2
|
+
declare const ollamaConfig: import("@bitlerjs/core").ConfigItem<z.ZodObject<{
|
3
|
+
url: z.ZodString;
|
4
|
+
}, "strip", z.ZodTypeAny, {
|
5
|
+
url: string;
|
6
|
+
}, {
|
7
|
+
url: string;
|
8
|
+
}>>;
|
9
|
+
export { ollamaConfig as ollamaConfig };
|
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;AAGrD,QAAA,MAAM,YAAY;;;;;;GAehB,CAAC;AAEH,OAAO,EAAE,YAAY,IAAI,YAAY,EAAE,CAAC"}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { createConfigItem, z } from '@bitlerjs/core';
|
2
|
+
import OpenAI from 'openai';
|
3
|
+
const ollamaConfig = createConfigItem({
|
4
|
+
kind: 'ollama',
|
5
|
+
name: 'Ollama',
|
6
|
+
group: 'Model Providers',
|
7
|
+
description: 'Ollama configuration',
|
8
|
+
schema: z.object({
|
9
|
+
url: z.string(),
|
10
|
+
}),
|
11
|
+
validate: async ({ input }) => {
|
12
|
+
const client = new OpenAI({
|
13
|
+
baseURL: input.url,
|
14
|
+
apiKey: 'ollama',
|
15
|
+
});
|
16
|
+
await client.models.list();
|
17
|
+
},
|
18
|
+
});
|
19
|
+
export { ollamaConfig as ollamaConfig };
|
20
|
+
//# 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;AACrD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,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,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;KAChB,CAAC;IACF,QAAQ,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;QAC5B,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;YACxB,OAAO,EAAE,KAAK,CAAC,GAAG;YAClB,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;QACH,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC;CACF,CAAC,CAAC;AAEH,OAAO,EAAE,YAAY,IAAI,YAAY,EAAE,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,MAAM,oCA8BV,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
package/dist/exports.js
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
import OpenAI from 'openai';
|
2
|
+
import { Configs, createExtension } from '@bitlerjs/core';
|
3
|
+
import { createModel, Models } from '@bitlerjs/llm';
|
4
|
+
import { ollamaConfig } from './configs/configs.js';
|
5
|
+
const ollama = createExtension({
|
6
|
+
setup: async ({ container }) => {
|
7
|
+
const configsService = container.get(Configs);
|
8
|
+
const modelsService = container.get(Models);
|
9
|
+
configsService.register([ollamaConfig]);
|
10
|
+
configsService.use(ollamaConfig, async (config) => {
|
11
|
+
if (config) {
|
12
|
+
const client = new OpenAI({
|
13
|
+
baseURL: config.url,
|
14
|
+
apiKey: 'ollama',
|
15
|
+
});
|
16
|
+
const openAIModels = await client.models.list();
|
17
|
+
const models = openAIModels.getPaginatedItems();
|
18
|
+
modelsService.register(models.map((model) => createModel({
|
19
|
+
kind: `ollama-${model.id}`,
|
20
|
+
name: model.id,
|
21
|
+
modelName: model.id,
|
22
|
+
provider: 'ollama',
|
23
|
+
apiKey: 'ollama',
|
24
|
+
url: config.url,
|
25
|
+
})));
|
26
|
+
}
|
27
|
+
});
|
28
|
+
},
|
29
|
+
});
|
30
|
+
export { ollama };
|
31
|
+
//# 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,OAAO,EAAE,MAAM,CAAC,GAAG;oBACnB,MAAM,EAAE,QAAQ;iBACjB,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,QAAQ;oBAChB,GAAG,EAAE,MAAM,CAAC,GAAG;iBAChB,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/ollama",
|
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
|
+
}
|