feat(core): use the same prompt for Search With AFFiNE AI (#12496)

Support [AI-59](https://linear.app/affine-design/issue/AI-59)

Deprecated use of the perplexity model. Makes chat and search use the same prompt content.

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

- **New Features**
  - Added support for two new AI models: Claude Opus 4 and Claude Sonnet 4, enabling enhanced text and image input capabilities.
  - Introduced a new chat prompt with detailed instructions for specialized AI interactions within AFFiNE.

- **Refactor**
  - Improved prompt management for AI chat and search features by centralizing shared settings for better consistency.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
akumatus
2025-05-26 10:20:19 +00:00
committed by Yue Wu
parent 5fcdad46eb
commit 8b76644fc1
3 changed files with 56 additions and 33 deletions

View File

@@ -1086,14 +1086,14 @@ Finally, please only send us the content of your continuation in Markdown Format
}, },
]; ];
const chat: Prompt[] = [ const CHAT_PROMPT: Omit<Prompt, 'name'> = {
{
name: 'Chat With AFFiNE AI',
model: 'gpt-4.1', model: 'gpt-4.1',
optionalModels: [ optionalModels: [
'gpt-4.1', 'gpt-4.1',
'o3', 'o3',
'o4-mini', 'o4-mini',
'claude-opus-4-20250514',
'claude-sonnet-4-20250514',
'claude-3-7-sonnet-20250219', 'claude-3-7-sonnet-20250219',
'claude-3-5-sonnet-20241022', 'claude-3-5-sonnet-20241022',
'gemini-2.5-flash-preview-05-20', 'gemini-2.5-flash-preview-05-20',
@@ -1101,7 +1101,7 @@ const chat: Prompt[] = [
'claude-opus-4@20250514', 'claude-opus-4@20250514',
'claude-sonnet-4@20250514', 'claude-sonnet-4@20250514',
'claude-3-7-sonnet@20250219', 'claude-3-7-sonnet@20250219',
'claude-3-5-sonnet@20240620', 'claude-3-5-sonnet-v2@20241022',
], ],
messages: [ messages: [
{ {
@@ -1234,11 +1234,16 @@ Below is the user's query. Please respond in the user's preferred language witho
config: { config: {
tools: ['webSearch'], tools: ['webSearch'],
}, },
};
const chat: Prompt[] = [
{
name: 'Chat With AFFiNE AI',
...CHAT_PROMPT,
}, },
{ {
name: 'Search With AFFiNE AI', name: 'Search With AFFiNE AI',
model: 'sonar-reasoning-pro', ...CHAT_PROMPT,
messages: [],
}, },
// use for believer plan // use for believer plan
{ {

View File

@@ -15,13 +15,30 @@ export class AnthropicOfficialProvider extends AnthropicProvider<AnthropicOffici
override readonly type = CopilotProviderType.Anthropic; override readonly type = CopilotProviderType.Anthropic;
override readonly models = [ override readonly models = [
{
id: 'claude-opus-4-20250514',
capabilities: [
{
input: [ModelInputType.Text, ModelInputType.Image],
output: [ModelOutputType.Text],
},
],
},
{
id: 'claude-sonnet-4-20250514',
capabilities: [
{
input: [ModelInputType.Text, ModelInputType.Image],
output: [ModelOutputType.Text],
},
],
},
{ {
id: 'claude-3-7-sonnet-20250219', id: 'claude-3-7-sonnet-20250219',
capabilities: [ capabilities: [
{ {
input: [ModelInputType.Text, ModelInputType.Image], input: [ModelInputType.Text, ModelInputType.Image],
output: [ModelOutputType.Text], output: [ModelOutputType.Text],
defaultForOutputType: true,
}, },
], ],
}, },
@@ -31,6 +48,7 @@ export class AnthropicOfficialProvider extends AnthropicProvider<AnthropicOffici
{ {
input: [ModelInputType.Text, ModelInputType.Image], input: [ModelInputType.Text, ModelInputType.Image],
output: [ModelOutputType.Text], output: [ModelOutputType.Text],
defaultForOutputType: true,
}, },
], ],
}, },

View File

@@ -41,7 +41,7 @@ export class AnthropicVertexProvider extends AnthropicProvider<AnthropicVertexCo
], ],
}, },
{ {
id: 'claude-3-5-sonnet@20240620', id: 'claude-3-5-sonnet-v2@20241022',
capabilities: [ capabilities: [
{ {
input: [ModelInputType.Text, ModelInputType.Image], input: [ModelInputType.Text, ModelInputType.Image],