Unify naming convension ('openai'/'Openai', no 'openAi'/'openAI')
This commit is contained in:
parent
fdc65c998c
commit
50b8ae8185
@ -34,7 +34,7 @@ export function checkDevChatDependency(): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
export async function checkOpenAiAPIKey() {
|
||||
export async function checkOpenaiApiKey() {
|
||||
const secretStorage: vscode.SecretStorage = ExtensionContextHolder.context!.secrets;
|
||||
let openaiApiKey = await secretStorage.get("devchat_OPENAI_API_KEY");
|
||||
if (!openaiApiKey) {
|
||||
@ -49,7 +49,7 @@ export async function checkOpenAiAPIKey() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkOpenAIKey() {
|
||||
function checkOpenaiKey() {
|
||||
let openaiApiKey = vscode.workspace.getConfiguration('DevChat').get('OpenAI.apiKey');
|
||||
if (!openaiApiKey) {
|
||||
openaiApiKey = process.env.OPENAI_API_KEY;
|
||||
@ -57,7 +57,7 @@ function checkOpenAIKey() {
|
||||
if (!openaiApiKey) {
|
||||
// OpenAI key not set
|
||||
vscode.window.showInputBox({
|
||||
placeHolder: 'Please input your openAI API Key'
|
||||
placeHolder: 'Please input your OpenAI API key (or DevChat access key)'
|
||||
}).then((value) => {
|
||||
if (value) {
|
||||
// Set API Key
|
||||
@ -86,7 +86,7 @@ function checkDependencyPackage() {
|
||||
});
|
||||
}
|
||||
|
||||
if (!checkOpenAIKey()) {
|
||||
if (!checkOpenaiKey()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import * as vscode from 'vscode';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import {
|
||||
checkOpenAiAPIKey,
|
||||
checkOpenaiApiKey,
|
||||
checkDevChatDependency,
|
||||
checkDependencyPackage,
|
||||
registerOpenChatPanelCommand,
|
||||
@ -224,7 +224,7 @@ function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
// check api key
|
||||
if (apiKeyStatus === '' || apiKeyStatus === 'please set api key') {
|
||||
const bOk = await checkOpenAiAPIKey();
|
||||
const bOk = await checkOpenaiApiKey();
|
||||
if (bOk) {
|
||||
apiKeyStatus = 'ready';
|
||||
} else {
|
||||
|
@ -3,7 +3,7 @@ import DevChat, { LogOptions, LogEntry } from '../toolwrapper/devchat';
|
||||
import { MessageHandler } from './messageHandler';
|
||||
import messageHistory from '../util/messageHistory';
|
||||
import { regInMessage, regOutMessage } from '../util/reg_messages';
|
||||
import { checkOpenAiAPIKey } from '../contributes/commands';
|
||||
import { checkOpenaiApiKey } from '../contributes/commands';
|
||||
import ExtensionContextHolder from '../util/extensionContext';
|
||||
import { TopicManager } from '../topic/topicManager';
|
||||
|
||||
@ -86,7 +86,7 @@ export async function historyMessages(message: any, panel: vscode.WebviewPanel|v
|
||||
messageHistory.add(entryNew);
|
||||
}
|
||||
|
||||
const isApiKeyReady = await checkOpenAiAPIKey();
|
||||
const isApiKeyReady = await checkOpenaiApiKey();
|
||||
isApiSet = true;
|
||||
if (!isApiKeyReady) {
|
||||
const startMessage = [ apiKeyMissedMessage() ];
|
||||
@ -119,7 +119,7 @@ export function isValidApiKey(apiKey: string) {
|
||||
|
||||
export async function isWaitForApiKey() {
|
||||
if (isApiSet === undefined) {
|
||||
isApiSet = await checkOpenAiAPIKey();
|
||||
isApiSet = await checkOpenaiApiKey();
|
||||
}
|
||||
return !isApiSet;
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class DevChat {
|
||||
return args;
|
||||
}
|
||||
|
||||
async getOpenAiApiKey(): Promise<string | undefined> {
|
||||
async getOpenaiApiKey(): Promise<string | undefined> {
|
||||
const secretStorage: vscode.SecretStorage = ExtensionContextHolder.context!.secrets;
|
||||
let openaiApiKey = await secretStorage.get("devchat_OPENAI_API_KEY");
|
||||
if (!openaiApiKey) {
|
||||
@ -151,15 +151,15 @@ class DevChat {
|
||||
args.push(content);
|
||||
|
||||
const workspaceDir = vscode.workspace.workspaceFolders?.[0].uri.fsPath;
|
||||
let openaiApiKey = await this.getOpenAiApiKey();
|
||||
let openaiApiKey = await this.getOpenaiApiKey();
|
||||
if (!openaiApiKey) {
|
||||
logger.channel()?.error('openAI key is invalid!');
|
||||
logger.channel()?.error('OpenAI key is invalid!');
|
||||
logger.channel()?.show();
|
||||
}
|
||||
|
||||
|
||||
const openAiApiBase = vscode.workspace.getConfiguration('DevChat').get('OpenAI.EndPoint');
|
||||
const openAiApiBaseObject = openAiApiBase ? { OPENAI_API_BASE: openAiApiBase } : {};
|
||||
const openaiApiBase = vscode.workspace.getConfiguration('DevChat').get('OpenAI.EndPoint');
|
||||
const openaiApiBaseObject = openaiApiBase ? { OPENAI_API_BASE: openaiApiBase } : {};
|
||||
|
||||
const openaiModel = vscode.workspace.getConfiguration('DevChat').get('OpenAI.model');
|
||||
const openaiTemperature = vscode.workspace.getConfiguration('DevChat').get('OpenAI.temperature');
|
||||
@ -203,7 +203,7 @@ class DevChat {
|
||||
env: {
|
||||
...process.env,
|
||||
OPENAI_API_KEY: openaiApiKey,
|
||||
...openAiApiBaseObject
|
||||
...openaiApiBaseObject
|
||||
},
|
||||
}, onStdoutPartial, undefined, undefined, undefined);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user