mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 04:26:23 +08:00
feat: adapt cloudflare worker ai (#14732)
#### PR Dependency Tree * **PR #14732** 👈 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** * Cloudflare Workers AI added as a Copilot provider (configurable in admin settings). * Gemini 3.1 Flash Lite Preview model made available. * **Behavior Changes** * Reranking now uses a different default model identifier (affects relevancy scores). * **Tests** * Rerank tests adjusted to focus on the updated model and expected results. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
AnthropicOfficialConfig,
|
||||
AnthropicVertexConfig,
|
||||
} from './providers/anthropic';
|
||||
import { CloudflareWorkersAIConfig } from './providers/cloudflare';
|
||||
import type { FalConfig } from './providers/fal';
|
||||
import { GeminiGenerativeConfig, GeminiVertexConfig } from './providers/gemini';
|
||||
import { MorphConfig } from './providers/morph';
|
||||
@@ -23,6 +24,7 @@ import {
|
||||
|
||||
export type CopilotProviderConfigMap = {
|
||||
[CopilotProviderType.OpenAI]: OpenAIConfig;
|
||||
[CopilotProviderType.CloudflareWorkersAi]: CloudflareWorkersAIConfig;
|
||||
[CopilotProviderType.FAL]: FalConfig;
|
||||
[CopilotProviderType.Gemini]: GeminiGenerativeConfig;
|
||||
[CopilotProviderType.GeminiVertex]: GeminiVertexConfig;
|
||||
@@ -117,6 +119,12 @@ const FalConfigShape = z.object({
|
||||
apiKey: z.string(),
|
||||
});
|
||||
|
||||
const CloudflareWorkersAIConfigShape = z.object({
|
||||
apiToken: z.string(),
|
||||
accountId: z.string().optional(),
|
||||
baseURL: z.string().optional(),
|
||||
});
|
||||
|
||||
const GeminiGenerativeConfigShape = z.object({
|
||||
apiKey: z.string(),
|
||||
baseURL: z.string().optional(),
|
||||
@@ -153,6 +161,10 @@ const CopilotProviderProfileShape = z.discriminatedUnion('type', [
|
||||
type: z.literal(CopilotProviderType.FAL),
|
||||
config: FalConfigShape,
|
||||
}),
|
||||
CopilotProviderProfileBaseShape.extend({
|
||||
type: z.literal(CopilotProviderType.CloudflareWorkersAi),
|
||||
config: CloudflareWorkersAIConfigShape,
|
||||
}),
|
||||
CopilotProviderProfileBaseShape.extend({
|
||||
type: z.literal(CopilotProviderType.Gemini),
|
||||
config: GeminiGenerativeConfigShape,
|
||||
@@ -205,6 +217,7 @@ declare global {
|
||||
profiles: ConfigItem<CopilotProviderProfile[]>;
|
||||
defaults: ConfigItem<CopilotProviderDefaults>;
|
||||
openai: ConfigItem<OpenAIConfig>;
|
||||
cloudflareWorkersAi: ConfigItem<CloudflareWorkersAIConfig>;
|
||||
fal: ConfigItem<FalConfig>;
|
||||
gemini: ConfigItem<GeminiGenerativeConfig>;
|
||||
geminiVertex: ConfigItem<GeminiVertexConfig>;
|
||||
@@ -257,6 +270,13 @@ defineModuleConfig('copilot', {
|
||||
},
|
||||
link: 'https://github.com/openai/openai-node',
|
||||
},
|
||||
'providers.cloudflareWorkersAi': {
|
||||
desc: 'The config for the Cloudflare Workers AI provider.',
|
||||
default: {
|
||||
apiToken: '',
|
||||
accountId: '',
|
||||
},
|
||||
},
|
||||
'providers.fal': {
|
||||
desc: 'The config for the fal provider.',
|
||||
default: {
|
||||
|
||||
Reference in New Issue
Block a user