From a0efb9a200d02efa231e2cf805ad2bbc861eb78c Mon Sep 17 00:00:00 2001 From: "bobo.yang" Date: Wed, 10 May 2023 21:28:41 +0800 Subject: [PATCH] Add OpenAI endpoint config --- package.json | 18 ++++++++++++------ src/toolwrapper/devchat.ts | 4 ++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 78559a1..878c851 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,13 @@ "default": "", "description": "Open API Key", "when": "DevChat.llmModel == 'OpenAI'" - } + }, + "DevChat.OpenAI.EndPoint": { + "type": "string", + "default": "", + "description": "OpenAI api server", + "when": "DevChat.llmModel == 'OpenAI'" + } } }, "views": { @@ -94,15 +100,15 @@ }, { "command": "devchat.addConext", - "title": "add to DevChat" + "title": "Add to DevChat" }, { "command": "devchat.askForCode", - "title": "add to DevChat" + "title": "Add to DevChat" }, { "command": "devchat.askForFile", - "title": "add to DevChat" + "title": "Add to DevChat" } ], "menus": { @@ -118,13 +124,13 @@ "command": "devchat.askForCode", "when": "editorTextFocus && editorHasSelection", "group": "navigation", - "title": "add to DevChat" + "title": "Add to DevChat" }, { "command": "devchat.askForFile", "when": "editorTextFocus && !editorHasSelection", "group": "navigation", - "title": "add to DevChat" + "title": "Add to DevChat" } ] } diff --git a/src/toolwrapper/devchat.ts b/src/toolwrapper/devchat.ts index bdd68ce..5628c18 100644 --- a/src/toolwrapper/devchat.ts +++ b/src/toolwrapper/devchat.ts @@ -114,6 +114,9 @@ class DevChat { logger.channel()?.show(); } + 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'); const openaiStream = vscode.workspace.getConfiguration('DevChat').get('OpenAI.stream'); @@ -206,6 +209,7 @@ class DevChat { env: { ...process.env, OPENAI_API_KEY: openaiApiKey, + ...openAiApiBaseObject, }, }, onStdoutPartial);