pi-llama-cpp 0.3.3 → 0.3.4
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/package.json
CHANGED
package/src/models/baseModel.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "../constants";
|
|
8
8
|
import { Mode } from "../enums/mode";
|
|
9
9
|
import { Status } from "../enums/status";
|
|
10
|
-
import { DataProperty
|
|
10
|
+
import { DataProperty } from "../interfaces/endpoints/models";
|
|
11
11
|
import { PropsEndpoint } from "../interfaces/endpoints/props";
|
|
12
12
|
import { rpc } from "../tools/retriever";
|
|
13
13
|
|
|
@@ -97,11 +97,11 @@ export abstract class BaseModel {
|
|
|
97
97
|
*/
|
|
98
98
|
async getContextSize(): Promise<number> {
|
|
99
99
|
try {
|
|
100
|
-
const {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
return
|
|
100
|
+
const { default_generation_settings } = await rpc<PropsEndpoint>(
|
|
101
|
+
`/props?model=${this.id}`,
|
|
102
|
+
);
|
|
103
|
+
const { n_ctx } = default_generation_settings;
|
|
104
|
+
return n_ctx;
|
|
105
105
|
} catch {
|
|
106
106
|
return DEFAULT_CTX;
|
|
107
107
|
}
|
|
@@ -1,23 +1,8 @@
|
|
|
1
|
-
import { DEFAULT_CTX } from "../constants";
|
|
2
1
|
import { Mode } from "../enums/mode";
|
|
3
|
-
import { PropsEndpoint } from "../interfaces/endpoints/props";
|
|
4
|
-
import { rpc } from "../tools/retriever";
|
|
5
2
|
import { BaseModel } from "./baseModel";
|
|
6
3
|
|
|
7
4
|
export class SingleModel extends BaseModel {
|
|
8
5
|
get mode(): Mode {
|
|
9
6
|
return Mode.SINGLE;
|
|
10
7
|
}
|
|
11
|
-
|
|
12
|
-
async getContextSize(): Promise<number> {
|
|
13
|
-
try {
|
|
14
|
-
const { default_generation_settings } = await rpc<PropsEndpoint>(
|
|
15
|
-
`/props?model=${this.id}`,
|
|
16
|
-
);
|
|
17
|
-
const { n_ctx } = default_generation_settings;
|
|
18
|
-
return n_ctx;
|
|
19
|
-
} catch {
|
|
20
|
-
return DEFAULT_CTX;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
8
|
}
|
|
@@ -130,14 +130,9 @@ describe("RouterModel context size extraction", () => {
|
|
|
130
130
|
},
|
|
131
131
|
],
|
|
132
132
|
});
|
|
133
|
-
// Second call: super.getContextSize() -> /
|
|
133
|
+
// Second call: super.getContextSize() -> /props?model=test-model with default_generation_settings.n_ctx
|
|
134
134
|
mockRpc.mockResolvedValueOnce({
|
|
135
|
-
|
|
136
|
-
{
|
|
137
|
-
id: "test-model",
|
|
138
|
-
meta: { n_ctx: 4096 },
|
|
139
|
-
},
|
|
140
|
-
],
|
|
135
|
+
default_generation_settings: { n_ctx: 4096 },
|
|
141
136
|
});
|
|
142
137
|
|
|
143
138
|
const model = new RouterModel(
|
|
@@ -85,28 +85,19 @@ describe("SingleModel getStatus", () => {
|
|
|
85
85
|
});
|
|
86
86
|
|
|
87
87
|
describe("SingleModel getContextSize", () => {
|
|
88
|
-
it("should return n_ctx from /
|
|
88
|
+
it("should return n_ctx from /props endpoint default_generation_settings", async () => {
|
|
89
89
|
mockRpc.mockResolvedValueOnce({
|
|
90
|
-
|
|
90
|
+
default_generation_settings: { n_ctx: 8192 },
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
const model = createModel();
|
|
94
94
|
const ctxSize = await model.getContextSize();
|
|
95
95
|
|
|
96
96
|
expect(ctxSize).toBe(8192);
|
|
97
|
-
expect(mockRpc).toHaveBeenCalledWith("/
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it("should return DEFAULT_CTX when model not found in /models", async () => {
|
|
101
|
-
mockRpc.mockResolvedValueOnce({ data: [] });
|
|
102
|
-
|
|
103
|
-
const model = createModel();
|
|
104
|
-
const ctxSize = await model.getContextSize();
|
|
105
|
-
|
|
106
|
-
expect(ctxSize).toBe(DEFAULT_CTX);
|
|
97
|
+
expect(mockRpc).toHaveBeenCalledWith("/props?model=test");
|
|
107
98
|
});
|
|
108
99
|
|
|
109
|
-
it("should return DEFAULT_CTX when /
|
|
100
|
+
it("should return DEFAULT_CTX when /props fails", async () => {
|
|
110
101
|
mockRpc.mockRejectedValueOnce(new Error("Connection refused"));
|
|
111
102
|
|
|
112
103
|
const model = createModel();
|