fix: M-CHAT-A3 createSession 支持 forceCreate 参数
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 42s
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 42s
forceCreate=true 时跳过 open-or-create 查找,强制创建新会话。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
fe44dec567
commit
55e25f347e
@ -15,6 +15,7 @@ export interface CreateSessionParams {
|
|||||||
parentKnowledgeBaseId?: string | null;
|
parentKnowledgeBaseId?: string | null;
|
||||||
createdFrom?: string;
|
createdFrom?: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
|
forceCreate?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateSessionResult {
|
export interface CreateSessionResult {
|
||||||
@ -33,7 +34,7 @@ export class RagChatService {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
async createSession(userId: string, params: CreateSessionParams): Promise<CreateSessionResult> {
|
async createSession(userId: string, params: CreateSessionParams): Promise<CreateSessionResult> {
|
||||||
const { scopeType, scopeId, parentKnowledgeBaseId, createdFrom, title } = params;
|
const { scopeType, scopeId, parentKnowledgeBaseId, createdFrom, title, forceCreate } = params;
|
||||||
|
|
||||||
if (!VALID_SCOPE_TYPES.includes(scopeType)) {
|
if (!VALID_SCOPE_TYPES.includes(scopeType)) {
|
||||||
throw new BadRequestException(`scopeType must be one of: ${VALID_SCOPE_TYPES.join(', ')}`);
|
throw new BadRequestException(`scopeType must be one of: ${VALID_SCOPE_TYPES.join(', ')}`);
|
||||||
@ -44,8 +45,8 @@ export class RagChatService {
|
|||||||
|
|
||||||
const derivedKbId = this.deriveParentKbId(scopeType, scopeId, parentKnowledgeBaseId);
|
const derivedKbId = this.deriveParentKbId(scopeType, scopeId, parentKnowledgeBaseId);
|
||||||
|
|
||||||
// open-or-create: for non-global scopes, try to find an existing active session
|
// open-or-create: for non-global scopes, skip lookup when forceCreate
|
||||||
if (scopeType !== 'global' && scopeId) {
|
if (!forceCreate && scopeType !== 'global' && scopeId) {
|
||||||
const existing = await this.prisma.chatSession.findFirst({
|
const existing = await this.prisma.chatSession.findFirst({
|
||||||
where: {
|
where: {
|
||||||
userId,
|
userId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user