mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 10:06:17 +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:
@@ -19,24 +19,9 @@ type Prompt = Omit<
|
||||
config?: PromptConfig;
|
||||
};
|
||||
|
||||
export const Scenario: Record<string, string[]> = {
|
||||
audio: ['Transcript audio'],
|
||||
brainstorm: [
|
||||
'Brainstorm mindmap',
|
||||
'Create a presentation',
|
||||
'Expand mind map',
|
||||
'workflow:brainstorm:step2',
|
||||
'workflow:presentation:step2',
|
||||
'workflow:presentation:step4',
|
||||
],
|
||||
export const Scenario = {
|
||||
audio_transcribing: ['Transcript audio'],
|
||||
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
|
||||
embedding: [],
|
||||
image: [
|
||||
@@ -49,7 +34,23 @@ export const Scenario: Record<string, string[]> = {
|
||||
'Remove background',
|
||||
'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',
|
||||
'Generate a caption',
|
||||
'Translate to',
|
||||
@@ -60,7 +61,7 @@ export const Scenario: Record<string, string[]> = {
|
||||
'workflow:image-pixel:step2',
|
||||
'workflow:image-sketch:step2',
|
||||
],
|
||||
quick_written: [
|
||||
quick_text_generation: [
|
||||
'Brainstorm ideas about this',
|
||||
'Continue writing',
|
||||
'Explain this code',
|
||||
@@ -73,8 +74,7 @@ export const Scenario: Record<string, string[]> = {
|
||||
'Write an article about this',
|
||||
'Write outline',
|
||||
],
|
||||
rerank: ['Rerank results'],
|
||||
summary_inspection: [
|
||||
polish_and_summarize: [
|
||||
'Change tone to',
|
||||
'Check code error',
|
||||
'Conversation Summary',
|
||||
@@ -92,7 +92,7 @@ export const Scenario: Record<string, string[]> = {
|
||||
};
|
||||
|
||||
export type CopilotPromptScenario = {
|
||||
enabled?: boolean;
|
||||
override_enabled?: boolean;
|
||||
scenarios?: Partial<Record<keyof typeof Scenario, string>>;
|
||||
};
|
||||
|
||||
|
||||
@@ -45,10 +45,11 @@ export class PromptService implements OnApplicationBootstrap {
|
||||
}
|
||||
|
||||
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...');
|
||||
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) {
|
||||
const prompt = prompts.find(p => p.name === name);
|
||||
if (prompt && model) {
|
||||
|
||||
Reference in New Issue
Block a user