mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-19 02:56:23 +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:
@@ -141,16 +141,13 @@ export class ChatSession implements AsyncDisposable {
|
||||
return ret;
|
||||
}
|
||||
|
||||
finish(params: PromptParams): PromptMessage[] {
|
||||
const messages = this.takeMessages();
|
||||
private mergeUserContent(params: PromptParams) {
|
||||
const messages = this.stashMessages;
|
||||
const firstMessage = messages.at(0);
|
||||
// TODO: refactor this {{content}} keyword agreement
|
||||
// if the message in prompt config contains {{content}},
|
||||
// we should combine it with the user message in the prompt
|
||||
if (
|
||||
messages.length === 1 &&
|
||||
firstMessage &&
|
||||
this.state.prompt.paramKeys.includes('content')
|
||||
this.state.prompt.paramKeys.includes('content') &&
|
||||
!messages.some(m => m.role === AiPromptRole.assistant) &&
|
||||
firstMessage
|
||||
) {
|
||||
const normalizedParams = {
|
||||
...params,
|
||||
@@ -178,7 +175,18 @@ export class ChatSession implements AsyncDisposable {
|
||||
|
||||
return finished;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
finish(params: PromptParams): PromptMessage[] {
|
||||
// if the message in prompt config contains {{content}},
|
||||
// we should combine it with the user message in the prompt
|
||||
const mergedMessage = this.mergeUserContent(params);
|
||||
if (mergedMessage) {
|
||||
return mergedMessage;
|
||||
}
|
||||
|
||||
const messages = this.takeMessages();
|
||||
const lastMessage = messages.at(-1);
|
||||
return [
|
||||
...this.state.prompt.finish(
|
||||
|
||||
Reference in New Issue
Block a user