@adminforth/agent 1.15.0 → 1.16.1
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/systemPrompt.ts +13 -2
- package/build.log +2 -2
- package/custom/ChatSurface.vue +12 -9
- package/custom/ConversationArea.vue +13 -11
- package/custom/SessionsHistory.vue +6 -3
- package/custom/composables/useAgentTransitions.ts +1 -1
- package/dist/agent/systemPrompt.js +7 -0
- package/dist/custom/ChatSurface.vue +12 -9
- package/dist/custom/ConversationArea.vue +13 -11
- package/dist/custom/SessionsHistory.vue +6 -3
- package/dist/custom/composables/useAgentTransitions.ts +1 -1
- package/dist/index.js +5 -4
- package/index.ts +8 -3
- package/package.json +1 -1
- package/types.ts +5 -0
package/agent/systemPrompt.ts
CHANGED
|
@@ -35,10 +35,21 @@ export const DEFAULT_AGENT_SYSTEM_PROMPT = [
|
|
|
35
35
|
"If the confirmed plan has multiple steps, you may execute the whole confirmed plan without asking again between those steps.",
|
|
36
36
|
"If the plan changes, expands, or you want to do anything beyond the confirmed plan, ask for confirmation again.",
|
|
37
37
|
"Do not reuse an old confirmation for a new mutation plan.",
|
|
38
|
-
|
|
39
|
-
|
|
40
38
|
].join(" ");
|
|
41
39
|
|
|
40
|
+
export function appendCustomSystemPrompt(
|
|
41
|
+
systemPrompt: string,
|
|
42
|
+
customSystemPrompt?: string,
|
|
43
|
+
) {
|
|
44
|
+
const normalizedCustomSystemPrompt = customSystemPrompt?.trim();
|
|
45
|
+
|
|
46
|
+
if (!normalizedCustomSystemPrompt) {
|
|
47
|
+
return systemPrompt;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return `${systemPrompt}\n\n${normalizedCustomSystemPrompt}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
42
53
|
function formatResources(resources: AdminForthResource[]) {
|
|
43
54
|
return resources
|
|
44
55
|
.map((resource) => `- resourceId: ${resource.resourceId}\n label: ${resource.label}`)
|
package/build.log
CHANGED
|
@@ -31,5 +31,5 @@ custom/skills/fetch_data/SKILL.md
|
|
|
31
31
|
custom/skills/mutate_data/
|
|
32
32
|
custom/skills/mutate_data/SKILL.md
|
|
33
33
|
|
|
34
|
-
sent 184,
|
|
35
|
-
total size is 182,
|
|
34
|
+
sent 184,388 bytes received 436 bytes 369,648.00 bytes/sec
|
|
35
|
+
total size is 182,599 speedup is 0.99
|
package/custom/ChatSurface.vue
CHANGED
|
@@ -33,11 +33,13 @@
|
|
|
33
33
|
|
|
34
34
|
<div
|
|
35
35
|
class="w-full h-full flex flex-col"
|
|
36
|
-
:class="{ 'ml-4': agentStore.isFullScreen }"
|
|
37
36
|
>
|
|
38
|
-
<div
|
|
37
|
+
<div
|
|
38
|
+
class="flex items-center justify-between h-14 border-b border-gray-200 dark:border-gray-700"
|
|
39
|
+
:class="{ 'pl-4': agentStore.isFullScreen }"
|
|
40
|
+
>
|
|
39
41
|
<div
|
|
40
|
-
class="flex items-center
|
|
42
|
+
class="flex items-center"
|
|
41
43
|
>
|
|
42
44
|
<IconBarsOutline
|
|
43
45
|
class="m-2 w-8 h-8 p-1 cursor-pointer hover:scale-110 rounded transition-colors duration-200
|
|
@@ -99,9 +101,11 @@
|
|
|
99
101
|
/>
|
|
100
102
|
|
|
101
103
|
<div
|
|
102
|
-
class="w-full mb-2 flex items-center justify-center px-2 bg-transparent relative"
|
|
103
|
-
:
|
|
104
|
-
|
|
104
|
+
class="w-full mb-2 flex items-center justify-center px-2 bg-transparent relative translate-x-[-50%] left-1/2"
|
|
105
|
+
:style="{
|
|
106
|
+
maxWidth: agentStore.isFullScreen ? agentStore.MAX_WIDTH+'px' : '100%',
|
|
107
|
+
transition: `transform ${agentTransitions.TRANSITION_DURATION}ms ease-in-out`
|
|
108
|
+
}"
|
|
105
109
|
>
|
|
106
110
|
<textarea
|
|
107
111
|
v-model="agentStore.userMessageInput"
|
|
@@ -121,7 +125,7 @@
|
|
|
121
125
|
>
|
|
122
126
|
<button
|
|
123
127
|
aria-label="Select mode"
|
|
124
|
-
class="flex h-
|
|
128
|
+
class="flex h-9 w-9 items-center justify-center rounded-md border border-gray-200 bg-white text-lightNavbarIcons transition-colors duration-200 hover:bg-gray-100 dark:border-gray-600 dark:bg-gray-800 dark:text-darkNavbarIcons dark:hover:bg-gray-700"
|
|
125
129
|
:class="isModeMenuOpen ? 'bg-gray-100 dark:bg-gray-700' : ''"
|
|
126
130
|
:disabled="agentStore.isResponseInProgress"
|
|
127
131
|
title="Select mode"
|
|
@@ -148,7 +152,7 @@
|
|
|
148
152
|
</div>
|
|
149
153
|
</div>
|
|
150
154
|
<Button
|
|
151
|
-
class="absolute right-4 bottom-2 !p-0 h-
|
|
155
|
+
class="absolute right-4 bottom-2 !p-0 h-9 w-9"
|
|
152
156
|
@click="sendMessage"
|
|
153
157
|
:disabled="!agentStore.trimmedUserMessage || agentStore.isResponseInProgress"
|
|
154
158
|
>
|
|
@@ -193,7 +197,6 @@ const agentStore = useAgentStore();
|
|
|
193
197
|
const agentTransitions = useAgentTransitions();
|
|
194
198
|
const coreStore = useCoreStore();
|
|
195
199
|
const isModeMenuOpen = ref(false);
|
|
196
|
-
|
|
197
200
|
let startX = 0
|
|
198
201
|
let startWidth = 0
|
|
199
202
|
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
2
|
+
<button @click="scrollContainer.scrollToBottom()">
|
|
3
|
+
<IconArrowDownOutline
|
|
4
|
+
class="absolute z-10 bottom-32 left-1/2 bg-lightPrimary dark:bg-darkPrimary text-white p-2 w-10 h-10 rounded-full transition-opacity duration-100 ease-in"
|
|
5
|
+
:class="showScrollToBottomButton ? 'opacity-100' : 'opacity-0 pointer-events-none'"
|
|
6
|
+
:disabled="!showScrollToBottomButton"
|
|
7
|
+
/>
|
|
8
|
+
</button>
|
|
9
|
+
|
|
3
10
|
<SessionsHistory
|
|
4
11
|
:class="agentStore.isSessionHistoryOpen ? 'translate-x-0' : '-translate-x-full'"
|
|
5
12
|
/>
|
|
@@ -12,24 +19,19 @@
|
|
|
12
19
|
</div>
|
|
13
20
|
<AutoScrollContainer
|
|
14
21
|
:enabled="!showScrollToBottomButton"
|
|
15
|
-
class="relative flex flex-col overflow-y-auto"
|
|
22
|
+
class="relative flex flex-col overflow-y-auto translate-x-[-50%] left-1/2"
|
|
16
23
|
ref="scrollContainer"
|
|
17
24
|
:threshold="10"
|
|
18
25
|
behavior="smooth"
|
|
19
|
-
:class="agentStore.isFullScreen ? 'mx-auto' : ''"
|
|
20
26
|
:style="{
|
|
21
27
|
maxWidth: agentStore.isFullScreen ? agentStore.MAX_WIDTH+'px' : '100%',
|
|
22
|
-
transition: `
|
|
28
|
+
transition: `
|
|
29
|
+
max-width ${agentTransitions.TRANSITION_DURATION}ms ease-in-out,
|
|
30
|
+
transform ${agentTransitions.TRANSITION_DURATION}ms ease-in-out
|
|
31
|
+
`
|
|
23
32
|
}"
|
|
24
33
|
>
|
|
25
34
|
|
|
26
|
-
<button @click="scrollContainer.scrollToBottom()">
|
|
27
|
-
<IconArrowDownOutline
|
|
28
|
-
class="fixed bottom-32 left-1/2 bg-lightPrimary dark:bg-darkPrimary text-white p-2 w-10 h-10 rounded-full transition-opacity duration-100 ease-in"
|
|
29
|
-
:class="showScrollToBottomButton ? 'opacity-100' : 'opacity-0 pointer-events-none'"
|
|
30
|
-
:disabled="!showScrollToBottomButton"
|
|
31
|
-
/>
|
|
32
|
-
</button>
|
|
33
35
|
<div
|
|
34
36
|
v-for="message in props.messages" :key="message.id"
|
|
35
37
|
class="flex flex-col w-full"
|
|
@@ -23,12 +23,15 @@
|
|
|
23
23
|
<button
|
|
24
24
|
v-for="session in group.sessions"
|
|
25
25
|
:key="session.sessionId"
|
|
26
|
-
class="flex items-center justify-between w-full px-4 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors duration-200 ease-in-out text-gray-800 dark:text-gray-200
|
|
27
|
-
:class="{
|
|
26
|
+
class="flex items-center justify-between w-full px-4 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors duration-200 ease-in-out text-gray-800 dark:text-gray-200"
|
|
27
|
+
:class="{
|
|
28
|
+
'bg-lightPrimary/20 hover:bg-lightPrimary/20 dark:bg-darkPrimary/20 dark:hover:bg-darkPrimary/20': agentStore.activeSessionId === session.sessionId,
|
|
29
|
+
'cursor-default opacity-50 pointer-events-none': agentStore.isResponseInProgress
|
|
30
|
+
}"
|
|
28
31
|
@click="agentStore.setActiveSession(session.sessionId); agentStore.setSessionHistoryOpen(false);"
|
|
29
32
|
:disabled="agentStore.isResponseInProgress"
|
|
30
33
|
>
|
|
31
|
-
{{ session.title || session.sessionId }}
|
|
34
|
+
<p class="truncate">{{ session.title || session.sessionId }}</p>
|
|
32
35
|
<div @click.stop="agentStore.deleteSession(session.sessionId)" class="w-7 h-7 p-1 hover:scale-110 hover:bg-gray-200 dark:hover:bg-gray-500 flex items-center justify-center rounded">
|
|
33
36
|
<IconPlusOutline class="rotate-45 w-6 h-6"/>
|
|
34
37
|
</div>
|
|
@@ -4,7 +4,7 @@ import { useAgentStore } from './useAgentStore';
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export const useAgentTransitions = defineStore('agentTransitions', () => {
|
|
7
|
-
const TRANSITION_DURATION =
|
|
7
|
+
const TRANSITION_DURATION = 300;
|
|
8
8
|
|
|
9
9
|
const agentStore = useAgentStore();
|
|
10
10
|
const appRoot = ref<HTMLElement | null>(null);
|
|
@@ -35,6 +35,13 @@ export const DEFAULT_AGENT_SYSTEM_PROMPT = [
|
|
|
35
35
|
"If the plan changes, expands, or you want to do anything beyond the confirmed plan, ask for confirmation again.",
|
|
36
36
|
"Do not reuse an old confirmation for a new mutation plan.",
|
|
37
37
|
].join(" ");
|
|
38
|
+
export function appendCustomSystemPrompt(systemPrompt, customSystemPrompt) {
|
|
39
|
+
const normalizedCustomSystemPrompt = customSystemPrompt === null || customSystemPrompt === void 0 ? void 0 : customSystemPrompt.trim();
|
|
40
|
+
if (!normalizedCustomSystemPrompt) {
|
|
41
|
+
return systemPrompt;
|
|
42
|
+
}
|
|
43
|
+
return `${systemPrompt}\n\n${normalizedCustomSystemPrompt}`;
|
|
44
|
+
}
|
|
38
45
|
function formatResources(resources) {
|
|
39
46
|
return resources
|
|
40
47
|
.map((resource) => `- resourceId: ${resource.resourceId}\n label: ${resource.label}`)
|
|
@@ -33,11 +33,13 @@
|
|
|
33
33
|
|
|
34
34
|
<div
|
|
35
35
|
class="w-full h-full flex flex-col"
|
|
36
|
-
:class="{ 'ml-4': agentStore.isFullScreen }"
|
|
37
36
|
>
|
|
38
|
-
<div
|
|
37
|
+
<div
|
|
38
|
+
class="flex items-center justify-between h-14 border-b border-gray-200 dark:border-gray-700"
|
|
39
|
+
:class="{ 'pl-4': agentStore.isFullScreen }"
|
|
40
|
+
>
|
|
39
41
|
<div
|
|
40
|
-
class="flex items-center
|
|
42
|
+
class="flex items-center"
|
|
41
43
|
>
|
|
42
44
|
<IconBarsOutline
|
|
43
45
|
class="m-2 w-8 h-8 p-1 cursor-pointer hover:scale-110 rounded transition-colors duration-200
|
|
@@ -99,9 +101,11 @@
|
|
|
99
101
|
/>
|
|
100
102
|
|
|
101
103
|
<div
|
|
102
|
-
class="w-full mb-2 flex items-center justify-center px-2 bg-transparent relative"
|
|
103
|
-
:
|
|
104
|
-
|
|
104
|
+
class="w-full mb-2 flex items-center justify-center px-2 bg-transparent relative translate-x-[-50%] left-1/2"
|
|
105
|
+
:style="{
|
|
106
|
+
maxWidth: agentStore.isFullScreen ? agentStore.MAX_WIDTH+'px' : '100%',
|
|
107
|
+
transition: `transform ${agentTransitions.TRANSITION_DURATION}ms ease-in-out`
|
|
108
|
+
}"
|
|
105
109
|
>
|
|
106
110
|
<textarea
|
|
107
111
|
v-model="agentStore.userMessageInput"
|
|
@@ -121,7 +125,7 @@
|
|
|
121
125
|
>
|
|
122
126
|
<button
|
|
123
127
|
aria-label="Select mode"
|
|
124
|
-
class="flex h-
|
|
128
|
+
class="flex h-9 w-9 items-center justify-center rounded-md border border-gray-200 bg-white text-lightNavbarIcons transition-colors duration-200 hover:bg-gray-100 dark:border-gray-600 dark:bg-gray-800 dark:text-darkNavbarIcons dark:hover:bg-gray-700"
|
|
125
129
|
:class="isModeMenuOpen ? 'bg-gray-100 dark:bg-gray-700' : ''"
|
|
126
130
|
:disabled="agentStore.isResponseInProgress"
|
|
127
131
|
title="Select mode"
|
|
@@ -148,7 +152,7 @@
|
|
|
148
152
|
</div>
|
|
149
153
|
</div>
|
|
150
154
|
<Button
|
|
151
|
-
class="absolute right-4 bottom-2 !p-0 h-
|
|
155
|
+
class="absolute right-4 bottom-2 !p-0 h-9 w-9"
|
|
152
156
|
@click="sendMessage"
|
|
153
157
|
:disabled="!agentStore.trimmedUserMessage || agentStore.isResponseInProgress"
|
|
154
158
|
>
|
|
@@ -193,7 +197,6 @@ const agentStore = useAgentStore();
|
|
|
193
197
|
const agentTransitions = useAgentTransitions();
|
|
194
198
|
const coreStore = useCoreStore();
|
|
195
199
|
const isModeMenuOpen = ref(false);
|
|
196
|
-
|
|
197
200
|
let startX = 0
|
|
198
201
|
let startWidth = 0
|
|
199
202
|
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
2
|
+
<button @click="scrollContainer.scrollToBottom()">
|
|
3
|
+
<IconArrowDownOutline
|
|
4
|
+
class="absolute z-10 bottom-32 left-1/2 bg-lightPrimary dark:bg-darkPrimary text-white p-2 w-10 h-10 rounded-full transition-opacity duration-100 ease-in"
|
|
5
|
+
:class="showScrollToBottomButton ? 'opacity-100' : 'opacity-0 pointer-events-none'"
|
|
6
|
+
:disabled="!showScrollToBottomButton"
|
|
7
|
+
/>
|
|
8
|
+
</button>
|
|
9
|
+
|
|
3
10
|
<SessionsHistory
|
|
4
11
|
:class="agentStore.isSessionHistoryOpen ? 'translate-x-0' : '-translate-x-full'"
|
|
5
12
|
/>
|
|
@@ -12,24 +19,19 @@
|
|
|
12
19
|
</div>
|
|
13
20
|
<AutoScrollContainer
|
|
14
21
|
:enabled="!showScrollToBottomButton"
|
|
15
|
-
class="relative flex flex-col overflow-y-auto"
|
|
22
|
+
class="relative flex flex-col overflow-y-auto translate-x-[-50%] left-1/2"
|
|
16
23
|
ref="scrollContainer"
|
|
17
24
|
:threshold="10"
|
|
18
25
|
behavior="smooth"
|
|
19
|
-
:class="agentStore.isFullScreen ? 'mx-auto' : ''"
|
|
20
26
|
:style="{
|
|
21
27
|
maxWidth: agentStore.isFullScreen ? agentStore.MAX_WIDTH+'px' : '100%',
|
|
22
|
-
transition: `
|
|
28
|
+
transition: `
|
|
29
|
+
max-width ${agentTransitions.TRANSITION_DURATION}ms ease-in-out,
|
|
30
|
+
transform ${agentTransitions.TRANSITION_DURATION}ms ease-in-out
|
|
31
|
+
`
|
|
23
32
|
}"
|
|
24
33
|
>
|
|
25
34
|
|
|
26
|
-
<button @click="scrollContainer.scrollToBottom()">
|
|
27
|
-
<IconArrowDownOutline
|
|
28
|
-
class="fixed bottom-32 left-1/2 bg-lightPrimary dark:bg-darkPrimary text-white p-2 w-10 h-10 rounded-full transition-opacity duration-100 ease-in"
|
|
29
|
-
:class="showScrollToBottomButton ? 'opacity-100' : 'opacity-0 pointer-events-none'"
|
|
30
|
-
:disabled="!showScrollToBottomButton"
|
|
31
|
-
/>
|
|
32
|
-
</button>
|
|
33
35
|
<div
|
|
34
36
|
v-for="message in props.messages" :key="message.id"
|
|
35
37
|
class="flex flex-col w-full"
|
|
@@ -23,12 +23,15 @@
|
|
|
23
23
|
<button
|
|
24
24
|
v-for="session in group.sessions"
|
|
25
25
|
:key="session.sessionId"
|
|
26
|
-
class="flex items-center justify-between w-full px-4 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors duration-200 ease-in-out text-gray-800 dark:text-gray-200
|
|
27
|
-
:class="{
|
|
26
|
+
class="flex items-center justify-between w-full px-4 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors duration-200 ease-in-out text-gray-800 dark:text-gray-200"
|
|
27
|
+
:class="{
|
|
28
|
+
'bg-lightPrimary/20 hover:bg-lightPrimary/20 dark:bg-darkPrimary/20 dark:hover:bg-darkPrimary/20': agentStore.activeSessionId === session.sessionId,
|
|
29
|
+
'cursor-default opacity-50 pointer-events-none': agentStore.isResponseInProgress
|
|
30
|
+
}"
|
|
28
31
|
@click="agentStore.setActiveSession(session.sessionId); agentStore.setSessionHistoryOpen(false);"
|
|
29
32
|
:disabled="agentStore.isResponseInProgress"
|
|
30
33
|
>
|
|
31
|
-
{{ session.title || session.sessionId }}
|
|
34
|
+
<p class="truncate">{{ session.title || session.sessionId }}</p>
|
|
32
35
|
<div @click.stop="agentStore.deleteSession(session.sessionId)" class="w-7 h-7 p-1 hover:scale-110 hover:bg-gray-200 dark:hover:bg-gray-500 flex items-center justify-center rounded">
|
|
33
36
|
<IconPlusOutline class="rotate-45 w-6 h-6"/>
|
|
34
37
|
</div>
|
|
@@ -4,7 +4,7 @@ import { useAgentStore } from './useAgentStore';
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export const useAgentTransitions = defineStore('agentTransitions', () => {
|
|
7
|
-
const TRANSITION_DURATION =
|
|
7
|
+
const TRANSITION_DURATION = 300;
|
|
8
8
|
|
|
9
9
|
const agentStore = useAgentStore();
|
|
10
10
|
const appRoot = ref<HTMLElement | null>(null);
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import { HumanMessage, SystemMessage } from "langchain";
|
|
|
20
20
|
import { createAgentChatModel, callAgent } from "./agent/simpleAgent.js";
|
|
21
21
|
import { createSequenceDebugCollector } from "./agent/middleware/sequenceDebug.js";
|
|
22
22
|
import { prepareApiBasedTools as buildApiBasedTools, } from './apiBasedTools.js';
|
|
23
|
-
import { buildAgentSystemPrompt, DEFAULT_AGENT_SYSTEM_PROMPT, } from "./agent/systemPrompt.js";
|
|
23
|
+
import { appendCustomSystemPrompt, buildAgentSystemPrompt, DEFAULT_AGENT_SYSTEM_PROMPT, } from "./agent/systemPrompt.js";
|
|
24
24
|
import { ALWAYS_AVAILABLE_API_TOOL_NAMES } from "./agent/tools/index.js";
|
|
25
25
|
function isAggregateErrorLike(error) {
|
|
26
26
|
return typeof error === "object" && error !== null && Array.isArray(error.errors);
|
|
@@ -91,8 +91,8 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
|
|
|
91
91
|
constructor(options) {
|
|
92
92
|
super(options, import.meta.url);
|
|
93
93
|
this.apiBasedTools = {};
|
|
94
|
-
this.agentSystemPromptPromise = Promise.resolve(DEFAULT_AGENT_SYSTEM_PROMPT);
|
|
95
94
|
this.options = options;
|
|
95
|
+
this.agentSystemPromptPromise = Promise.resolve(appendCustomSystemPrompt(DEFAULT_AGENT_SYSTEM_PROMPT, this.options.systemPrompt));
|
|
96
96
|
this.shouldHaveSingleInstancePerWholeApp = () => false;
|
|
97
97
|
}
|
|
98
98
|
modifyResourceConfig(adminforth, resourceConfig) {
|
|
@@ -127,7 +127,8 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
|
|
|
127
127
|
assertRequiredApiTool(this.apiBasedTools, toolName);
|
|
128
128
|
}
|
|
129
129
|
assertRequiredApiTool(this.apiBasedTools, "update_record");
|
|
130
|
-
this.agentSystemPromptPromise = buildAgentSystemPrompt(adminforth)
|
|
130
|
+
this.agentSystemPromptPromise = buildAgentSystemPrompt(adminforth)
|
|
131
|
+
.then((systemPrompt) => appendCustomSystemPrompt(systemPrompt, this.options.systemPrompt));
|
|
131
132
|
}
|
|
132
133
|
instanceUniqueRepresentation(pluginOptions) {
|
|
133
134
|
return `single`;
|
|
@@ -406,7 +407,7 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
|
|
|
406
407
|
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser }) {
|
|
407
408
|
const triggerMessage = body.triggerMessage;
|
|
408
409
|
const userId = adminUser.pk;
|
|
409
|
-
const title = triggerMessage ? (triggerMessage.length > 40 ? triggerMessage.slice(0, 40)
|
|
410
|
+
const title = triggerMessage ? (triggerMessage.length > 40 ? triggerMessage.slice(0, 40) : triggerMessage) : 'New Session';
|
|
410
411
|
const newSession = {
|
|
411
412
|
[this.pluginOptions.sessionResource.idField]: randomUUID(),
|
|
412
413
|
[this.pluginOptions.sessionResource.titleField]: title,
|
package/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
} from './apiBasedTools.js';
|
|
17
17
|
import type { ApiBasedTool } from './apiBasedTools.js';
|
|
18
18
|
import {
|
|
19
|
+
appendCustomSystemPrompt,
|
|
19
20
|
buildAgentSystemPrompt,
|
|
20
21
|
DEFAULT_AGENT_SYSTEM_PROMPT,
|
|
21
22
|
} from "./agent/systemPrompt.js";
|
|
@@ -67,7 +68,7 @@ function assertRequiredApiTool(
|
|
|
67
68
|
export default class AdminForthAgentPlugin extends AdminForthPlugin {
|
|
68
69
|
options: PluginOptions;
|
|
69
70
|
apiBasedTools: Record<string, ApiBasedTool> = {};
|
|
70
|
-
agentSystemPromptPromise
|
|
71
|
+
agentSystemPromptPromise: Promise<string>;
|
|
71
72
|
|
|
72
73
|
private async createNewTurn(sessionId: string, prompt: string, response?: string) {
|
|
73
74
|
const turnId = randomUUID();
|
|
@@ -109,6 +110,9 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
|
|
|
109
110
|
constructor(options: PluginOptions) {
|
|
110
111
|
super(options, import.meta.url);
|
|
111
112
|
this.options = options;
|
|
113
|
+
this.agentSystemPromptPromise = Promise.resolve(
|
|
114
|
+
appendCustomSystemPrompt(DEFAULT_AGENT_SYSTEM_PROMPT, this.options.systemPrompt),
|
|
115
|
+
);
|
|
112
116
|
this.shouldHaveSingleInstancePerWholeApp = () => false;
|
|
113
117
|
}
|
|
114
118
|
|
|
@@ -139,7 +143,8 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
|
|
|
139
143
|
assertRequiredApiTool(this.apiBasedTools, toolName);
|
|
140
144
|
}
|
|
141
145
|
assertRequiredApiTool(this.apiBasedTools, "update_record");
|
|
142
|
-
this.agentSystemPromptPromise = buildAgentSystemPrompt(adminforth)
|
|
146
|
+
this.agentSystemPromptPromise = buildAgentSystemPrompt(adminforth)
|
|
147
|
+
.then((systemPrompt) => appendCustomSystemPrompt(systemPrompt, this.options.systemPrompt));
|
|
143
148
|
}
|
|
144
149
|
|
|
145
150
|
instanceUniqueRepresentation(pluginOptions: any) : string {
|
|
@@ -442,7 +447,7 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
|
|
|
442
447
|
handler: async ({body, adminUser }) => {
|
|
443
448
|
const triggerMessage = body.triggerMessage;
|
|
444
449
|
const userId = adminUser.pk;
|
|
445
|
-
const title = triggerMessage ? (triggerMessage.length > 40 ? triggerMessage.slice(0, 40)
|
|
450
|
+
const title = triggerMessage ? (triggerMessage.length > 40 ? triggerMessage.slice(0, 40) : triggerMessage) : 'New Session';
|
|
446
451
|
const newSession = {
|
|
447
452
|
[this.pluginOptions.sessionResource.idField]: randomUUID(),
|
|
448
453
|
[this.pluginOptions.sessionResource.titleField]: title,
|
package/package.json
CHANGED
package/types.ts
CHANGED
|
@@ -50,6 +50,11 @@ export interface PluginOptions extends PluginsCommonOptions {
|
|
|
50
50
|
*/
|
|
51
51
|
maxTokens?: number;
|
|
52
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Optional custom system prompt appended to the built-in agent system prompt.
|
|
55
|
+
*/
|
|
56
|
+
systemPrompt?: string;
|
|
57
|
+
|
|
53
58
|
/**
|
|
54
59
|
* Response generation level.
|
|
55
60
|
* Default is low
|