mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 18:26:05 +08:00
feat: support more ai image actions (#7027)
This commit is contained in:
@@ -127,6 +127,7 @@ const blocksuiteFeatureFlags: Partial<Record<keyof BlockSuiteFlags, string>> = {
|
||||
enable_expand_database_block: 'Enable Expand Database Block',
|
||||
enable_database_statistics: 'Enable Database Block Statistics',
|
||||
enable_block_query: 'Enable Todo Block Query',
|
||||
enable_new_image_actions: 'Enable New Image Actions',
|
||||
};
|
||||
|
||||
const BlocksuiteFeatureFlagSettings = () => {
|
||||
|
||||
@@ -7,7 +7,13 @@ export const promptKeys = [
|
||||
'debug:action:dalle3',
|
||||
'debug:action:fal-sd15',
|
||||
'debug:action:fal-upscaler',
|
||||
'debug:action:fal-rembg',
|
||||
'debug:action:fal-remove-bg',
|
||||
'debug:action:fal-sdturbo-clay',
|
||||
'debug:action:fal-sdturbo-pixel',
|
||||
'debug:action:fal-sdturbo-sketch',
|
||||
'debug:action:fal-sdturbo-fantasy',
|
||||
'debug:action:fal-face-to-sticker',
|
||||
'debug:action:fal-summary-caption',
|
||||
'chat:gpt4',
|
||||
'Summary',
|
||||
'Summary the webpage',
|
||||
|
||||
@@ -17,6 +17,23 @@ import {
|
||||
} from './request';
|
||||
import { setupTracker } from './tracker';
|
||||
|
||||
const filterStyleToPromptName = new Map(
|
||||
Object.entries({
|
||||
'Clay style': 'debug:action:fal-sdturbo-clay',
|
||||
'Pixel style': 'debug:action:fal-sdturbo-pixel',
|
||||
'Sketch style': 'debug:action:fal-sdturbo-sketch',
|
||||
'Anime style': 'debug:action:fal-sdturbo-fantasy',
|
||||
})
|
||||
);
|
||||
|
||||
const processTypeToPromptName = new Map(
|
||||
Object.entries({
|
||||
Clearer: 'debug:action:fal-upscaler',
|
||||
'Remove background': 'debug:action:fal-remove-bg',
|
||||
'Convert to sticker': 'debug:action:fal-face-to-sticker',
|
||||
})
|
||||
);
|
||||
|
||||
function setupAIProvider() {
|
||||
// a single workspace should have only a single chat session
|
||||
// user-id:workspace-id:doc-id -> chat session id
|
||||
@@ -290,6 +307,36 @@ Could you make a new website based on these notes and send back just the html fi
|
||||
});
|
||||
});
|
||||
|
||||
AIProvider.provide('filterImage', options => {
|
||||
// test to image
|
||||
const promptName = filterStyleToPromptName.get(
|
||||
options.style as string
|
||||
) as PromptKey;
|
||||
return toImage({
|
||||
...options,
|
||||
promptName,
|
||||
});
|
||||
});
|
||||
|
||||
AIProvider.provide('processImage', options => {
|
||||
// test to image
|
||||
const promptName = processTypeToPromptName.get(
|
||||
options.type as string
|
||||
) as PromptKey;
|
||||
return toImage({
|
||||
...options,
|
||||
promptName,
|
||||
});
|
||||
});
|
||||
|
||||
AIProvider.provide('generateCaption', options => {
|
||||
return textToText({
|
||||
...options,
|
||||
content: options.input,
|
||||
promptName: 'debug:action:fal-summary-caption',
|
||||
});
|
||||
});
|
||||
|
||||
AIProvider.provide('continueWriting', options => {
|
||||
return textToText({
|
||||
...options,
|
||||
|
||||
@@ -34,6 +34,7 @@ type AIActionEventProperties = {
|
||||
| 'login required'
|
||||
| 'insert'
|
||||
| 'replace'
|
||||
| 'use as caption'
|
||||
| 'discard'
|
||||
| 'retry'
|
||||
| 'add note'
|
||||
@@ -195,6 +196,8 @@ function inferControl(
|
||||
return 'insert';
|
||||
} else if (event.event === 'result:replace') {
|
||||
return 'replace';
|
||||
} else if (event.event === 'result:use-as-caption') {
|
||||
return 'use as caption';
|
||||
} else if (event.event === 'result:discard') {
|
||||
return 'discard';
|
||||
} else if (event.event === 'result:retry') {
|
||||
|
||||
Reference in New Issue
Block a user