mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-24 22:09:08 +08:00
feat: support chatting in center peek (#7601)
This commit is contained in:
@@ -24,6 +24,7 @@ export type TextToTextOptions = {
|
||||
signal?: AbortSignal;
|
||||
retry?: boolean;
|
||||
workflow?: boolean;
|
||||
isRootSession?: boolean;
|
||||
postfix?: (text: string) => string;
|
||||
};
|
||||
|
||||
@@ -151,6 +152,7 @@ export function textToText({
|
||||
timeout = TIMEOUT,
|
||||
retry = false,
|
||||
workflow = false,
|
||||
isRootSession = false,
|
||||
postfix,
|
||||
}: TextToTextOptions) {
|
||||
let _sessionId: string;
|
||||
@@ -188,6 +190,9 @@ export function textToText({
|
||||
workflow ? 'workflow' : undefined
|
||||
);
|
||||
AIProvider.LAST_ACTION_SESSIONID = _sessionId;
|
||||
if (isRootSession) {
|
||||
AIProvider.LAST_ROOT_SESSION_ID = _sessionId;
|
||||
}
|
||||
|
||||
if (signal) {
|
||||
if (signal.aborted) {
|
||||
@@ -250,6 +255,10 @@ export function textToText({
|
||||
}
|
||||
|
||||
AIProvider.LAST_ACTION_SESSIONID = _sessionId;
|
||||
if (isRootSession) {
|
||||
AIProvider.LAST_ROOT_SESSION_ID = _sessionId;
|
||||
}
|
||||
|
||||
return client.chatText({
|
||||
sessionId: _sessionId,
|
||||
messageId: _messageId,
|
||||
|
||||
+2
-1
@@ -77,7 +77,8 @@ function setupAIProvider() {
|
||||
|
||||
//#region actions
|
||||
AIProvider.provide('chat', options => {
|
||||
const sessionId = getChatSessionId(options.workspaceId, options.docId);
|
||||
const sessionId =
|
||||
options.sessionId ?? getChatSessionId(options.workspaceId, options.docId);
|
||||
return textToText({
|
||||
...options,
|
||||
content: options.input,
|
||||
|
||||
@@ -18,13 +18,15 @@ type AIActionEventProperties = {
|
||||
| 'AI action panel'
|
||||
| 'right side bar'
|
||||
| 'inline chat panel'
|
||||
| 'AI result panel';
|
||||
| 'AI result panel'
|
||||
| 'AI chat block';
|
||||
module:
|
||||
| 'exit confirmation'
|
||||
| 'AI action panel'
|
||||
| 'AI chat panel'
|
||||
| 'inline chat panel'
|
||||
| 'AI result panel';
|
||||
| 'AI result panel'
|
||||
| 'AI chat block';
|
||||
control:
|
||||
| 'stop button'
|
||||
| 'format toolbar'
|
||||
@@ -139,6 +141,8 @@ function inferSegment(
|
||||
return 'AI result panel';
|
||||
} else if (event.options.where === 'chat-panel') {
|
||||
return 'right side bar';
|
||||
} else if (event.options.where === 'ai-chat-block') {
|
||||
return 'AI chat block';
|
||||
} else {
|
||||
return 'AI action panel';
|
||||
}
|
||||
@@ -155,6 +159,8 @@ function inferModule(
|
||||
return 'AI result panel';
|
||||
} else if (event.options.where === 'inline-chat-panel') {
|
||||
return 'inline chat panel';
|
||||
} else if (event.options.where === 'ai-chat-block') {
|
||||
return 'AI chat block';
|
||||
} else {
|
||||
return 'AI action panel';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user