feat(chat): render commercial actions and persist greetings
Docker Image / Build and Push Docker Image (push) Successful in 1m56s
Docker Image / Build and Push Docker Image (push) Successful in 1m56s
This commit is contained in:
@@ -7,6 +7,8 @@ import {
|
||||
ChatHistoryResponse,
|
||||
ChatPreviewsResponse,
|
||||
ChatSendResponse,
|
||||
OpeningMessageRequestSchema,
|
||||
OpeningMessageResponse,
|
||||
SendMessageRequestSchema,
|
||||
UnlockHistoryRequestSchema,
|
||||
UnlockHistoryResponse,
|
||||
@@ -50,6 +52,19 @@ export class ChatRemoteDataSource {
|
||||
});
|
||||
}
|
||||
|
||||
async saveOpeningMessage(
|
||||
characterId: string,
|
||||
openingMessage: string,
|
||||
options?: ChatRequestOptions,
|
||||
): Promise<Result<OpeningMessageResponse>> {
|
||||
return Result.wrap(() =>
|
||||
this.api.saveOpeningMessage(
|
||||
OpeningMessageRequestSchema.parse({ characterId, openingMessage }),
|
||||
options,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
async getPreviews(
|
||||
options?: ChatRequestOptions,
|
||||
): Promise<Result<ChatPreviewsResponse>> {
|
||||
|
||||
@@ -12,6 +12,7 @@ import type {
|
||||
ChatPreviewsResponse,
|
||||
ChatMessage,
|
||||
ChatSendResponse,
|
||||
OpeningMessageResponse,
|
||||
UnlockHistoryResponse,
|
||||
UnlockPrivateResponse,
|
||||
} from "@/data/schemas/chat";
|
||||
@@ -46,6 +47,18 @@ export class ChatRepository implements IChatRepository {
|
||||
return this.remote.sendMessage(characterId, message, options);
|
||||
}
|
||||
|
||||
async saveOpeningMessage(
|
||||
characterId: string,
|
||||
openingMessage: string,
|
||||
options?: ChatRequestOptions,
|
||||
): Promise<Result<OpeningMessageResponse>> {
|
||||
return this.remote.saveOpeningMessage(
|
||||
characterId,
|
||||
openingMessage,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
/** 获取聊天历史,分页参数默认 limit=50, offset=0。 */
|
||||
async getHistory(
|
||||
characterId: string,
|
||||
|
||||
@@ -13,6 +13,7 @@ import type {
|
||||
ChatMediaKind,
|
||||
ChatMessage,
|
||||
ChatSendResponse,
|
||||
OpeningMessageResponse,
|
||||
UnlockHistoryResponse,
|
||||
UnlockPrivateResponse,
|
||||
} from "@/data/schemas/chat";
|
||||
@@ -65,6 +66,13 @@ export interface IChatRepository {
|
||||
options?: ChatSendOptions,
|
||||
): Promise<Result<ChatSendResponse>>;
|
||||
|
||||
/** 幂等保存角色首次开场白。 */
|
||||
saveOpeningMessage(
|
||||
characterId: string,
|
||||
openingMessage: string,
|
||||
options?: ChatRequestOptions,
|
||||
): Promise<Result<OpeningMessageResponse>>;
|
||||
|
||||
/** 获取聊天历史,分页参数默认 limit=50, offset=0。 */
|
||||
getHistory(
|
||||
characterId: string,
|
||||
|
||||
Reference in New Issue
Block a user