Skip to content

Commit 6f96295

Browse files
committed
live-demo: update agent plugin and adminforth versions and add global plugins setup
AdminForth/1439/add-global-plugins
1 parent 00b8fa7 commit 6f96295

6 files changed

Lines changed: 766 additions & 1107 deletions

File tree

live-demo/app/globalPlugins.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import AdminForthAgent from '@adminforth/agent';
2+
import { getLocalizedPlaceholderMessages } from './resources/agent_resources/placeholderMessages';
3+
import OpenAIAudioAdapter from '@adminforth/audio-adapter-openai'
4+
import CompletionAdapterOpenAIResponses from '@adminforth/completion-adapter-openai-responses';
5+
6+
const openAiApiKey = process.env.OPENAI_API_KEY as string;
7+
8+
const createCompletionAdapter = (
9+
model: string,
10+
effort: 'low' | 'medium' | 'xhigh',
11+
) => new CompletionAdapterOpenAIResponses({
12+
openAiApiKey,
13+
model,
14+
extraRequestBodyParameters: {
15+
reasoning: {
16+
effort,
17+
},
18+
},
19+
});
20+
21+
const balancedCompletionAdapter = createCompletionAdapter('gpt-5.4-mini', 'medium');
22+
const fastCompletionAdapter = createCompletionAdapter('gpt-5.4-mini', 'low');
23+
const smartThinkingCompletionAdapter = createCompletionAdapter('gpt-5.4', 'xhigh');
24+
25+
export const adminForthAgent = new AdminForthAgent({
26+
audioAdapter: new OpenAIAudioAdapter({
27+
apiKey: openAiApiKey,
28+
defaultVoice: 'alloy',
29+
defaultSpeed: 1.25,
30+
}),
31+
placeholderMessages: async ({ httpExtra }: any) => getLocalizedPlaceholderMessages({
32+
completionAdapter: fastCompletionAdapter as any,
33+
httpExtra,
34+
}),
35+
modes: [
36+
{
37+
name: 'Balanced',
38+
completionAdapter: balancedCompletionAdapter,
39+
},
40+
{
41+
name: 'Fast',
42+
completionAdapter: fastCompletionAdapter,
43+
},
44+
{
45+
name: 'Smart Thinking',
46+
completionAdapter: smartThinkingCompletionAdapter,
47+
},
48+
],
49+
maxTokens: 10000,
50+
sessionResource: {
51+
resourceId: 'sessions',
52+
idField: 'id',
53+
titleField: 'title',
54+
turnsField: 'turns',
55+
askerIdField: 'asker_id',
56+
createdAtField: 'created_at',
57+
},
58+
turnResource: {
59+
resourceId: 'turns',
60+
idField: 'id',
61+
sessionIdField: 'session_id',
62+
createdAtField: 'created_at',
63+
promptField: 'prompt',
64+
responseField: 'response',
65+
},
66+
checkpointResource: {
67+
resourceId: 'agent_checkpoints',
68+
idField: 'id',
69+
threadIdField: 'thread_id',
70+
checkpointNamespaceField: 'checkpoint_namespace',
71+
checkpointIdField: 'checkpoint_id',
72+
parentCheckpointIdField: 'parent_checkpoint_id',
73+
rowKindField: 'row_kind',
74+
taskIdField: 'task_id',
75+
sequenceField: 'sequence',
76+
createdAtField: 'created_at',
77+
checkpointPayloadField: 'checkpoint_payload',
78+
metadataPayloadField: 'metadata_payload',
79+
writesPayloadField: 'writes_payload',
80+
schemaVersionField: 'schema_version',
81+
},
82+
stickByDefault: true,
83+
})

live-demo/app/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import checkpointsResource from './resources/agent_resources/checkpoints';
1313
import jobs_resource from './resources/jobs';
1414
import { randomUUID } from 'crypto';
1515
try { fs.mkdirSync('db') } catch (e) {}
16-
16+
import { adminForthAgent } from './globalPlugins';
1717

1818
let db;
1919

@@ -129,6 +129,9 @@ new AdminForth({
129129
url: 'https://github.com/devforth/adminforth/tree/main/live-demo/app',
130130
},
131131
],
132+
globalPlugins: [
133+
adminForthAgent
134+
]
132135
});
133136

134137
async function seedDatabase() {

live-demo/app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"author": "",
1818
"description": "",
1919
"dependencies": {
20-
"@adminforth/agent": "^1.53.0",
20+
"@adminforth/agent": "^2.0.0",
2121
"@adminforth/audio-adapter-openai": "^1.3.0",
2222
"@adminforth/audit-log": "^1.9.21",
2323
"@adminforth/auto-remove": "^1.0.11",
@@ -41,7 +41,7 @@
4141
"@adminforth/two-factors-auth": "^3.3.10",
4242
"@adminforth/upload": "^2.15.14",
4343
"@prisma/client": "^6.19.3",
44-
"adminforth": "^3.0.1",
44+
"adminforth": "^3.5.0",
4545
"cldr-core": "^48.2.0",
4646
"express": "^4.22.2"
4747
},

0 commit comments

Comments
 (0)