fix(aidocs): correct smartconfig file handling and tighten TypeScript typings
This commit is contained in:
+9
-6
@@ -3,12 +3,12 @@ import * as plugins from './plugins.js';
|
||||
import * as aiDocsClasses from './aidocs_classes/index.js';
|
||||
|
||||
export class AiDoc {
|
||||
private openaiToken: string;
|
||||
private openaiToken = '';
|
||||
|
||||
public smartconfigKV: plugins.smartconfig.KeyValueStore;
|
||||
public qenvInstance: plugins.qenv.Qenv;
|
||||
public aidocInteract: plugins.smartinteract.SmartInteract;
|
||||
public model: plugins.smartai.LanguageModelV3;
|
||||
public smartconfigKV?: plugins.smartconfig.KeyValueStore<{ OPENAI_TOKEN: string }>;
|
||||
public qenvInstance!: plugins.qenv.Qenv;
|
||||
public aidocInteract!: plugins.smartinteract.SmartInteract;
|
||||
public model!: plugins.smartai.LanguageModelV3;
|
||||
|
||||
argvArg: any;
|
||||
|
||||
@@ -35,7 +35,10 @@ export class AiDoc {
|
||||
// lets care about prerequisites
|
||||
this.aidocInteract = new plugins.smartinteract.SmartInteract();
|
||||
this.qenvInstance = new plugins.qenv.Qenv();
|
||||
if (!(await this.qenvInstance.getEnvVarOnDemand('OPENAI_TOKEN'))) {
|
||||
const openaiTokenFromEnv = await this.qenvInstance.getEnvVarOnDemand('OPENAI_TOKEN');
|
||||
if (openaiTokenFromEnv) {
|
||||
this.openaiToken = openaiTokenFromEnv;
|
||||
} else {
|
||||
// Migrate old KV store path to new path if needed
|
||||
const homeDir = plugins.smartpath.get.home();
|
||||
const oldKvPath = plugins.path.join(homeDir, '.smartconfig/kv/tsdoc.json');
|
||||
|
||||
Reference in New Issue
Block a user