donobu 5.20.0 → 5.20.1
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/clients/OllamaGptClient.d.ts +1 -1
- package/dist/clients/OllamaGptClient.js +19 -10
- package/dist/esm/clients/OllamaGptClient.d.ts +1 -1
- package/dist/esm/clients/OllamaGptClient.js +19 -10
- package/dist/esm/exceptions/GptModelCapabilityException.d.ts +12 -0
- package/dist/esm/exceptions/GptModelCapabilityException.js +19 -0
- package/dist/exceptions/GptModelCapabilityException.d.ts +12 -0
- package/dist/exceptions/GptModelCapabilityException.js +19 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ZodType } from 'zod/v4';
|
|
2
2
|
import type { OllamaConfig } from '../models/GptConfig';
|
|
3
3
|
import type { AssistantMessage, GptMessage, ProposedToolCallsMessage, StructuredOutputMessage } from '../models/GptMessage';
|
|
4
4
|
import type { ToolOption } from './GptClient';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OllamaGptClient = void 0;
|
|
4
|
+
const v4_1 = require("zod/v4");
|
|
5
|
+
const GptModelCapabilityException_1 = require("../exceptions/GptModelCapabilityException");
|
|
4
6
|
const GptModelNotFoundException_1 = require("../exceptions/GptModelNotFoundException");
|
|
5
7
|
const GptPlatformNotReachableException_1 = require("../exceptions/GptPlatformNotReachableException");
|
|
6
8
|
const Logger_1 = require("../utils/Logger");
|
|
@@ -23,9 +25,15 @@ class OllamaGptClient extends GptClient_1.GptClient {
|
|
|
23
25
|
}
|
|
24
26
|
async ping(options) {
|
|
25
27
|
const signal = options?.signal ?? AbortSignal.timeout(10_000);
|
|
28
|
+
const modelName = this.config.modelName;
|
|
26
29
|
let resp;
|
|
27
30
|
try {
|
|
28
|
-
resp = await fetch(`${this.apiUrl}/api/
|
|
31
|
+
resp = await fetch(`${this.apiUrl}/api/show`, {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
headers: { 'Content-Type': 'application/json' },
|
|
34
|
+
body: JSON.stringify({ model: modelName }),
|
|
35
|
+
signal,
|
|
36
|
+
});
|
|
29
37
|
}
|
|
30
38
|
catch (error) {
|
|
31
39
|
if (error instanceof TypeError) {
|
|
@@ -34,18 +42,19 @@ class OllamaGptClient extends GptClient_1.GptClient {
|
|
|
34
42
|
}
|
|
35
43
|
throw error;
|
|
36
44
|
}
|
|
45
|
+
if (resp.status === 404) {
|
|
46
|
+
throw new GptModelNotFoundException_1.GptModelNotFoundException(this.config.type, modelName);
|
|
47
|
+
}
|
|
37
48
|
if (!resp.ok) {
|
|
38
49
|
throw new GptPlatformNotReachableException_1.GptPlatformNotReachableException(this.config.type);
|
|
39
50
|
}
|
|
40
|
-
const data =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (!found) {
|
|
48
|
-
throw new GptModelNotFoundException_1.GptModelNotFoundException(this.config.type, modelName);
|
|
51
|
+
const data = v4_1.z
|
|
52
|
+
.object({ capabilities: v4_1.z.array(v4_1.z.string()).default([]) })
|
|
53
|
+
.parse(await resp.json());
|
|
54
|
+
const requiredCapabilities = ['completion', 'tools', 'vision'];
|
|
55
|
+
const missingCapabilities = requiredCapabilities.filter((cap) => !data.capabilities.includes(cap));
|
|
56
|
+
if (missingCapabilities.length > 0) {
|
|
57
|
+
throw new GptModelCapabilityException_1.GptModelCapabilityException(this.config.type, modelName, missingCapabilities);
|
|
49
58
|
}
|
|
50
59
|
}
|
|
51
60
|
async getMessage(messages, options) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ZodType } from 'zod/v4';
|
|
2
2
|
import type { OllamaConfig } from '../models/GptConfig';
|
|
3
3
|
import type { AssistantMessage, GptMessage, ProposedToolCallsMessage, StructuredOutputMessage } from '../models/GptMessage';
|
|
4
4
|
import type { ToolOption } from './GptClient';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OllamaGptClient = void 0;
|
|
4
|
+
const v4_1 = require("zod/v4");
|
|
5
|
+
const GptModelCapabilityException_1 = require("../exceptions/GptModelCapabilityException");
|
|
4
6
|
const GptModelNotFoundException_1 = require("../exceptions/GptModelNotFoundException");
|
|
5
7
|
const GptPlatformNotReachableException_1 = require("../exceptions/GptPlatformNotReachableException");
|
|
6
8
|
const Logger_1 = require("../utils/Logger");
|
|
@@ -23,9 +25,15 @@ class OllamaGptClient extends GptClient_1.GptClient {
|
|
|
23
25
|
}
|
|
24
26
|
async ping(options) {
|
|
25
27
|
const signal = options?.signal ?? AbortSignal.timeout(10_000);
|
|
28
|
+
const modelName = this.config.modelName;
|
|
26
29
|
let resp;
|
|
27
30
|
try {
|
|
28
|
-
resp = await fetch(`${this.apiUrl}/api/
|
|
31
|
+
resp = await fetch(`${this.apiUrl}/api/show`, {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
headers: { 'Content-Type': 'application/json' },
|
|
34
|
+
body: JSON.stringify({ model: modelName }),
|
|
35
|
+
signal,
|
|
36
|
+
});
|
|
29
37
|
}
|
|
30
38
|
catch (error) {
|
|
31
39
|
if (error instanceof TypeError) {
|
|
@@ -34,18 +42,19 @@ class OllamaGptClient extends GptClient_1.GptClient {
|
|
|
34
42
|
}
|
|
35
43
|
throw error;
|
|
36
44
|
}
|
|
45
|
+
if (resp.status === 404) {
|
|
46
|
+
throw new GptModelNotFoundException_1.GptModelNotFoundException(this.config.type, modelName);
|
|
47
|
+
}
|
|
37
48
|
if (!resp.ok) {
|
|
38
49
|
throw new GptPlatformNotReachableException_1.GptPlatformNotReachableException(this.config.type);
|
|
39
50
|
}
|
|
40
|
-
const data =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (!found) {
|
|
48
|
-
throw new GptModelNotFoundException_1.GptModelNotFoundException(this.config.type, modelName);
|
|
51
|
+
const data = v4_1.z
|
|
52
|
+
.object({ capabilities: v4_1.z.array(v4_1.z.string()).default([]) })
|
|
53
|
+
.parse(await resp.json());
|
|
54
|
+
const requiredCapabilities = ['completion', 'tools', 'vision'];
|
|
55
|
+
const missingCapabilities = requiredCapabilities.filter((cap) => !data.capabilities.includes(cap));
|
|
56
|
+
if (missingCapabilities.length > 0) {
|
|
57
|
+
throw new GptModelCapabilityException_1.GptModelCapabilityException(this.config.type, modelName, missingCapabilities);
|
|
49
58
|
}
|
|
50
59
|
}
|
|
51
60
|
async getMessage(messages, options) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DonobuException } from './DonobuException';
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when a model exists but lacks required capabilities
|
|
4
|
+
* (e.g. completion, tools, or vision).
|
|
5
|
+
*/
|
|
6
|
+
export declare class GptModelCapabilityException extends DonobuException {
|
|
7
|
+
readonly platform: string;
|
|
8
|
+
readonly gptModel: string;
|
|
9
|
+
readonly missingCapabilities: string[];
|
|
10
|
+
constructor(platform: string, gptModel: string, missingCapabilities: string[]);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=GptModelCapabilityException.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GptModelCapabilityException = void 0;
|
|
4
|
+
const DonobuException_1 = require("./DonobuException");
|
|
5
|
+
/**
|
|
6
|
+
* Thrown when a model exists but lacks required capabilities
|
|
7
|
+
* (e.g. completion, tools, or vision).
|
|
8
|
+
*/
|
|
9
|
+
class GptModelCapabilityException extends DonobuException_1.DonobuException {
|
|
10
|
+
constructor(platform, gptModel, missingCapabilities) {
|
|
11
|
+
super(`The model '${gptModel}' on '${platform}' is missing required capabilities: ${missingCapabilities.join(', ')}. ` +
|
|
12
|
+
`Please choose a model that supports completion, tools, and vision.`);
|
|
13
|
+
this.platform = platform;
|
|
14
|
+
this.gptModel = gptModel;
|
|
15
|
+
this.missingCapabilities = missingCapabilities;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.GptModelCapabilityException = GptModelCapabilityException;
|
|
19
|
+
//# sourceMappingURL=GptModelCapabilityException.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DonobuException } from './DonobuException';
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when a model exists but lacks required capabilities
|
|
4
|
+
* (e.g. completion, tools, or vision).
|
|
5
|
+
*/
|
|
6
|
+
export declare class GptModelCapabilityException extends DonobuException {
|
|
7
|
+
readonly platform: string;
|
|
8
|
+
readonly gptModel: string;
|
|
9
|
+
readonly missingCapabilities: string[];
|
|
10
|
+
constructor(platform: string, gptModel: string, missingCapabilities: string[]);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=GptModelCapabilityException.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GptModelCapabilityException = void 0;
|
|
4
|
+
const DonobuException_1 = require("./DonobuException");
|
|
5
|
+
/**
|
|
6
|
+
* Thrown when a model exists but lacks required capabilities
|
|
7
|
+
* (e.g. completion, tools, or vision).
|
|
8
|
+
*/
|
|
9
|
+
class GptModelCapabilityException extends DonobuException_1.DonobuException {
|
|
10
|
+
constructor(platform, gptModel, missingCapabilities) {
|
|
11
|
+
super(`The model '${gptModel}' on '${platform}' is missing required capabilities: ${missingCapabilities.join(', ')}. ` +
|
|
12
|
+
`Please choose a model that supports completion, tools, and vision.`);
|
|
13
|
+
this.platform = platform;
|
|
14
|
+
this.gptModel = gptModel;
|
|
15
|
+
this.missingCapabilities = missingCapabilities;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.GptModelCapabilityException = GptModelCapabilityException;
|
|
19
|
+
//# sourceMappingURL=GptModelCapabilityException.js.map
|