mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-24 04:27:27 +08:00
@@ -5,6 +5,7 @@ import { DeploymentType } from '../../env';
|
|||||||
export enum ServerFeature {
|
export enum ServerFeature {
|
||||||
Captcha = 'captcha',
|
Captcha = 'captcha',
|
||||||
Copilot = 'copilot',
|
Copilot = 'copilot',
|
||||||
|
CopilotEmbedding = 'copilot_embedding',
|
||||||
Payment = 'payment',
|
Payment = 'payment',
|
||||||
OAuth = 'oauth',
|
OAuth = 'oauth',
|
||||||
Indexer = 'indexer',
|
Indexer = 'indexer',
|
||||||
|
|||||||
@@ -232,8 +232,8 @@ export class CopilotWorkspaceConfigModel extends BaseModel {
|
|||||||
async checkEmbeddingAvailable(): Promise<boolean> {
|
async checkEmbeddingAvailable(): Promise<boolean> {
|
||||||
const [{ count }] = await this.db.$queryRaw<
|
const [{ count }] = await this.db.$queryRaw<
|
||||||
{ count: number }[]
|
{ count: number }[]
|
||||||
>`SELECT count(1) FROM pg_tables WHERE tablename in ('ai_workspace_file_embeddings')`;
|
>`SELECT count(1) FROM pg_tables WHERE tablename in ('ai_workspace_embeddings', 'ai_workspace_file_embeddings')`;
|
||||||
return Number(count) === 1;
|
return Number(count) === 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
private processEmbeddings(
|
private processEmbeddings(
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { createHash } from 'node:crypto';
|
|||||||
import { Injectable, OnApplicationBootstrap } from '@nestjs/common';
|
import { Injectable, OnApplicationBootstrap } from '@nestjs/common';
|
||||||
|
|
||||||
import { FileUpload, JobQueue, PaginationInput } from '../../../base';
|
import { FileUpload, JobQueue, PaginationInput } from '../../../base';
|
||||||
|
import { ServerFeature, ServerService } from '../../../core';
|
||||||
import { Models } from '../../../models';
|
import { Models } from '../../../models';
|
||||||
import { CopilotStorage } from '../storage';
|
import { CopilotStorage } from '../storage';
|
||||||
import { readStream } from '../utils';
|
import { readStream } from '../utils';
|
||||||
@@ -12,6 +13,7 @@ export class CopilotWorkspaceService implements OnApplicationBootstrap {
|
|||||||
private supportEmbedding = false;
|
private supportEmbedding = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private readonly server: ServerService,
|
||||||
private readonly models: Models,
|
private readonly models: Models,
|
||||||
private readonly queue: JobQueue,
|
private readonly queue: JobQueue,
|
||||||
private readonly storage: CopilotStorage
|
private readonly storage: CopilotStorage
|
||||||
@@ -19,8 +21,9 @@ export class CopilotWorkspaceService implements OnApplicationBootstrap {
|
|||||||
|
|
||||||
async onApplicationBootstrap() {
|
async onApplicationBootstrap() {
|
||||||
const supportEmbedding =
|
const supportEmbedding =
|
||||||
await this.models.copilotContext.checkEmbeddingAvailable();
|
await this.models.copilotWorkspace.checkEmbeddingAvailable();
|
||||||
if (supportEmbedding) {
|
if (supportEmbedding) {
|
||||||
|
this.server.enableFeature(ServerFeature.CopilotEmbedding);
|
||||||
this.supportEmbedding = true;
|
this.supportEmbedding = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1606,6 +1606,7 @@ enum ServerDeploymentType {
|
|||||||
enum ServerFeature {
|
enum ServerFeature {
|
||||||
Captcha
|
Captcha
|
||||||
Copilot
|
Copilot
|
||||||
|
CopilotEmbedding
|
||||||
Indexer
|
Indexer
|
||||||
OAuth
|
OAuth
|
||||||
Payment
|
Payment
|
||||||
|
|||||||
@@ -2169,6 +2169,7 @@ export enum ServerDeploymentType {
|
|||||||
export enum ServerFeature {
|
export enum ServerFeature {
|
||||||
Captcha = 'Captcha',
|
Captcha = 'Captcha',
|
||||||
Copilot = 'Copilot',
|
Copilot = 'Copilot',
|
||||||
|
CopilotEmbedding = 'CopilotEmbedding',
|
||||||
Indexer = 'Indexer',
|
Indexer = 'Indexer',
|
||||||
OAuth = 'OAuth',
|
OAuth = 'OAuth',
|
||||||
Payment = 'Payment',
|
Payment = 'Payment',
|
||||||
|
|||||||
Reference in New Issue
Block a user