Skip to content

Commit 00b8fa7

Browse files
committed
docs: update docs for the agent plugin
AdminForth/1439/add-global-plugins
1 parent f1370b7 commit 00b8fa7

2 files changed

Lines changed: 8 additions & 80 deletions

File tree

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ It stores session history in your own resources and generates responses using on
1717
## Installation
1818

1919
```bash
20-
pnpm i @adminforth/agent --save
21-
pnpm i @adminforth/completion-adapter-openai-responses --save
20+
pnpm add @adminforth/agent --save
21+
pnpm add @adminforth/completion-adapter-openai-responses --save
2222
```
2323

2424
Add your LLM credentials to `.env`:
@@ -197,17 +197,17 @@ export const admin = new AdminForth({
197197
});
198198
```
199199

200-
Then attach the plugin once, usually to your `adminuser` resource:
200+
Then attach the plugin once in `index.ts` as global plugin:
201201

202202
Configure the plugin with `modes`. The legacy top-level `completionAdapter` setup is no longer used.
203203

204-
```ts title="./resources/adminuser.ts"
204+
```ts title="./index.ts"
205205
import AdminForthAgent from '@adminforth/agent';
206206
import CompletionAdapterOpenAIResponses from '@adminforth/completion-adapter-openai-responses';
207207

208208
...
209209

210-
plugins: [
210+
globalPlugins: [
211211
...
212212
new AdminForthAgent({
213213
// optional, can be used to suggest example prompts in the UI
@@ -462,7 +462,7 @@ pnpm makemigration --name add-adminforth-agent-turn-debug ; pnpm migrate:local
462462

463463
Tell the plugin where to store debug data:
464464

465-
```ts title="./resources/adminuser.ts"
465+
```ts title="index.ts"
466466
new AdminForthAgent({
467467
modes: [
468468
...
@@ -604,7 +604,7 @@ pnpm add @adminforth/audio-adapter-openai
604604

605605
2) Import it in your users resource and add to the plugin config
606606

607-
```ts title="./resources/adminuser.ts"
607+
```ts title="index.ts"
608608
//diff-add
609609
import OpenAIAudioAdapter from '@adminforth/audio-adapter-openai'
610610

@@ -1010,7 +1010,7 @@ export const admin = new AdminForth({
10101010

10111011
Then connect it to the plugin:
10121012

1013-
```ts title="./resources/adminuser.ts"
1013+
```ts title="index.ts"
10141014
new AdminForthAgent({
10151015
modes: [
10161016
...

dev-demo/resources/adminuser.ts

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,8 @@ import AdminForthStorageAdapterLocalFilesystem from "../../adapters/adminforth-s
88
import OpenSignupPlugin from '../../plugins/adminforth-open-signup/index.js';
99
import DashboardPlugin from '../../plugins/adminforth-dashboard/index.js';
1010
import KeyValueAdapterRam from '../../adapters/adminforth-key-value-adapter-ram/index.js';
11-
import AdminForthAgent from '../../plugins/adminforth-agent/index.js';
12-
import CompletionAdapterOpenAIResponses from '../../adapters/adminforth-completion-adapter-openai-responses/index.js';
13-
import OpenAIAudioAdapter from '../../adapters/adminforth-audio-adapter-openai/index.js';
1411
import OAuthPlugin from './configs/oauthPluginConfig.js';
1512

16-
const OVH_AI_ENDPOINTS_BASE_URL = 'https://oai.endpoints.kepler.ai.cloud.ovh.net/v1';
17-
const ovhAiEndpointsAccessToken = process.env.OVH_AI_ENDPOINTS_ACCESS_TOKEN;
18-
const openAiResponsesApiKey = ovhAiEndpointsAccessToken || process.env.OPENAI_API_KEY;
19-
const usesOvhAiEndpoints = Boolean(ovhAiEndpointsAccessToken);
20-
21-
function createAgentCompletionAdapter(
22-
model: string,
23-
effort: 'low' | 'medium' | 'xhigh',
24-
) {
25-
return new CompletionAdapterOpenAIResponses({
26-
openAiApiKey: openAiResponsesApiKey as string,
27-
baseUrl: usesOvhAiEndpoints ? OVH_AI_ENDPOINTS_BASE_URL : undefined,
28-
model: usesOvhAiEndpoints ? 'gpt-oss-120b' : model,
29-
extraRequestBodyParameters: {
30-
...(usesOvhAiEndpoints ? { store: false } : {}),
31-
reasoning: {
32-
effort,
33-
},
34-
},
35-
});
36-
}
37-
3813
async function allowedForSuperAdmin({ adminUser }: { adminUser: AdminUser }): Promise<boolean> {
3914
return adminUser.dbUser.role === 'superadmin';
4015
}
@@ -198,53 +173,6 @@ export default {
198173
},
199174
}),
200175
OAuthPlugin,
201-
...(process.env.OPENAI_API_KEY ?
202-
[
203-
new AdminForthAgent({
204-
audioAdapter: new OpenAIAudioAdapter({
205-
apiKey: process.env.OPENAI_API_KEY,
206-
}),
207-
placeholderMessages: async ({ adminUser, httpExtra }) => {
208-
return [
209-
"What is a cars count in SQLite",
210-
"Build average car price by days chart in SQLite",
211-
]
212-
},
213-
modes: [
214-
{
215-
name: 'Balanced',
216-
completionAdapter: createAgentCompletionAdapter('gpt-5.4-mini', 'medium'),
217-
},
218-
{
219-
name: 'Fast',
220-
completionAdapter: createAgentCompletionAdapter('gpt-5.4-mini', 'low'),
221-
},
222-
{
223-
name: 'Smart Thinking',
224-
completionAdapter: createAgentCompletionAdapter('gpt-5.4', 'xhigh'),
225-
},
226-
],
227-
maxTokens: 10000,
228-
reasoning: 'none',
229-
sessionResource: {
230-
resourceId: 'sessions',
231-
idField: 'id',
232-
titleField: 'title',
233-
turnsField: 'turns',
234-
askerIdField: 'asker_id',
235-
createdAtField: 'created_at',
236-
},
237-
turnResource: {
238-
resourceId: 'turns',
239-
idField: 'id',
240-
sessionIdField: 'session_id',
241-
createdAtField: 'created_at',
242-
promptField: 'prompt',
243-
responseField: 'response',
244-
debugField: 'dubbug',
245-
},
246-
}),
247-
] : []),
248176
new DashboardPlugin({
249177
dashboardConfigsResourceId: 'dashboard_configs',
250178
}),

0 commit comments

Comments
 (0)