This commit is contained in:
Philipinho
2025-10-13 23:28:08 +01:00
parent 68177d6f34
commit 807603f3a2
7 changed files with 323 additions and 35 deletions

View File

@ -20,7 +20,7 @@ import {
WorkspaceInvitations,
Workspaces,
} from '@docmost/db/types/db';
import { Embeddings } from '@docmost/db/types/embeddings.types';
import { PageEmbeddings } from '@docmost/db/types/embeddings.types';
export interface DbInterface {
attachments: Attachments;
@ -32,7 +32,7 @@ export interface DbInterface {
fileTasks: FileTasks;
groups: Groups;
groupUsers: GroupUsers;
embeddings: Embeddings;
pageEmbeddings: PageEmbeddings;
pageHistory: PageHistory;
pages: Pages;
shares: Shares;

View File

@ -1,13 +1,15 @@
import { Json, Timestamp, Generated } from '@docmost/db/types/db';
// embeddings type
export interface Embeddings {
export interface PageEmbeddings {
id: Generated<string>;
pageId: string;
spaceId: string;
modelName: string;
modelDimensions: number;
workspaceId: string;
attachmentId: string;
embedding: number[] | Buffer | string;
embedding: number[];
chunkIndex: Generated<number>;
chunkStart: Generated<number>;
chunkLength: Generated<number>;

View File

@ -21,7 +21,7 @@ import {
UserMfa as _UserMFA,
ApiKeys,
} from './db';
import { Embeddings } from '@docmost/db/types/embeddings.types';
import { PageEmbeddings } from '@docmost/db/types/embeddings.types';
// Workspace
export type Workspace = Selectable<Workspaces>;
@ -128,6 +128,6 @@ export type InsertableApiKey = Insertable<ApiKeys>;
export type UpdatableApiKey = Updateable<Omit<ApiKeys, 'id'>>;
// Page Embedding
export type Embedding = Selectable<Embeddings>;
export type InsertableEmbedding = Insertable<Embeddings>;
export type UpdatableEmbedding = Updateable<Omit<Embeddings, 'id'>>;
export type PageEmbedding = Selectable<PageEmbeddings>;
export type InsertablePageEmbedding = Insertable<PageEmbeddings>;
export type UpdatablePageEmbedding = Updateable<Omit<PageEmbeddings, 'id'>>;

View File

@ -231,7 +231,31 @@ export class EnvironmentService {
}
getTypesenseLocale(): string {
return this.configService.get<string>('TYPESENSE_LOCALE', 'en').toLowerCase();
return this.configService
.get<string>('TYPESENSE_LOCALE', 'en')
.toLowerCase();
}
getAiDriver(): string {
return this.configService.get<string>('AI_DRIVER', 'openai');
}
getAiEmbeddingModel(): string {
return this.configService.get<string>(
'AI_EMBEDDING_MODEL',
'text-embedding-3-small',
);
}
getAiCompletionModel(): string {
return this.configService.get<string>('AI_COMPLETION_MODEL', 'gpt-4o-mini');
}
getAiEmbeddingDimension(): number {
return parseInt(
this.configService.get<string>('AI_EMBEDDING_DIMENSION', '1536'),
10,
);
}
getOpenAiApiKey(): string {
@ -242,18 +266,27 @@ export class EnvironmentService {
return this.configService.get<string>('OPENAI_API_URL');
}
getOpenAiEmbeddingModel(): string {
getGoogleAiApiKey(): string {
return this.configService.get<string>('GOOGLE_AI_API_KEY');
}
getOllamaApiUrl(): string {
return this.configService.get<string>(
'OPENAI_EMBEDDING_MODEL',
'text-embedding-3-small',
'OLLAMA_API_URL',
'http://localhost:11434',
);
}
getOpenAiCompletionModel(): string {
return this.configService.get<string>(
'OPENAI_COMPLETION_MODEL',
'gpt-4o-mini',
);
getAwsAccessKeyId(): string {
return this.configService.get<string>('AWS_ACCESS_KEY_ID');
}
getAwsSecretAccessKey(): string {
return this.configService.get<string>('AWS_SECRET_ACCESS_KEY');
}
getAwsBedrockRegion(): string {
return this.configService.get<string>('AWS_BEDROCK_REGION');
}
isAIEnabled(): string {