Skip to content

Commit 7877397

Browse files
committed
docs: enhance agent plugin to support multiple modes for response generation and update documentation accordingly
1 parent 1177cbc commit 7877397

1 file changed

Lines changed: 45 additions & 10 deletions

File tree

  • adminforth/documentation/docs/tutorial/08-Plugins

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

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
This plugin adds an AI agent with a chat surface to AdminForth which is capable of default skills like searching/editing data and extending with custom skills.
77

8-
It stores session history in your own resources and uses any AdminForth completion adapter to generate responses.
8+
It stores session history in your own resources and generates responses using one of the configured `modes`.
99

1010
## Installation
1111

@@ -21,7 +21,7 @@ Add your LLM credentials to `.env`:
2121
OPENAI_API_KEY=your_key
2222
```
2323

24-
You can replace the OpenAI adapter with any completion adapter from [List of adapters](/docs/tutorial/ListOfAdapters/).
24+
Each mode accepts any AdminForth completion adapter, so you can replace the OpenAI adapter with another adapter from [List of adapters](/docs/tutorial/ListOfAdapters/).
2525

2626
## Setup
2727

@@ -166,6 +166,8 @@ export const admin = new AdminForth({
166166

167167
Then attach the plugin once, usually to your `adminuser` resource:
168168

169+
Configure the plugin with `modes`. The legacy top-level `completionAdapter` setup is no longer used.
170+
169171
```ts title="./resources/adminuser.ts"
170172
import AdminForthAgent from '@adminforth/agent';
171173
import CompletionAdapterOpenAIChatGPT from '@adminforth/completion-adapter-open-ai-chat-gpt';
@@ -175,12 +177,45 @@ import CompletionAdapterOpenAIChatGPT from '@adminforth/completion-adapter-open-
175177
plugins: [
176178
...
177179
new AdminForthAgent({
178-
completionAdapter: new CompletionAdapterOpenAIChatGPT({
179-
openAiApiKey: process.env.OPENAI_API_KEY as string,
180-
model: 'gpt-5.4-mini',
181-
}),
180+
modes: [
181+
{
182+
name: 'Balanced',
183+
completionAdapter: new CompletionAdapterOpenAIChatGPT({
184+
openAiApiKey: process.env.OPENAI_API_KEY as string,
185+
model: 'gpt-5.4-mini',
186+
extraRequestBodyParameters: {
187+
reasoning: {
188+
effort: 'medium',
189+
},
190+
},
191+
}),
192+
},
193+
{
194+
name: 'Fast',
195+
completionAdapter: new CompletionAdapterOpenAIChatGPT({
196+
openAiApiKey: process.env.OPENAI_API_KEY as string,
197+
model: 'gpt-5.4-mini',
198+
extraRequestBodyParameters: {
199+
reasoning: {
200+
effort: 'low',
201+
},
202+
},
203+
}),
204+
},
205+
{
206+
name: 'Smart Thinking',
207+
completionAdapter: new CompletionAdapterOpenAIChatGPT({
208+
openAiApiKey: process.env.OPENAI_API_KEY as string,
209+
model: 'gpt-5.4',
210+
extraRequestBodyParameters: {
211+
reasoning: {
212+
effort: 'xhigh',
213+
},
214+
},
215+
}),
216+
},
217+
],
182218
maxTokens: 10000,
183-
reasoning: 'none',
184219
sessionResource: {
185220
resourceId: 'sessions',
186221
idField: 'id',
@@ -203,7 +238,9 @@ plugins: [
203238
]
204239
```
205240

206-
The plugin adds a chat surface to the admin UI and keeps session history per admin user.
241+
Each item in `modes` defines a user-selectable preset in the chat UI. The selected mode is sent to the backend and the plugin uses that mode's `completionAdapter` for the response.
242+
243+
The plugin adds a chat surface to the admin UI, keeps session history per admin user, and shows a mode picker when `modes` are configured.
207244

208245
## Reverse proxy and CDN configuration for streaming
209246

@@ -270,5 +307,3 @@ In skills markdown file, merge which tool exactlu agent should load.
270307
Skill example:
271308

272309
// TODO
273-
274-

0 commit comments

Comments
 (0)