Files
AFFiNE/packages/backend/server/src/plugins/copilot/config.ts
fengmk2 bc3b41378d chore(server): add ai document link on admin panel (#13428)
close AF-2766
<img width="2082" height="654" alt="image"
src="https://github.com/user-attachments/assets/efba776c-91cd-4d59-a2a6-e00f68c61be1"
/>



#### PR Dependency Tree


* **PR #13428** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Configuration descriptions for the copilot plugin now include direct
links to relevant documentation for easier access to more information.

* **Style**
* Improved display of configuration descriptions to support and render
HTML content.

* **Refactor**
* The AI navigation item in the admin panel has been disabled and is no
longer visible.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-07 03:16:29 +00:00

138 lines
3.8 KiB
TypeScript

import {
defineModuleConfig,
StorageJSONSchema,
StorageProviderConfig,
} from '../../base';
import { CopilotPromptScenario } from './prompt/prompts';
import {
AnthropicOfficialConfig,
AnthropicVertexConfig,
} from './providers/anthropic';
import type { FalConfig } from './providers/fal';
import { GeminiGenerativeConfig, GeminiVertexConfig } from './providers/gemini';
import { MorphConfig } from './providers/morph';
import { OpenAIConfig } from './providers/openai';
import { PerplexityConfig } from './providers/perplexity';
import { VertexSchema } from './providers/types';
declare global {
interface AppConfigSchema {
copilot: {
enabled: boolean;
unsplash: ConfigItem<{
key: string;
}>;
exa: ConfigItem<{
key: string;
}>;
storage: ConfigItem<StorageProviderConfig>;
scenarios: ConfigItem<CopilotPromptScenario>;
providers: {
openai: ConfigItem<OpenAIConfig>;
fal: ConfigItem<FalConfig>;
gemini: ConfigItem<GeminiGenerativeConfig>;
geminiVertex: ConfigItem<GeminiVertexConfig>;
perplexity: ConfigItem<PerplexityConfig>;
anthropic: ConfigItem<AnthropicOfficialConfig>;
anthropicVertex: ConfigItem<AnthropicVertexConfig>;
morph: ConfigItem<MorphConfig>;
};
};
}
}
defineModuleConfig('copilot', {
enabled: {
desc: 'Whether to enable the copilot plugin. <br> Document: <a href="https://docs.affine.pro/self-host-affine/administer/ai" target="_blank">https://docs.affine.pro/self-host-affine/administer/ai</a>',
default: false,
},
scenarios: {
desc: 'Use custom models in scenarios and override default settings.',
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',
},
},
},
'providers.openai': {
desc: 'The config for the openai provider.',
default: {
apiKey: '',
baseURL: 'https://api.openai.com/v1',
},
link: 'https://github.com/openai/openai-node',
},
'providers.fal': {
desc: 'The config for the fal provider.',
default: {
apiKey: '',
},
},
'providers.gemini': {
desc: 'The config for the gemini provider.',
default: {
apiKey: '',
baseURL: 'https://generativelanguage.googleapis.com/v1beta',
},
},
'providers.geminiVertex': {
desc: 'The config for the gemini provider in Google Vertex AI.',
default: {},
schema: VertexSchema,
},
'providers.perplexity': {
desc: 'The config for the perplexity provider.',
default: {
apiKey: '',
},
},
'providers.anthropic': {
desc: 'The config for the anthropic provider.',
default: {
apiKey: '',
baseURL: 'https://api.anthropic.com/v1',
},
},
'providers.anthropicVertex': {
desc: 'The config for the anthropic provider in Google Vertex AI.',
default: {},
schema: VertexSchema,
},
'providers.morph': {
desc: 'The config for the morph provider.',
default: {},
},
unsplash: {
desc: 'The config for the unsplash key.',
default: {
key: '',
},
},
exa: {
desc: 'The config for the exa web search key.',
default: {
key: '',
},
},
storage: {
desc: 'The config for the storage provider.',
default: {
provider: 'fs',
bucket: 'copilot',
config: {
path: '~/.affine/storage',
},
},
schema: StorageJSONSchema,
},
});