mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-11 05:58:56 +08:00
chore(server): update config naming (#13419)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Updated scenario names and options for Copilot, including new and renamed scenarios such as "audio_transcribing," "complex_text_generation," "quick_decision_making," "quick_text_generation," and "polish_and_summarize." * Enhanced support for customizing and overriding default model assignments in Copilot scenarios. * **Bug Fixes** * Improved consistency and clarity in scenario configuration and prompt selection. * **Documentation** * Updated descriptions in configuration interfaces to better explain the ability to use custom models and override defaults. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -669,20 +669,20 @@
|
|||||||
},
|
},
|
||||||
"scenarios": {
|
"scenarios": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "The models used in the scene for the copilot, will use this config if enabled.\n@default {\"enabled\":false,\"scenarios\":{\"audio\":\"gemini-2.5-flash\",\"chat\":\"claude-sonnet-4@20250514\",\"embedding\":\"gemini-embedding-001\",\"image\":\"gpt-image-1\",\"rerank\":\"gpt-4.1\",\"brainstorm\":\"gpt-4o-2024-08-06\",\"coding\":\"claude-sonnet-4@20250514\",\"quick_decision\":\"gpt-4.1-mini\",\"quick_written\":\"gemini-2.5-flash\",\"summary_inspection\":\"gemini-2.5-flash\"}}",
|
"description": "Use custom models in scenarios and override default settings.\n@default {\"override_enabled\":false,\"scenarios\":{\"audio_transcribing\":\"gemini-2.5-flash\",\"chat\":\"claude-sonnet-4@20250514\",\"embedding\":\"gemini-embedding-001\",\"image\":\"gpt-image-1\",\"rerank\":\"gpt-4.1\",\"coding\":\"claude-sonnet-4@20250514\",\"complex_text_generation\":\"gpt-4o-2024-08-06\",\"quick_decision_making\":\"gpt-4.1-mini\",\"quick_text_generation\":\"gemini-2.5-flash\",\"polish_and_summarize\":\"gemini-2.5-flash\"}}",
|
||||||
"default": {
|
"default": {
|
||||||
"enabled": false,
|
"override_enabled": false,
|
||||||
"scenarios": {
|
"scenarios": {
|
||||||
"audio": "gemini-2.5-flash",
|
"audio_transcribing": "gemini-2.5-flash",
|
||||||
"chat": "claude-sonnet-4@20250514",
|
"chat": "claude-sonnet-4@20250514",
|
||||||
"embedding": "gemini-embedding-001",
|
"embedding": "gemini-embedding-001",
|
||||||
"image": "gpt-image-1",
|
"image": "gpt-image-1",
|
||||||
"rerank": "gpt-4.1",
|
"rerank": "gpt-4.1",
|
||||||
"brainstorm": "gpt-4o-2024-08-06",
|
|
||||||
"coding": "claude-sonnet-4@20250514",
|
"coding": "claude-sonnet-4@20250514",
|
||||||
"quick_decision": "gpt-4.1-mini",
|
"complex_text_generation": "gpt-4o-2024-08-06",
|
||||||
"quick_written": "gemini-2.5-flash",
|
"quick_decision_making": "gpt-4.1-mini",
|
||||||
"summary_inspection": "gemini-2.5-flash"
|
"quick_text_generation": "gemini-2.5-flash",
|
||||||
|
"polish_and_summarize": "gemini-2.5-flash"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -117,13 +117,13 @@ test.serial.before(async t => {
|
|||||||
value: {
|
value: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
scenarios: {
|
scenarios: {
|
||||||
image: 'lcm',
|
image: 'flux-1/schnell',
|
||||||
rerank: 'gpt-4.1-mini',
|
rerank: 'gpt-4.1-mini',
|
||||||
brainstorm: 'gpt-4.1-mini',
|
complex_text_generation: 'gpt-4.1-mini',
|
||||||
coding: 'gpt-4.1-mini',
|
coding: 'gpt-4.1-mini',
|
||||||
quick_decision: 'gpt-4.1-mini',
|
quick_decision_making: 'gpt-4.1-mini',
|
||||||
quick_written: 'gpt-4.1-mini',
|
quick_text_generation: 'gpt-4.1-mini',
|
||||||
summary_inspection: 'gemini-2.5-flash',
|
polish_and_summarize: 'gemini-2.5-flash',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -46,20 +46,20 @@ defineModuleConfig('copilot', {
|
|||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
scenarios: {
|
scenarios: {
|
||||||
desc: 'The models used in the scene for the copilot, will use this config if enabled.',
|
desc: 'Use custom models in scenarios and override default settings.',
|
||||||
default: {
|
default: {
|
||||||
enabled: false,
|
override_enabled: false,
|
||||||
scenarios: {
|
scenarios: {
|
||||||
audio: 'gemini-2.5-flash',
|
audio_transcribing: 'gemini-2.5-flash',
|
||||||
chat: 'claude-sonnet-4@20250514',
|
chat: 'claude-sonnet-4@20250514',
|
||||||
embedding: 'gemini-embedding-001',
|
embedding: 'gemini-embedding-001',
|
||||||
image: 'gpt-image-1',
|
image: 'gpt-image-1',
|
||||||
rerank: 'gpt-4.1',
|
rerank: 'gpt-4.1',
|
||||||
brainstorm: 'gpt-4o-2024-08-06',
|
|
||||||
coding: 'claude-sonnet-4@20250514',
|
coding: 'claude-sonnet-4@20250514',
|
||||||
quick_decision: 'gpt-4.1-mini',
|
complex_text_generation: 'gpt-4o-2024-08-06',
|
||||||
quick_written: 'gemini-2.5-flash',
|
quick_decision_making: 'gpt-4.1-mini',
|
||||||
summary_inspection: 'gemini-2.5-flash',
|
quick_text_generation: 'gemini-2.5-flash',
|
||||||
|
polish_and_summarize: 'gemini-2.5-flash',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class ProductionEmbeddingClient extends EmbeddingClient {
|
|||||||
|
|
||||||
override async configured(): Promise<boolean> {
|
override async configured(): Promise<boolean> {
|
||||||
const embedding = await this.providerFactory.getProvider({
|
const embedding = await this.providerFactory.getProvider({
|
||||||
modelId: this.config.copilot?.scenarios?.enabled
|
modelId: this.config.copilot?.scenarios?.override_enabled
|
||||||
? this.config.copilot.scenarios.scenarios?.embedding || EMBEDDING_MODEL
|
? this.config.copilot.scenarios.scenarios?.embedding || EMBEDDING_MODEL
|
||||||
: EMBEDDING_MODEL,
|
: EMBEDDING_MODEL,
|
||||||
outputType: ModelOutputType.Embedding,
|
outputType: ModelOutputType.Embedding,
|
||||||
|
|||||||
@@ -19,24 +19,9 @@ type Prompt = Omit<
|
|||||||
config?: PromptConfig;
|
config?: PromptConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Scenario: Record<string, string[]> = {
|
export const Scenario = {
|
||||||
audio: ['Transcript audio'],
|
audio_transcribing: ['Transcript audio'],
|
||||||
brainstorm: [
|
|
||||||
'Brainstorm mindmap',
|
|
||||||
'Create a presentation',
|
|
||||||
'Expand mind map',
|
|
||||||
'workflow:brainstorm:step2',
|
|
||||||
'workflow:presentation:step2',
|
|
||||||
'workflow:presentation:step4',
|
|
||||||
],
|
|
||||||
chat: ['Chat With AFFiNE AI'],
|
chat: ['Chat With AFFiNE AI'],
|
||||||
coding: [
|
|
||||||
'Apply Updates',
|
|
||||||
'Code Artifact',
|
|
||||||
'Make it real',
|
|
||||||
'Make it real with text',
|
|
||||||
'Section Edit',
|
|
||||||
],
|
|
||||||
// no prompt needed, just a placeholder
|
// no prompt needed, just a placeholder
|
||||||
embedding: [],
|
embedding: [],
|
||||||
image: [
|
image: [
|
||||||
@@ -49,7 +34,23 @@ export const Scenario: Record<string, string[]> = {
|
|||||||
'Remove background',
|
'Remove background',
|
||||||
'Upscale image',
|
'Upscale image',
|
||||||
],
|
],
|
||||||
quick_decision: [
|
rerank: ['Rerank results'],
|
||||||
|
coding: [
|
||||||
|
'Apply Updates',
|
||||||
|
'Code Artifact',
|
||||||
|
'Make it real',
|
||||||
|
'Make it real with text',
|
||||||
|
'Section Edit',
|
||||||
|
],
|
||||||
|
complex_text_generation: [
|
||||||
|
'Brainstorm mindmap',
|
||||||
|
'Create a presentation',
|
||||||
|
'Expand mind map',
|
||||||
|
'workflow:brainstorm:step2',
|
||||||
|
'workflow:presentation:step2',
|
||||||
|
'workflow:presentation:step4',
|
||||||
|
],
|
||||||
|
quick_decision_making: [
|
||||||
'Create headings',
|
'Create headings',
|
||||||
'Generate a caption',
|
'Generate a caption',
|
||||||
'Translate to',
|
'Translate to',
|
||||||
@@ -60,7 +61,7 @@ export const Scenario: Record<string, string[]> = {
|
|||||||
'workflow:image-pixel:step2',
|
'workflow:image-pixel:step2',
|
||||||
'workflow:image-sketch:step2',
|
'workflow:image-sketch:step2',
|
||||||
],
|
],
|
||||||
quick_written: [
|
quick_text_generation: [
|
||||||
'Brainstorm ideas about this',
|
'Brainstorm ideas about this',
|
||||||
'Continue writing',
|
'Continue writing',
|
||||||
'Explain this code',
|
'Explain this code',
|
||||||
@@ -73,8 +74,7 @@ export const Scenario: Record<string, string[]> = {
|
|||||||
'Write an article about this',
|
'Write an article about this',
|
||||||
'Write outline',
|
'Write outline',
|
||||||
],
|
],
|
||||||
rerank: ['Rerank results'],
|
polish_and_summarize: [
|
||||||
summary_inspection: [
|
|
||||||
'Change tone to',
|
'Change tone to',
|
||||||
'Check code error',
|
'Check code error',
|
||||||
'Conversation Summary',
|
'Conversation Summary',
|
||||||
@@ -92,7 +92,7 @@ export const Scenario: Record<string, string[]> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type CopilotPromptScenario = {
|
export type CopilotPromptScenario = {
|
||||||
enabled?: boolean;
|
override_enabled?: boolean;
|
||||||
scenarios?: Partial<Record<keyof typeof Scenario, string>>;
|
scenarios?: Partial<Record<keyof typeof Scenario, string>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -45,10 +45,11 @@ export class PromptService implements OnApplicationBootstrap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async setup(scenarios?: CopilotPromptScenario) {
|
protected async setup(scenarios?: CopilotPromptScenario) {
|
||||||
if (!!scenarios && scenarios.enabled && scenarios.scenarios) {
|
if (!!scenarios && scenarios.override_enabled && scenarios.scenarios) {
|
||||||
this.logger.log('Updating prompts based on scenarios...');
|
this.logger.log('Updating prompts based on scenarios...');
|
||||||
for (const [scenario, model] of Object.entries(scenarios.scenarios)) {
|
for (const [scenario, model] of Object.entries(scenarios.scenarios)) {
|
||||||
const promptNames = Scenario[scenario];
|
const promptNames = Scenario[scenario as keyof typeof Scenario] || [];
|
||||||
|
if (!promptNames.length) continue;
|
||||||
for (const name of promptNames) {
|
for (const name of promptNames) {
|
||||||
const prompt = prompts.find(p => p.name === name);
|
const prompt = prompts.find(p => p.name === name);
|
||||||
if (prompt && model) {
|
if (prompt && model) {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ export class FalProvider extends CopilotProvider<FalConfig> {
|
|||||||
|
|
||||||
override readonly models = [
|
override readonly models = [
|
||||||
{
|
{
|
||||||
id: 'lcm',
|
id: 'flux-1/schnell',
|
||||||
capabilities: [
|
capabilities: [
|
||||||
{
|
{
|
||||||
input: [ModelInputType.Text],
|
input: [ModelInputType.Text],
|
||||||
|
|||||||
@@ -258,7 +258,7 @@
|
|||||||
},
|
},
|
||||||
"scenarios": {
|
"scenarios": {
|
||||||
"type": "Object",
|
"type": "Object",
|
||||||
"desc": "The models used in the scene for the copilot, will use this config if enabled."
|
"desc": "Use custom models in scenarios and override default settings."
|
||||||
},
|
},
|
||||||
"providers.openai": {
|
"providers.openai": {
|
||||||
"type": "Object",
|
"type": "Object",
|
||||||
|
|||||||
Reference in New Issue
Block a user