diff --git a/src/store/session/index.ts b/src/store/session/index.ts index 4133688a87c6..95fa0300e11f 100644 --- a/src/store/session/index.ts +++ b/src/store/session/index.ts @@ -33,4 +33,5 @@ export const useSessionStore = create()( export * from './selectors'; export { initialLobeAgentConfig } from './slices/agentConfig'; +export { initLobeSession } from './slices/session'; export type { SessionStore } from './store'; diff --git a/src/store/session/slices/session/action.ts b/src/store/session/slices/session/action.ts index 3e1ab329a421..076cc602210d 100644 --- a/src/store/session/slices/session/action.ts +++ b/src/store/session/slices/session/action.ts @@ -1,9 +1,9 @@ +import { merge } from 'lodash-es'; import Router from 'next/router'; import { StateCreator } from 'zustand/vanilla'; -import { SessionStore } from '@/store/session'; -import { LanguageModel } from '@/types/llm'; -import { LobeAgentSession, LobeSessionType } from '@/types/session'; +import { SessionStore, initLobeSession } from '@/store/session'; +import { LobeAgentSession } from '@/types/session'; import { uuid } from '@/utils/uuid'; import { SessionDispatch, sessionsReducer } from './reducers/session'; @@ -58,21 +58,12 @@ export const createSessionSlice: StateCreator< const timestamp = Date.now(); - const newSession: LobeAgentSession = { - chats: {}, - config: { - model: LanguageModel.GPT3_5, - params: { - temperature: 0.6, - }, - systemRole: '', - }, + // TODO: 等 settings 里的 defaultAgent 都改好以后,做个合并即可 + const newSession: LobeAgentSession = merge({}, initLobeSession, { createAt: timestamp, id: uuid(), - meta: {}, - type: LobeSessionType.Agent, updateAt: timestamp, - }; + }); dispatchSession({ session: newSession, type: 'addSession' });