mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 02:42:25 +08:00
feat(server): switch i2i to gpt (#12238)
fix AI-14 fix AI-17 fix AI-39 fix AI-112 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Expanded and reorganized prompt options for text and image actions, adding new prompts for image generation, style conversions, upscaling, background removal, and sticker creation. - Enhanced image editing capabilities with direct support for image attachments in prompts. - **Improvements** - Updated prompt names and descriptions to be more user-friendly and descriptive. - Simplified and clarified prompt selection and image processing workflows with improved default behaviors. - Better organization of prompts through clear grouping and categorization. - **Bug Fixes** - Improved validation and handling of image attachments during editing requests. - **Refactor** - Internal code restructuring of prompts and provider logic for clarity and maintainability without affecting user workflows. - Refined message handling and content merging logic to ensure consistent prompt processing. - Adjusted image attachment rendering logic for improved display consistency. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -20,12 +20,6 @@ type Prompt = Omit<
|
||||
};
|
||||
|
||||
const workflows: Prompt[] = [
|
||||
{
|
||||
name: 'debug:action:fal-teed',
|
||||
action: 'fal-teed',
|
||||
model: 'workflowutils/teed',
|
||||
messages: [{ role: 'user', content: '{{content}}' }],
|
||||
},
|
||||
{
|
||||
name: 'workflow:presentation',
|
||||
action: 'workflow:presentation',
|
||||
@@ -305,48 +299,7 @@ const workflows: Prompt[] = [
|
||||
},
|
||||
];
|
||||
|
||||
const actions: Prompt[] = [
|
||||
{
|
||||
name: 'debug:action:dalle3',
|
||||
action: 'image',
|
||||
model: 'dall-e-3',
|
||||
messages: [],
|
||||
},
|
||||
{
|
||||
name: 'debug:action:gpt-image-1',
|
||||
action: 'image',
|
||||
model: 'gpt-image-1',
|
||||
messages: [],
|
||||
},
|
||||
{
|
||||
name: 'debug:action:fal-sd15',
|
||||
action: 'image',
|
||||
model: 'lcm-sd15-i2i',
|
||||
messages: [],
|
||||
},
|
||||
{
|
||||
name: 'debug:action:fal-upscaler',
|
||||
action: 'Clearer',
|
||||
model: 'clarity-upscaler',
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'best quality, 8K resolution, highres, clarity, {{content}}',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'debug:action:fal-remove-bg',
|
||||
action: 'Remove background',
|
||||
model: 'imageutils/rembg',
|
||||
messages: [],
|
||||
},
|
||||
{
|
||||
name: 'debug:action:fal-face-to-sticker',
|
||||
action: 'Convert to sticker',
|
||||
model: 'face-to-sticker',
|
||||
messages: [],
|
||||
},
|
||||
const textActions: Prompt[] = [
|
||||
{
|
||||
name: 'Transcript audio',
|
||||
action: 'Transcript audio',
|
||||
@@ -1449,6 +1402,161 @@ When sent new notes, respond ONLY with the contents of the html file.`,
|
||||
},
|
||||
];
|
||||
|
||||
const imageActions: Prompt[] = [
|
||||
{
|
||||
name: 'Generate image',
|
||||
action: 'image',
|
||||
model: 'gpt-image-1',
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content: '{{content}}',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Convert to Clay style',
|
||||
action: 'Convert to Clay style',
|
||||
model: 'gpt-image-1',
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content:
|
||||
'Migration style. Migrates the style from the first image to the second. turn to clay/claymation style. {{content}}',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Convert to Sketch style',
|
||||
action: 'Convert to Sketch style',
|
||||
model: 'gpt-image-1',
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'turn to mono-color sketch style. {{content}}',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Convert to Anime style',
|
||||
action: 'Convert to Anime style',
|
||||
model: 'gpt-image-1',
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'turn to Suzume style like anime style. {{content}}',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Convert to Pixel style',
|
||||
action: 'Convert to Pixel style',
|
||||
model: 'gpt-image-1',
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'turn to kairosoft pixel art. {{content}}',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Convert to sticker',
|
||||
action: 'Convert to sticker',
|
||||
model: 'gpt-image-1',
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content:
|
||||
'convert this image to sticker. you need to identify the subject matter and warp a circle of white stroke around the subject matter and with transparent background. {{content}}',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Upscale image',
|
||||
action: 'Upscale image',
|
||||
model: 'gpt-image-1',
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'make the image more detailed. {{content}}',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Remove background',
|
||||
action: 'Remove background',
|
||||
model: 'gpt-image-1',
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content:
|
||||
'Keep the subject and remove other non-subject items. Transparent background. {{content}}',
|
||||
},
|
||||
],
|
||||
},
|
||||
// TODO(@darkskygit): deprecated, remove it after <0.22 version is outdated
|
||||
{
|
||||
name: 'debug:action:fal-remove-bg',
|
||||
action: 'Remove background',
|
||||
model: 'imageutils/rembg',
|
||||
messages: [],
|
||||
},
|
||||
{
|
||||
name: 'debug:action:fal-face-to-sticker',
|
||||
action: 'Convert to sticker',
|
||||
model: 'face-to-sticker',
|
||||
messages: [],
|
||||
},
|
||||
{
|
||||
name: 'debug:action:fal-teed',
|
||||
action: 'fal-teed',
|
||||
model: 'workflowutils/teed',
|
||||
messages: [{ role: 'user', content: '{{content}}' }],
|
||||
},
|
||||
{
|
||||
name: 'debug:action:dalle3',
|
||||
action: 'image',
|
||||
model: 'dall-e-3',
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content: '{{content}}',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'debug:action:gpt-image-1',
|
||||
action: 'image',
|
||||
model: 'gpt-image-1',
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content: '{{content}}',
|
||||
},
|
||||
],
|
||||
config: {
|
||||
requireContent: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'debug:action:fal-sd15',
|
||||
action: 'image',
|
||||
model: 'lcm-sd15-i2i',
|
||||
messages: [],
|
||||
},
|
||||
{
|
||||
name: 'debug:action:fal-upscaler',
|
||||
action: 'Clearer',
|
||||
model: 'clarity-upscaler',
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'best quality, 8K resolution, highres, clarity, {{content}}',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const CHAT_PROMPT: Omit<Prompt, 'name'> = {
|
||||
model: 'gpt-4.1',
|
||||
optionalModels: [
|
||||
@@ -1622,7 +1730,12 @@ const chat: Prompt[] = [
|
||||
},
|
||||
];
|
||||
|
||||
export const prompts: Prompt[] = [...actions, ...chat, ...workflows];
|
||||
export const prompts: Prompt[] = [
|
||||
...textActions,
|
||||
...imageActions,
|
||||
...chat,
|
||||
...workflows,
|
||||
];
|
||||
|
||||
export async function refreshPrompts(db: PrismaClient) {
|
||||
const needToSkip = await db.aiPrompt
|
||||
|
||||
Reference in New Issue
Block a user