mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-26 10:55:27 +00:00
chore(chat): support isNewChat payload flag and fix any casts
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
type AgentMessage,
|
||||
type AgentTool,
|
||||
type SessionTreeEntry,
|
||||
type AgentMessage,
|
||||
type AgentTool,
|
||||
type SessionTreeEntry,
|
||||
} from '@earendil-works/pi-agent-core'
|
||||
import { type ImageContent } from '@earendil-works/pi-ai'
|
||||
import { assetService } from '@shumai/core/src/asset/asset'
|
||||
@@ -18,10 +18,10 @@ import { generateKeyBetween } from 'jittered-fractional-indexing'
|
||||
import { ulid } from 'ulid'
|
||||
import { DatabaseSessionStorage } from '../database-session-storage'
|
||||
import {
|
||||
createAgentSession,
|
||||
fieldsToTypeBoxSchema,
|
||||
type AutofillField,
|
||||
type DbProviderInfo,
|
||||
createAgentSession,
|
||||
fieldsToTypeBoxSchema,
|
||||
type AutofillField,
|
||||
type DbProviderInfo,
|
||||
} from '../index'
|
||||
|
||||
import { UpdateAssetMetadataRequest } from '@shumai/dtos'
|
||||
|
||||
@@ -135,10 +135,9 @@ export async function createAgentSession(params: CreateAgentSessionParams) {
|
||||
const agentDir = path.join(process.cwd(), '.pi', 'agents', agentId)
|
||||
if (!fs.existsSync(agentDir)) fs.mkdirSync(agentDir, { recursive: true })
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const model =
|
||||
getModelFromDb(params.providers, providerName, modelId) ||
|
||||
(getModel as any)(providerName, modelId)
|
||||
(getModel as unknown as (p: string, m: string) => unknown)(providerName, modelId)
|
||||
|
||||
const piDir = path.join(process.cwd(), '.pi')
|
||||
if (!fs.existsSync(piDir)) fs.mkdirSync(piDir, { recursive: true })
|
||||
|
||||
@@ -92,7 +92,7 @@ export async function agentChat(task: WorkflowTask): Promise<void> {
|
||||
const teamId = asset.project.teamId
|
||||
|
||||
// 4. Initialize Session if missing
|
||||
let isNewChat = !payload.agent?.sessionId
|
||||
let isNewChat = !payload.agent?.sessionId || payload.agent?.isNewChat === true
|
||||
if (!sessionId) {
|
||||
if (!userCommentId) {
|
||||
throw ApplicationFailure.create({
|
||||
|
||||
@@ -302,6 +302,7 @@ export class ChatService {
|
||||
agentId,
|
||||
sessionId: activeSessionId,
|
||||
userId: user.id,
|
||||
isNewChat: !passedSessionId,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -293,6 +293,7 @@ declare global {
|
||||
imageUrls?: string[]
|
||||
attachedFiles?: string[]
|
||||
assetIds?: string[]
|
||||
isNewChat?: boolean
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user