From 50b8ae818584af1deaee4833eb0d392d146709e9 Mon Sep 17 00:00:00 2001 From: Jinglei Ren Date: Sun, 28 May 2023 08:32:12 +0800 Subject: [PATCH] Unify naming convension ('openai'/'Openai', no 'openAi'/'openAI') --- src/contributes/commands.ts | 8 ++++---- src/extension.ts | 4 ++-- src/handler/historyMessages.ts | 6 +++--- src/toolwrapper/devchat.ts | 12 ++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/contributes/commands.ts b/src/contributes/commands.ts index 9357d48..7380d86 100644 --- a/src/contributes/commands.ts +++ b/src/contributes/commands.ts @@ -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; } } diff --git a/src/extension.ts b/src/extension.ts index 9ffdc47..a711d12 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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 { diff --git a/src/handler/historyMessages.ts b/src/handler/historyMessages.ts index 39cea21..d53bdd2 100644 --- a/src/handler/historyMessages.ts +++ b/src/handler/historyMessages.ts @@ -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; } diff --git a/src/toolwrapper/devchat.ts b/src/toolwrapper/devchat.ts index 67980f6..26b2503 100644 --- a/src/toolwrapper/devchat.ts +++ b/src/toolwrapper/devchat.ts @@ -84,7 +84,7 @@ class DevChat { return args; } - async getOpenAiApiKey(): Promise { + async getOpenaiApiKey(): Promise { 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);