@@ -17,13 +17,19 @@ import {
17
17
} from '@/libs/agent-runtime' ;
18
18
import { filesPrompts } from '@/prompts/files' ;
19
19
import { BuiltinSystemRolePrompts } from '@/prompts/systemRole' ;
20
- import { aiModelSelectors , aiProviderSelectors , useAiInfraStore } from '@/store/aiInfra' ;
21
- import { getAgentChatConfig } from '@/store/chat/slices/aiChat/actions/helpers' ;
22
- import { useSessionStore } from '@/store/session' ;
20
+ import { getAgentStoreState } from '@/store/agent' ;
21
+ import { agentChatConfigSelectors } from '@/store/agent/selectors' ;
22
+ import {
23
+ aiModelSelectors ,
24
+ aiProviderSelectors ,
25
+ getAiInfraStoreState ,
26
+ useAiInfraStore ,
27
+ } from '@/store/aiInfra' ;
28
+ import { getSessionStoreState } from '@/store/session' ;
23
29
import { sessionMetaSelectors } from '@/store/session/selectors' ;
24
- import { useToolStore } from '@/store/tool' ;
30
+ import { getToolStoreState } from '@/store/tool' ;
25
31
import { pluginSelectors , toolSelectors } from '@/store/tool/selectors' ;
26
- import { useUserStore } from '@/store/user' ;
32
+ import { getUserStoreState , useUserStore } from '@/store/user' ;
27
33
import {
28
34
modelConfigSelectors ,
29
35
modelProviderSelectors ,
@@ -46,10 +52,10 @@ import { API_ENDPOINTS } from './_url';
46
52
const isCanUseFC = ( model : string , provider : string ) => {
47
53
// TODO: remove isDeprecatedEdition condition in V2.0
48
54
if ( isDeprecatedEdition ) {
49
- return modelProviderSelectors . isModelEnabledFunctionCall ( model ) ( useUserStore . getState ( ) ) ;
55
+ return modelProviderSelectors . isModelEnabledFunctionCall ( model ) ( getUserStoreState ( ) ) ;
50
56
}
51
57
52
- return aiModelSelectors . isModelSupportToolUse ( model , provider ) ( useAiInfraStore . getState ( ) ) ;
58
+ return aiModelSelectors . isModelSupportToolUse ( model , provider ) ( getAiInfraStoreState ( ) ) ;
53
59
} ;
54
60
55
61
/**
@@ -169,7 +175,7 @@ class ChatService {
169
175
) ;
170
176
171
177
// =================== 0. process search =================== //
172
- const chatConfig = getAgentChatConfig ( ) ;
178
+ const chatConfig = agentChatConfigSelectors . currentChatConfig ( getAgentStoreState ( ) ) ;
173
179
174
180
const enabledSearch = chatConfig . searchMode !== 'off' ;
175
181
const isModelHasBuiltinSearch = aiModelSelectors . isModelHasBuiltinSearch (
@@ -200,7 +206,7 @@ class ChatService {
200
206
201
207
// ============ 2. preprocess tools ============ //
202
208
203
- let filterTools = toolSelectors . enabledSchema ( pluginIds ) ( useToolStore . getState ( ) ) ;
209
+ let filterTools = toolSelectors . enabledSchema ( pluginIds ) ( getToolStoreState ( ) ) ;
204
210
205
211
// check this model can use function call
206
212
const canUseFC = isCanUseFC ( payload . model , payload . provider ! ) ;
@@ -378,7 +384,7 @@ class ChatService {
378
384
* @param options
379
385
*/
380
386
runPluginApi = async ( params : PluginRequestPayload , options ?: FetchOptions ) => {
381
- const s = useToolStore . getState ( ) ;
387
+ const s = getToolStoreState ( ) ;
382
388
383
389
const settings = pluginSelectors . getPluginSettingsById ( params . identifier ) ( s ) ;
384
390
const manifest = pluginSelectors . getToolManifestById ( params . identifier ) ( s ) ;
@@ -537,7 +543,7 @@ class ChatService {
537
543
const hasTools = tools && tools ?. length > 0 ;
538
544
const hasFC = hasTools && isCanUseFC ( model , provider ) ;
539
545
const toolsSystemRoles =
540
- hasFC && toolSelectors . enabledSystemRoles ( tools ) ( useToolStore . getState ( ) ) ;
546
+ hasFC && toolSelectors . enabledSystemRoles ( tools ) ( getToolStoreState ( ) ) ;
541
547
542
548
const injectSystemRoles = BuiltinSystemRolePrompts ( {
543
549
historySummary : options ?. historySummary ,
@@ -565,9 +571,9 @@ class ChatService {
565
571
} ;
566
572
567
573
private mapTrace = ( trace ?: TracePayload , tag ?: TraceTagMap ) : TracePayload => {
568
- const tags = sessionMetaSelectors . currentAgentMeta ( useSessionStore . getState ( ) ) . tags || [ ] ;
574
+ const tags = sessionMetaSelectors . currentAgentMeta ( getSessionStoreState ( ) ) . tags || [ ] ;
569
575
570
- const enabled = preferenceSelectors . userAllowTrace ( useUserStore . getState ( ) ) ;
576
+ const enabled = preferenceSelectors . userAllowTrace ( getUserStoreState ( ) ) ;
571
577
572
578
if ( ! enabled ) return { ...trace , enabled : false } ;
573
579
0 commit comments