Skip to content

Commit a0c405c

Browse files
authored
Merge branch 'main' into next
2 parents e0aeae5 + 4909fdc commit a0c405c

20 files changed

Lines changed: 321 additions & 9106 deletions

File tree

adminforth/dataConnectors/baseConnector.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ export default class AdminForthBaseConnector implements IAdminForthDataSourceCon
167167
}
168168
const fieldObj = resource.dataSourceColumns.find((col) => col.name == normalizedFilter.field);
169169
if (!fieldObj) {
170+
const resourceColumn = resource.columns.find((col) => col.name == normalizedFilter.field);
171+
if (resourceColumn?.virtual) {
172+
return { ok: true, error: '', normalizedFilters: normalizedFilter };
173+
}
174+
170175
const similar = suggestIfTypo(resource.dataSourceColumns.map((col) => col.name), normalizedFilter.field);
171176

172177
let isPolymorphicTarget = false;
@@ -191,6 +196,11 @@ export default class AdminForthBaseConnector implements IAdminForthDataSourceCon
191196
// ensure rightField exists in resource
192197
const rightFieldObj = resource.dataSourceColumns.find((col) => col.name == normalizedFilter.rightField);
193198
if (!rightFieldObj) {
199+
const rightResourceColumn = resource.columns.find((col) => col.name == normalizedFilter.rightField);
200+
if (rightResourceColumn?.virtual) {
201+
return { ok: true, error: '', normalizedFilters: normalizedFilter };
202+
}
203+
194204
const similar = suggestIfTypo(resource.dataSourceColumns.map((col) => col.name), normalizedFilter.rightField as string);
195205
throw new Error(`Field '${normalizedFilter.rightField}' not found in resource '${resource.resourceId}'. ${similar ? `Did you mean '${similar}'?` : ''}`);
196206
}

adminforth/documentation/docs/tutorial/08-Plugins/01-agent.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,41 @@ completionAdapter: new CompletionAdapterOpenAIResponses({
314314
OVH AI Endpoints still does not fully support the OpenAI `responses` API, so `useComplitionApi: false` may work unstably there.
315315

316316

317+
## Turn on audio chat support
318+
If you want to have an ability to talk with agent usng voice, you can setup it:
317319

320+
1) Install audio adapter:
321+
322+
```bash
323+
pnpm add @adminforth/audio-adapter-openai
324+
```
325+
326+
2) Import it in your users resource and add to the plugin config
327+
328+
```ts title="./resources/adminuser.ts"
329+
//diff-add
330+
import OpenAIAudioAdapter from '@adminforth/audio-adapter-openai'
331+
332+
...
333+
334+
335+
new AdminForthAgent({
336+
...
337+
//diff-add
338+
audioAdapter: new OpenAIAudioAdapter({
339+
//diff-add
340+
apiKey: process.env.OPENAI_API_KEY as string,,
341+
//diff-add
342+
defaultVoice: 'alloy',
343+
//diff-add
344+
defaultSpeed: 1.25,
345+
//diff-add
346+
}),
347+
...
348+
}),
349+
...
350+
351+
```
318352

319353
## Writing own skills
320354

dev-demo/custom/AfComponents.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
:loader="false" class="w-full" mode="secondary">
1313
Secondary button
1414
</Button>
15-
15+
1616
<Button @click="doSmth"
1717
:loader="true" class="w-full mt-4">
1818
Your button text

dev-demo/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const admin = new AdminForth({
5858
}
5959
const imageUrl = await plugin.getFileDownloadUrl(adminUser.dbUser.avatar || '', 3600);
6060
return imageUrl;
61-
},
61+
},
6262
},
6363
customization: {
6464
brandName: "dev-demo",
@@ -278,7 +278,7 @@ if (fileURLToPath(import.meta.url) === path.resolve(process.argv[1])) {
278278
admin.bundleNow({ hotReload: process.env.NODE_ENV === 'development' }).then(() => {
279279
logger.info('Bundling AdminForth SPA done.');
280280
});
281-
281+
282282
admin.express.serve(app);
283283

284284
const backgroundJobsPlugin = admin.getPluginByClassName<BackgroundJobsPlugin>('BackgroundJobsPlugin');

live-demo/app/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
FROM node:20-alpine
22
WORKDIR /code/
33
ADD package.json pnpm-lock.yaml pnpm-workspace.yaml /code/
4-
RUN npm i -g corepack@0.31.0
54
RUN corepack enable
5+
RUN corepack prepare pnpm@latest-10 --activate
66
RUN pnpm i
77
ADD . /code/
88
RUN pnpm bundleNow

live-demo/app/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import betterSqlite3 from 'better-sqlite3';
21
import express from 'express';
3-
import AdminForth, { AdminForthDataTypes, Filters, AdminForthResource, AdminForthResourceColumn } from 'adminforth';
2+
import type { Request, Response } from 'express';
3+
import AdminForth, { Filters } from 'adminforth';
4+
import type { AdminUser } from 'adminforth';
45
import fs from 'fs';
56
import usersResource from "./resources/users";
67
import apartmentsResource from "./resources/apartments";
78
import auditLogsResource from "./resources/auditLogs"
89
import translations from "./resources/translations";
910
import sessionsResource from './resources/agent_resources/sessions';
1011
import turnsResource from './resources/agent_resources/turns';
12+
import checkpointsResource from './resources/agent_resources/checkpoints';
1113
import jobs_resource from './resources/jobs';
1214
import { randomUUID } from 'crypto';
1315
try { fs.mkdirSync('db') } catch (e) {}
@@ -66,6 +68,7 @@ new AdminForth({
6668
translations,
6769
sessionsResource,
6870
turnsResource,
71+
checkpointsResource,
6972
jobs_resource,
7073
],
7174
menu: [
@@ -179,7 +182,7 @@ if (import.meta.url === `file://${process.argv[1]}`) {
179182
},
180183
},
181184
admin.express.authorize(
182-
async (req, res) => {
185+
async (req: Request, res: Response) => {
183186
const db = admin.resource('aparts').dataConnector.client;
184187
const days = req.body.days || 7;
185188
const apartsByDays = await db.prepare(
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
-- CreateTable
2+
CREATE TABLE "agent_checkpoints" (
3+
"id" TEXT NOT NULL PRIMARY KEY,
4+
"thread_id" TEXT NOT NULL,
5+
"checkpoint_namespace" TEXT NOT NULL,
6+
"checkpoint_id" TEXT NOT NULL,
7+
"parent_checkpoint_id" TEXT,
8+
"row_kind" TEXT NOT NULL,
9+
"task_id" TEXT,
10+
"sequence" INTEGER NOT NULL,
11+
"created_at" DATETIME NOT NULL,
12+
"checkpoint_payload" TEXT,
13+
"metadata_payload" TEXT,
14+
"writes_payload" TEXT,
15+
"schema_version" INTEGER NOT NULL
16+
);
17+
18+
-- CreateIndex
19+
CREATE INDEX "agent_checkpoints_thread_id_checkpoint_namespace_checkpoint_id_idx" ON "agent_checkpoints"("thread_id", "checkpoint_namespace", "checkpoint_id");
20+
21+
-- CreateIndex
22+
CREATE INDEX "agent_checkpoints_created_at_idx" ON "agent_checkpoints"("created_at");

0 commit comments

Comments
 (0)