@myvillage/cli 1.70.0 → 1.71.0
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
|
@@ -18,6 +18,12 @@ export const DATASET_APPEND_DESCRIPTION =
|
|
|
18
18
|
'regression provide a numeric `target`. Data stays local; provenance ' +
|
|
19
19
|
'is recorded automatically.';
|
|
20
20
|
|
|
21
|
+
export const MODEL_PREDICT_DESCRIPTION =
|
|
22
|
+
'Run a prediction with a LOCAL trained model on this machine. ' +
|
|
23
|
+
'Returns the predicted class with per-class confidence scores ' +
|
|
24
|
+
'(classification) or a numeric value (regression). The model must already ' +
|
|
25
|
+
'exist (trained in the Studio Lab or via `myvillage model train`).';
|
|
26
|
+
|
|
21
27
|
/** All native built-in tools available to every local agent. */
|
|
22
28
|
export const BUILTIN_TOOL_DEFS = [
|
|
23
29
|
{
|
|
@@ -26,5 +32,10 @@ export const BUILTIN_TOOL_DEFS = [
|
|
|
26
32
|
tier: 'villager',
|
|
27
33
|
builtin: true,
|
|
28
34
|
},
|
|
29
|
-
|
|
35
|
+
{
|
|
36
|
+
name: 'model_predict',
|
|
37
|
+
description: MODEL_PREDICT_DESCRIPTION,
|
|
38
|
+
tier: 'villager',
|
|
39
|
+
builtin: true,
|
|
40
|
+
},
|
|
30
41
|
];
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import { tool } from 'ai';
|
|
16
16
|
import { z } from 'zod';
|
|
17
17
|
import { appendRows, datasetExists } from '../utils/dataset-workspace.js';
|
|
18
|
-
import { DATASET_APPEND_DESCRIPTION } from './builtin-tools-registry.js';
|
|
18
|
+
import { DATASET_APPEND_DESCRIPTION, MODEL_PREDICT_DESCRIPTION } from './builtin-tools-registry.js';
|
|
19
19
|
|
|
20
20
|
export { BUILTIN_TOOL_DEFS } from './builtin-tools-registry.js';
|
|
21
21
|
|
|
@@ -71,5 +71,37 @@ export function getBuiltinTools(agentName, config) {
|
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
}),
|
|
74
|
+
|
|
75
|
+
model_predict: tool({
|
|
76
|
+
description: MODEL_PREDICT_DESCRIPTION,
|
|
77
|
+
inputSchema: z.object({
|
|
78
|
+
modelId: z.string().describe('Slug of the local trained model'),
|
|
79
|
+
input: z
|
|
80
|
+
.union([z.string(), z.array(z.number())])
|
|
81
|
+
.describe('Text, or a numeric vector for tabular models'),
|
|
82
|
+
}),
|
|
83
|
+
execute: async ({ modelId, input }) => {
|
|
84
|
+
try {
|
|
85
|
+
// Lazy-load the model/tfjs code so agent startup stays light — tfjs
|
|
86
|
+
// only loads the first time an agent actually predicts.
|
|
87
|
+
const { modelExists, readModelManifest, loadModel } = await import(
|
|
88
|
+
'../utils/model-workspace.js'
|
|
89
|
+
);
|
|
90
|
+
if (!modelExists(modelId)) {
|
|
91
|
+
return {
|
|
92
|
+
error:
|
|
93
|
+
`Model "${modelId}" not found locally. Train one first ` +
|
|
94
|
+
'(Studio Lab or `myvillage model train`).',
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const { predictWithModel } = await import('../utils/model-trainer.js');
|
|
98
|
+
const record = readModelManifest(modelId);
|
|
99
|
+
const model = await loadModel(modelId);
|
|
100
|
+
return predictWithModel(model, record, input);
|
|
101
|
+
} catch (e) {
|
|
102
|
+
return { error: e.message };
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
}),
|
|
74
106
|
};
|
|
75
107
|
}
|