chore(server): patch config system (#11260)
This commit is contained in:
@@ -104,7 +104,9 @@ export class ServerService implements OnApplicationBootstrap {
|
|||||||
private async setup() {
|
private async setup() {
|
||||||
const overrides = await this.loadDbOverrides();
|
const overrides = await this.loadDbOverrides();
|
||||||
this.configFactory.override(overrides);
|
this.configFactory.override(overrides);
|
||||||
this.event.emit('config.init', { config: this.configFactory.config });
|
await this.event.emitAsync('config.init', {
|
||||||
|
config: this.configFactory.config,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async loadDbOverrides() {
|
private async loadDbOverrides() {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import './config';
|
||||||
|
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
import { DocStorageModule } from '../doc';
|
import { DocStorageModule } from '../doc';
|
||||||
|
|||||||
@@ -24,15 +24,27 @@ const CONTEXT_SESSION_KEY = 'context-session';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class CopilotContextService implements OnApplicationBootstrap {
|
export class CopilotContextService implements OnApplicationBootstrap {
|
||||||
private supportEmbedding = false;
|
private supportEmbedding = false;
|
||||||
private readonly client: EmbeddingClient | undefined;
|
private client: EmbeddingClient | undefined;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
config: Config,
|
private readonly config: Config,
|
||||||
private readonly cache: Cache,
|
private readonly cache: Cache,
|
||||||
private readonly models: Models
|
private readonly models: Models
|
||||||
) {
|
) {}
|
||||||
const configure = config.copilot.providers.openai;
|
|
||||||
if (configure) {
|
@OnEvent('config.init')
|
||||||
|
onConfigInit() {
|
||||||
|
this.setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnEvent('config.changed')
|
||||||
|
onConfigChanged() {
|
||||||
|
this.setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
private setup() {
|
||||||
|
const configure = this.config.copilot.providers.openai;
|
||||||
|
if (configure.apiKey) {
|
||||||
this.client = new OpenAIEmbeddingClient(new OpenAI(configure));
|
this.client = new OpenAIEmbeddingClient(new OpenAI(configure));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user