Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(server): add missing env for ci (#11101)

darkskygit9c1123be8b68
diff --git a/.github/workflows/copilot-test.yml b/.github/workflows/copilot-test.yml
index d474a47fc3..305376a717 100644
--- a/.github/workflows/copilot-test.yml
+++ b/.github/workflows/copilot-test.yml
@@ -84,6 +84,7 @@ jobs:
CARGO_TARGET_DIR: '${{ github.workspace }}/target'
COPILOT_OPENAI_API_KEY: ${{ secrets.COPILOT_OPENAI_API_KEY }}
COPILOT_FAL_API_KEY: ${{ secrets.COPILOT_FAL_API_KEY }}
+ COPILOT_GOOGLE_API_KEY: ${{ secrets.COPILOT_GOOGLE_API_KEY }}
COPILOT_PERPLEXITY_API_KEY: ${{ secrets.COPILOT_PERPLEXITY_API_KEY }}
- name: Upload server test coverage results
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 0507a7e2bb..259978896b 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -98,6 +98,7 @@ jobs:
CAPTCHA_TURNSTILE_SECRET: ${{ secrets.CAPTCHA_TURNSTILE_SECRET }}
COPILOT_OPENAI_API_KEY: ${{ secrets.COPILOT_OPENAI_API_KEY }}
COPILOT_FAL_API_KEY: ${{ secrets.COPILOT_FAL_API_KEY }}
+ COPILOT_GOOGLE_API_KEY: ${{ secrets.COPILOT_GOOGLE_API_KEY }}
COPILOT_PERPLEXITY_API_KEY: ${{ secrets.COPILOT_PERPLEXITY_API_KEY }}
COPILOT_UNSPLASH_API_KEY: ${{ secrets.COPILOT_UNSPLASH_API_KEY }}
METRICS_CUSTOMER_IO_TOKEN: ${{ secrets.METRICS_CUSTOMER_IO_TOKEN }}
diff --git a/packages/backend/server/src/plugins/copilot/providers/index.ts b/packages/backend/server/src/plugins/copilot/providers/index.ts
index 1e89774d0c..d4f663ef6f 100644
--- a/packages/backend/server/src/plugins/copilot/providers/index.ts
+++ b/packages/backend/server/src/plugins/copilot/providers/index.ts
@@ -120,11 +120,16 @@ export class CopilotProviderService {
return providerFactory(this.config, this.logger);
}
- getProvider(provider: CopilotProviderType): CopilotProvider {
- if (!this.cachedProviders.has(provider)) {
- this.cachedProviders.set(provider, this.create(provider));
+ getProvider(provider: CopilotProviderType): CopilotProvider | null {
+ try {
+ if (!this.cachedProviders.has(provider)) {
+ this.cachedProviders.set(provider, this.create(provider));
+ }
+ return this.cachedProviders.get(provider) as CopilotProvider;
+ } catch {
+ // skip if the provider is not available
+ return null;
}
- return this.cachedProviders.get(provider) as CopilotProvider;
}
async getProviderByCapability<C extends CopilotCapability>(
@@ -146,7 +151,8 @@ export class CopilotProviderService {
// find first provider that supports the capability and model
if (providers.includes(selectedProvider)) {
const provider = this.getProvider(selectedProvider);
- if (provider.getCapabilities().includes(capability)) {
+
+ if (provider && provider.getCapabilities().includes(capability)) {
if (model) {
if (await provider.isModelAvailable(model)) {
return provider as CapabilityToCopilotProvider[C];
@@ -180,7 +186,7 @@ export class CopilotProviderService {
while (selectedProvider) {
const provider = this.getProvider(selectedProvider);
- if (await provider.isModelAvailable(model)) {
+ if (provider && (await provider.isModelAvailable(model))) {
return provider as CapabilityToCopilotProvider[C];
}