@adminforth/agent 1.19.0 → 1.21.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/agent/simpleAgent.ts +2 -3
- package/apiBasedTools.ts +7 -0
- package/build.log +2 -2
- package/custom/skills/data-analytics/SKILL.md +3 -3
- package/dist/agent/simpleAgent.js +4 -4
- package/dist/apiBasedTools.js +6 -0
- package/dist/custom/skills/data-analytics/SKILL.md +3 -3
- package/dist/index.js +2 -1
- package/index.ts +2 -1
- package/package.json +1 -1
package/agent/simpleAgent.ts
CHANGED
|
@@ -165,7 +165,6 @@ function createAgentLlmMetricsLogger() {
|
|
|
165
165
|
export function createAgentChatModel(params: {
|
|
166
166
|
adapter: CompletionAdapter;
|
|
167
167
|
maxTokens: number;
|
|
168
|
-
modelName?: string;
|
|
169
168
|
}) {
|
|
170
169
|
const adapter = params.adapter as OpenAIBackedCompletionAdapter;
|
|
171
170
|
const options = adapter.options ?? {};
|
|
@@ -176,7 +175,7 @@ export function createAgentChatModel(params: {
|
|
|
176
175
|
);
|
|
177
176
|
}
|
|
178
177
|
|
|
179
|
-
const model =
|
|
178
|
+
const model = options.model ?? "gpt-5-nano";
|
|
180
179
|
const baseURL = options.baseURL ?? options.baseUrl;
|
|
181
180
|
const reasoning = options.extraRequestBodyParameters
|
|
182
181
|
?.reasoning as OpenAiReasoningConfig | undefined;
|
|
@@ -195,8 +194,8 @@ export function createAgentChatModel(params: {
|
|
|
195
194
|
useResponsesApi: true,
|
|
196
195
|
outputVersion: "v1",
|
|
197
196
|
streaming: true,
|
|
198
|
-
promptCacheKey: `adminforth-agent:${model}:system-v1:tools-v1`,
|
|
199
197
|
|
|
198
|
+
promptCacheKey: `adminforth-agent:${model}:system-v1:tools-v1`,
|
|
200
199
|
promptCacheRetention: "in_memory",
|
|
201
200
|
|
|
202
201
|
...(reasoningConfig ? { reasoning: reasoningConfig } : {}),
|
package/apiBasedTools.ts
CHANGED
|
@@ -75,6 +75,7 @@ type ToolOverrideContext = {
|
|
|
75
75
|
|
|
76
76
|
type ToolOverride = {
|
|
77
77
|
wipe_frontend_specific_data?: readonly string[];
|
|
78
|
+
format_tool?: (params: ToolOverrideContext) => Promise<string> | string;
|
|
78
79
|
post_process_response?: (params: ToolOverrideContext) => Promise<unknown> | unknown;
|
|
79
80
|
};
|
|
80
81
|
|
|
@@ -103,6 +104,9 @@ const TOOL_OVERRIDES: Record<string, ToolOverride> = {
|
|
|
103
104
|
'resource.options.actions[].customComponent',
|
|
104
105
|
'resource.options.pageInjections',
|
|
105
106
|
],
|
|
107
|
+
format_tool: async ({ }) => {
|
|
108
|
+
return "get resource Apartments"
|
|
109
|
+
}
|
|
106
110
|
},
|
|
107
111
|
get_resource_data: {
|
|
108
112
|
post_process_response: async ({ output, inputs, invokeTool, userTimeZone }) => {
|
|
@@ -126,6 +130,9 @@ const TOOL_OVERRIDES: Record<string, ToolOverride> = {
|
|
|
126
130
|
|
|
127
131
|
return response;
|
|
128
132
|
},
|
|
133
|
+
format_tool: async ({ }) => {
|
|
134
|
+
return "get 1-20 Apartment filtered listed=yes"
|
|
135
|
+
}
|
|
129
136
|
},
|
|
130
137
|
};
|
|
131
138
|
|
package/build.log
CHANGED
|
@@ -32,5 +32,5 @@ custom/skills/fetch_data/SKILL.md
|
|
|
32
32
|
custom/skills/mutate_data/
|
|
33
33
|
custom/skills/mutate_data/SKILL.md
|
|
34
34
|
|
|
35
|
-
sent 188,
|
|
36
|
-
total size is 186,
|
|
35
|
+
sent 188,784 bytes received 451 bytes 378,470.00 bytes/sec
|
|
36
|
+
total size is 186,932 speedup is 0.99
|
|
@@ -12,10 +12,10 @@ Use `get_resource_data` to fetch data for this skill. This is the main tool for
|
|
|
12
12
|
|
|
13
13
|
When the user asks for analytics, reports, trends, comparisons, or distributions:
|
|
14
14
|
|
|
15
|
-
- Fetch the
|
|
16
|
-
-
|
|
15
|
+
- Fetch the requested data using `aggregate` tool. This tool is capable of performing fast server-side aggregations on filtered data, groupings by date including grouping by day/week/month etc.
|
|
16
|
+
- if it is not possible to get the required aggregates using `aggregate`, fetch the underlying rows with `get_resource_data`. This is much heavier since returns original rows with all fields, but allows you to perform complex calculations, comparisons, and custom groupings in-memory. Always prefer `aggregate` when possible.
|
|
17
|
+
- Prefer narrow requests: use filters, sorting, pagination, and date ranges whenever possible.
|
|
17
18
|
- If the request is ambiguous, clarify the resource, metric, grouping, or date range before fetching data.
|
|
18
|
-
- Compute aggregates from the returned rows yourself: sums, counts, averages, min/max, grouped totals, ratios, and trend deltas.
|
|
19
19
|
- Return a short written summary with the key finding and most important numbers.
|
|
20
20
|
- If a chart would help, produce a Vega-Lite spec.
|
|
21
21
|
|
|
@@ -102,15 +102,15 @@ function createAgentLlmMetricsLogger() {
|
|
|
102
102
|
return new AgentLlmMetricsLogger();
|
|
103
103
|
}
|
|
104
104
|
export function createAgentChatModel(params) {
|
|
105
|
-
var _a, _b, _c, _d
|
|
105
|
+
var _a, _b, _c, _d;
|
|
106
106
|
const adapter = params.adapter;
|
|
107
107
|
const options = (_a = adapter.options) !== null && _a !== void 0 ? _a : {};
|
|
108
108
|
if (!options.openAiApiKey) {
|
|
109
109
|
throw new Error("CompletionAdapter must expose options.openAiApiKey for ChatOpenAI");
|
|
110
110
|
}
|
|
111
|
-
const model = (
|
|
112
|
-
const baseURL = (
|
|
113
|
-
const reasoning = (
|
|
111
|
+
const model = (_b = options.model) !== null && _b !== void 0 ? _b : "gpt-5-nano";
|
|
112
|
+
const baseURL = (_c = options.baseURL) !== null && _c !== void 0 ? _c : options.baseUrl;
|
|
113
|
+
const reasoning = (_d = options.extraRequestBodyParameters) === null || _d === void 0 ? void 0 : _d.reasoning;
|
|
114
114
|
const reasoningConfig = reasoning
|
|
115
115
|
? Object.assign(Object.assign({}, reasoning), { summary: "auto" }) : undefined;
|
|
116
116
|
// @ts-ignore
|
package/dist/apiBasedTools.js
CHANGED
|
@@ -25,6 +25,9 @@ const TOOL_OVERRIDES = {
|
|
|
25
25
|
'resource.options.actions[].customComponent',
|
|
26
26
|
'resource.options.pageInjections',
|
|
27
27
|
],
|
|
28
|
+
format_tool: (_a) => __awaiter(void 0, [_a], void 0, function* ({}) {
|
|
29
|
+
return "get resource Apartments";
|
|
30
|
+
})
|
|
28
31
|
},
|
|
29
32
|
get_resource_data: {
|
|
30
33
|
post_process_response: (_a) => __awaiter(void 0, [_a], void 0, function* ({ output, inputs, invokeTool, userTimeZone }) {
|
|
@@ -44,6 +47,9 @@ const TOOL_OVERRIDES = {
|
|
|
44
47
|
formatDateTimeColumns(response.data, dateTimeColumnNames, localizedTimeZone);
|
|
45
48
|
return response;
|
|
46
49
|
}),
|
|
50
|
+
format_tool: (_a) => __awaiter(void 0, [_a], void 0, function* ({}) {
|
|
51
|
+
return "get 1-20 Apartment filtered listed=yes";
|
|
52
|
+
})
|
|
47
53
|
},
|
|
48
54
|
};
|
|
49
55
|
function sanitizeForYaml(value) {
|
|
@@ -12,10 +12,10 @@ Use `get_resource_data` to fetch data for this skill. This is the main tool for
|
|
|
12
12
|
|
|
13
13
|
When the user asks for analytics, reports, trends, comparisons, or distributions:
|
|
14
14
|
|
|
15
|
-
- Fetch the
|
|
16
|
-
-
|
|
15
|
+
- Fetch the requested data using `aggregate` tool. This tool is capable of performing fast server-side aggregations on filtered data, groupings by date including grouping by day/week/month etc.
|
|
16
|
+
- if it is not possible to get the required aggregates using `aggregate`, fetch the underlying rows with `get_resource_data`. This is much heavier since returns original rows with all fields, but allows you to perform complex calculations, comparisons, and custom groupings in-memory. Always prefer `aggregate` when possible.
|
|
17
|
+
- Prefer narrow requests: use filters, sorting, pagination, and date ranges whenever possible.
|
|
17
18
|
- If the request is ambiguous, clarify the resource, metric, grouping, or date range before fetching data.
|
|
18
|
-
- Compute aggregates from the returned rows yourself: sums, counts, averages, min/max, grouped totals, ratios, and trend deltas.
|
|
19
19
|
- Return a short written summary with the key finding and most important numbers.
|
|
20
20
|
- If a chart would help, produce a Vega-Lite spec.
|
|
21
21
|
|
package/dist/index.js
CHANGED
|
@@ -371,7 +371,8 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
|
|
|
371
371
|
path: `/agent/get-sessions`,
|
|
372
372
|
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser }) {
|
|
373
373
|
const userId = adminUser.pk;
|
|
374
|
-
const
|
|
374
|
+
const limit = typeof body.limit === 'number' ? body.limit : 20;
|
|
375
|
+
const sessions = yield this.adminforth.resource(this.pluginOptions.sessionResource.resourceId).list([Filters.EQ(this.pluginOptions.sessionResource.askerIdField, userId)], limit, undefined, [Sorts.DESC(this.pluginOptions.sessionResource.createdAtField)]);
|
|
375
376
|
const sessionsToReturn = [];
|
|
376
377
|
for (const session of sessions) {
|
|
377
378
|
sessionsToReturn.push({
|
package/index.ts
CHANGED
|
@@ -422,8 +422,9 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
|
|
|
422
422
|
path: `/agent/get-sessions`,
|
|
423
423
|
handler: async ({body, adminUser }) => {
|
|
424
424
|
const userId = adminUser.pk;
|
|
425
|
+
const limit = typeof body.limit === 'number' ? body.limit : 20;
|
|
425
426
|
const sessions = await this.adminforth.resource(this.pluginOptions.sessionResource.resourceId).list(
|
|
426
|
-
[Filters.EQ(this.pluginOptions.sessionResource.askerIdField, userId)],
|
|
427
|
+
[Filters.EQ(this.pluginOptions.sessionResource.askerIdField, userId)], limit, undefined, [Sorts.DESC(this.pluginOptions.sessionResource.createdAtField)]
|
|
427
428
|
);
|
|
428
429
|
const sessionsToReturn = [];
|
|
429
430
|
for (const session of sessions) {
|