Add OpenAI endpoint config

This commit is contained in:
bobo.yang 2023-05-10 21:28:41 +08:00
parent 19ce45fdaf
commit a0efb9a200
2 changed files with 16 additions and 6 deletions

View File

@ -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"
}
]
}

View File

@ -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);