Skip to content

Commit 01c08a5

Browse files
committed
upgrade to v0.1.11
1 parent 8998fe1 commit 01c08a5

File tree

4 files changed

+52
-19
lines changed

4 files changed

+52
-19
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.1.11] - 2024-01-30
9+
10+
- Add setting to allow self-signed certificate which could be useful in dev / test stages
11+
812
## [0.1.10] - 2024-01-25
913

1014
- Fix error: request to \<AOAI URL\> failed, reason: read ECONNRESET

package.json

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "GAI Choy",
44
"description": "G̲enerative A̲I̲ empowered, C̲ode H̲elper O̲n Y̲our side. Yet another Copilot for coding, with built-in integration capability with Azure OpenAI models or, local LLM such as CodeShell.",
55
"publisher": "carusyte",
6-
"version": "0.1.10",
6+
"version": "0.1.11",
77
"icon": "assets/logo.png",
88
"pricing": "Free",
99
"keywords": [
@@ -37,6 +37,12 @@
3737
"type": "string",
3838
"order": 1
3939
},
40+
"GAIChoy.AllowSelfSignedCert": {
41+
"description": "Whether to allow self-signed certificate presented from the remote server",
42+
"default": false,
43+
"type": "boolean",
44+
"order": 2
45+
},
4046
"GAIChoy.RunEnvForLLMs": {
4147
"description": "The environment that should be used for running LLMs.",
4248
"default": "Azure OpenAI",
@@ -46,7 +52,7 @@
4652
"Azure OpenAI"
4753
],
4854
"type": "string",
49-
"order": 2
55+
"order": 3
5056
},
5157
"GAIChoy.ChatModel": {
5258
"description": "The deployed model in Azure OpenAI which will be used for technical conversations.",
@@ -58,7 +64,7 @@
5864
"gpt-4-32k"
5965
],
6066
"type": "string",
61-
"order": 3
67+
"order": 4
6268
},
6369
"GAIChoy.CodeCompletionModel": {
6470
"description": "The deployed model in Azure OpenAI which will be used for code completions.",
@@ -70,14 +76,14 @@
7076
"gpt-4-32k"
7177
],
7278
"type": "string",
73-
"order": 4
79+
"order": 5
7480
},
7581
"GAIChoy.ApiKey": {
7682
"description": "Set the API key for Azure OpenAI service",
7783
"type": "null",
7884
"scope": "application",
7985
"markdownDescription": "[Set API Key](command:gaichoy.set_api_key)",
80-
"order": 5
86+
"order": 6
8187
},
8288
"GAIChoy.ApiVersion": {
8389
"description": "The API version for Azure OpenAI.",
@@ -90,13 +96,13 @@
9096
"2023-09-01-preview"
9197
],
9298
"type": "string",
93-
"order": 6
99+
"order": 7
94100
},
95101
"GAIChoy.AutoTriggerCompletion": {
96102
"description": "Whether or not to automatically trigger completion when typing.",
97103
"default": false,
98104
"type": "boolean",
99-
"order": 7
105+
"order": 8
100106
},
101107
"GAIChoy.AutoCompletionDelay": {
102108
"description": "The delay in seconds before automatic code completion triggers.",
@@ -107,7 +113,7 @@
107113
3
108114
],
109115
"default": 2,
110-
"order": 8
116+
"order": 9
111117
},
112118
"GAIChoy.CompletionMaxTokens": {
113119
"description": "Maximum number of tokens for which suggestions will be displayed",
@@ -122,7 +128,7 @@
122128
4096
123129
],
124130
"default": 64,
125-
"order": 9
131+
"order": 10
126132
},
127133
"GAIChoy.ChatMaxTokens": {
128134
"description": "Maximum number of tokens for which chat messages will be displayed",
@@ -136,20 +142,20 @@
136142
32768
137143
],
138144
"default": 2048,
139-
"order": 10
145+
"order": 11
140146
},
141147
"GAIChoy.EnableDebugMessage": {
142148
"description": "Prints debug message to extension output.",
143149
"type": "boolean",
144150
"default": false,
145-
"order": 11
151+
"order": 12
146152
},
147153
"GAIChoy.ClearChatHistory": {
148154
"description": "Clear the chat history",
149155
"type": "null",
150156
"scope": "application",
151157
"markdownDescription": "[Clear chat history](command:gaichoy.clear_chat_history)",
152-
"order": 12
158+
"order": 13
153159
}
154160
}
155161
},

src/RequestCompletion.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable */
22
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";
3+
import {Agent} from "https"
34
import { workspace } from "vscode";
45
import { translate } from "./LanguageHelper";
56
import ExtensionResource from "./ExtensionResource";
@@ -13,6 +14,11 @@ export async function postCompletion(fileName: string, fimPrefixCode: string, fi
1314
const serverAddress = workspace.getConfiguration("GAIChoy").get("ServerAddress") as string;
1415
let maxtokens = workspace.getConfiguration("GAIChoy").get("CompletionMaxTokens") as number;
1516
const modelEnv = workspace.getConfiguration("GAIChoy").get("RunEnvForLLMs") as string;
17+
const allowSelfSignedCert = workspace.getConfiguration("GAIChoy").get("AllowSelfSignedCert") as boolean
18+
19+
if (allowSelfSignedCert) {
20+
axios.defaults.httpsAgent = new Agent({ rejectUnauthorized: false });
21+
}
1622

1723
if ("Azure OpenAI" == modelEnv) {
1824
return AzureOAI.completeCode(fileName, fimPrefixCode, fimSuffixCode, axiosInstance);

src/RequestEventStream.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable */
2+
import { Agent } from "https";
23
import { workspace } from "vscode";
34
import { FetchStream } from "./FetchStream";
45
import { ChatItem } from "./ChatMemory";
@@ -17,6 +18,7 @@ export async function postEventStream(prompt: string, chatList: Array<ChatItem>,
1718
const api_version = workspace.getConfiguration("GAIChoy").get("ApiVersion") as string;
1819
const maxtokens = workspace.getConfiguration("GAIChoy").get("ChatMaxTokens") as number;
1920
const modelEnv = workspace.getConfiguration("GAIChoy").get("RunEnvForLLMs") as string;
21+
const allowSelfSignedCert = workspace.getConfiguration("GAIChoy").get("AllowSelfSignedCert") as boolean
2022

2123
// get API key from secret storage
2224
let api_key = await ExtensionResource.instance.getApiKey();
@@ -34,8 +36,8 @@ export async function postEventStream(prompt: string, chatList: Array<ChatItem>,
3436
"Content-Type": "application/json",
3537
};
3638
body = {
37-
"prompt": "|<end>|" + prompt, "n_predict": maxtokens,
38-
"temperature": 0.8, "repetition_penalty": 1.2, "top_k":40, "top_p":0.95, "stream": true,
39+
"prompt": "|<end>|" + prompt, "n_predict": maxtokens,
40+
"temperature": 0.8, "repetition_penalty": 1.2, "top_k": 40, "top_p": 0.95, "stream": true,
3941
"stop": ["|<end>|", "|end|", "<|endoftext|>", "## human"]
4042
};
4143
}
@@ -49,7 +51,7 @@ export async function postEventStream(prompt: string, chatList: Array<ChatItem>,
4951
"inputs": prompt,
5052
"parameters": {
5153
"max_new_tokens": maxtokens,
52-
"temperature": 0.6, "repetition_penalty": 1.2, "top_p": 0.95, "do_sample": true,
54+
"temperature": 0.6, "repetition_penalty": 1.2, "top_p": 0.95, "do_sample": true,
5355
"stop": ["|<end>|", "|end|", "<|endoftext|>", "## human"]
5456
}
5557
};
@@ -108,14 +110,29 @@ export async function postEventStream(prompt: string, chatList: Array<ChatItem>,
108110
}
109111
}
110112
abortController = new AbortController();
111-
new FetchStream({
112-
url: serverAddress + uri,
113-
requestInit: {
113+
var requestInit = {}
114+
// Enable option to trust self-signed certificate
115+
if (allowSelfSignedCert) {
116+
requestInit = {
117+
method: "POST",
118+
headers: headers,
119+
body: JSON.stringify(body),
120+
signal: abortController.signal,
121+
agent: new Agent({
122+
rejectUnauthorized: false
123+
})
124+
}
125+
} else {
126+
requestInit = {
114127
method: "POST",
115128
headers: headers,
116129
body: JSON.stringify(body),
117130
signal: abortController.signal
118-
},
131+
}
132+
}
133+
new FetchStream({
134+
url: serverAddress + uri,
135+
requestInit: requestInit,
119136
onmessage: msgCallback,
120137
ondone: doneCallback,
121138
onerror: errorCallback

0 commit comments

Comments
 (0)