diff --git a/src/context/loadContexts.ts b/src/context/loadContexts.ts index 0c00c94..450352d 100644 --- a/src/context/loadContexts.ts +++ b/src/context/loadContexts.ts @@ -2,8 +2,8 @@ import { ChatContextManager } from './contextManager'; import { gitDiffCachedContext } from './contextGitDiffCached'; import { gitDiffContext } from './contextGitDiff'; import { customCommandContext } from './contextCustomCommand'; -import { refDefsContext } from './contextRefDefs'; -import { defRefsContext } from './contextDefRefs'; +// import { refDefsContext } from './contextRefDefs'; +// import { defRefsContext } from './contextDefRefs'; const chatContextManager = ChatContextManager.getInstance(); @@ -11,6 +11,6 @@ const chatContextManager = ChatContextManager.getInstance(); // 注册命令 chatContextManager.registerContext(gitDiffCachedContext); chatContextManager.registerContext(gitDiffContext); -chatContextManager.registerContext(refDefsContext); -chatContextManager.registerContext(defRefsContext); +// chatContextManager.registerContext(refDefsContext); +// chatContextManager.registerContext(defRefsContext); chatContextManager.registerContext(customCommandContext); diff --git a/src/contributes/commands.ts b/src/contributes/commands.ts index 0f978f2..ed439dd 100644 --- a/src/contributes/commands.ts +++ b/src/contributes/commands.ts @@ -164,8 +164,8 @@ function regAccessKeyCommand( await ApiKeyManager.writeApiKeySecret(passwordInput, provider); // update default model - const accessKey = await ApiKeyManager.getApiKey(); - if (!accessKey) { + const defaultModel = await ApiKeyManager.llmModel(); + if (!defaultModel) { const modelList = await ApiKeyManager.getValidModels(); if (modelList && modelList.length > 0) { // update default llm model diff --git a/src/handler/historyMessagesBase.ts b/src/handler/historyMessagesBase.ts index 4daddf3..4f71e98 100644 --- a/src/handler/historyMessagesBase.ts +++ b/src/handler/historyMessagesBase.ts @@ -4,7 +4,6 @@ import DevChat, { LogEntry, LogOptions } from '../toolwrapper/devchat'; import messageHistory from '../util/messageHistory'; import { ApiKeyManager } from '../util/apiKey'; -let isApiSet: boolean | undefined = undefined; export interface LoadHistoryMessages { command: string; @@ -68,14 +67,6 @@ export function isValidApiKey(apiKey: string, llmType: string = "None") { return true; } -export async function isWaitForApiKey() { - if (isApiSet === undefined) { - const apiKey = await ApiKeyManager.getApiKey(); - isApiSet = apiKey !== undefined; - } - return !isApiSet; -} - export async function loadTopicHistoryLogs(topicId: string | undefined): Promise | undefined> { if (!topicId) { return undefined; @@ -133,22 +124,6 @@ export function loadTopicHistoryFromCurrentMessageHistory(skip: number, count: n } as LoadHistoryMessages; } -export async function apiKeyInvalidMessage(): Promise { - const apiKey = await ApiKeyManager.getApiKey(); - isApiSet = true; - if (!apiKey) { - const startMessage = [apiKeyMissedMessage()]; - isApiSet = false; - - return { - command: 'loadHistoryMessages', - entries: startMessage, - } as LoadHistoryMessages; - } else { - return undefined; - } -} - export async function historyMessagesBase(topicId: string): Promise { const logEntriesFlat = await loadTopicHistoryLogs(topicId); if (!logEntriesFlat) { diff --git a/src/handler/historyMessagesHandler.ts b/src/handler/historyMessagesHandler.ts index 0443c3d..a12fdee 100644 --- a/src/handler/historyMessagesHandler.ts +++ b/src/handler/historyMessagesHandler.ts @@ -25,8 +25,3 @@ export async function getHistoryMessages(message: {command: string, topicId: str } } -export async function onApiKey(apiKey: string, panel: vscode.WebviewPanel|vscode.WebviewView): Promise { - const resMessage = await onApiKeyBase(apiKey); - MessageHandler.sendMessage(panel, resMessage); -} - diff --git a/src/handler/messageHandler.ts b/src/handler/messageHandler.ts index d75328d..86a44a6 100644 --- a/src/handler/messageHandler.ts +++ b/src/handler/messageHandler.ts @@ -4,9 +4,6 @@ import * as vscode from 'vscode'; import '../context/loadContexts'; import { logger } from '../util/logger'; -import { isWaitForApiKey } from './historyMessagesBase'; -import { onApiKey } from './historyMessagesHandler'; -import { ApiKeyManager } from '../util/apiKey'; export class MessageHandler { @@ -37,12 +34,6 @@ export class MessageHandler { } catch (e) { } } - if (message.command === 'sendMessage') { - if (await isWaitForApiKey() && !await ApiKeyManager.getApiKey()) { - onApiKey(message.text, panel); - return; - } - } const handler = this.handlers[message.command]; if (handler) { diff --git a/src/panel/statusBarViewBase.ts b/src/panel/statusBarViewBase.ts index 752059b..58aa495 100644 --- a/src/panel/statusBarViewBase.ts +++ b/src/panel/statusBarViewBase.ts @@ -65,19 +65,11 @@ export async function dependencyCheck(): Promise<[string, string]> { // define subfunction to check api key const getApiKeyStatus = async (): Promise => { if (apiKeyStatus === '' || apiKeyStatus === 'Click "DevChat" status icon to set key') { - const accessKey = await ApiKeyManager.getApiKey(); - if (accessKey) { + const defaultModel = await ApiKeyManager.llmModel(); + if (defaultModel) { apiKeyStatus = 'has valid access key'; return apiKeyStatus; } else { - // test whether valid model exists - const modelList = await ApiKeyManager.getValidModels(); - if (modelList && modelList.length > 0) { - // update default llm model - await UiUtilWrapper.updateConfiguration('devchat', 'defaultModel', modelList[0]); - apiKeyStatus = 'has valid access key'; - return apiKeyStatus; - } apiKeyStatus = 'Click "DevChat" status icon to set key'; return apiKeyStatus; }