Skip to content

Commit

Permalink
upgrade to v0.1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
carusyte committed Jan 30, 2024
1 parent 8998fe1 commit 01c08a5
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.11] - 2024-01-30

- Add setting to allow self-signed certificate which could be useful in dev / test stages

## [0.1.10] - 2024-01-25

- Fix error: request to \<AOAI URL\> failed, reason: read ECONNRESET
Expand Down
30 changes: 18 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "GAI Choy",
"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.",
"publisher": "carusyte",
"version": "0.1.10",
"version": "0.1.11",
"icon": "assets/logo.png",
"pricing": "Free",
"keywords": [
Expand Down Expand Up @@ -37,6 +37,12 @@
"type": "string",
"order": 1
},
"GAIChoy.AllowSelfSignedCert": {
"description": "Whether to allow self-signed certificate presented from the remote server",
"default": false,
"type": "boolean",
"order": 2
},
"GAIChoy.RunEnvForLLMs": {
"description": "The environment that should be used for running LLMs.",
"default": "Azure OpenAI",
Expand All @@ -46,7 +52,7 @@
"Azure OpenAI"
],
"type": "string",
"order": 2
"order": 3
},
"GAIChoy.ChatModel": {
"description": "The deployed model in Azure OpenAI which will be used for technical conversations.",
Expand All @@ -58,7 +64,7 @@
"gpt-4-32k"
],
"type": "string",
"order": 3
"order": 4
},
"GAIChoy.CodeCompletionModel": {
"description": "The deployed model in Azure OpenAI which will be used for code completions.",
Expand All @@ -70,14 +76,14 @@
"gpt-4-32k"
],
"type": "string",
"order": 4
"order": 5
},
"GAIChoy.ApiKey": {
"description": "Set the API key for Azure OpenAI service",
"type": "null",
"scope": "application",
"markdownDescription": "[Set API Key](command:gaichoy.set_api_key)",
"order": 5
"order": 6
},
"GAIChoy.ApiVersion": {
"description": "The API version for Azure OpenAI.",
Expand All @@ -90,13 +96,13 @@
"2023-09-01-preview"
],
"type": "string",
"order": 6
"order": 7
},
"GAIChoy.AutoTriggerCompletion": {
"description": "Whether or not to automatically trigger completion when typing.",
"default": false,
"type": "boolean",
"order": 7
"order": 8
},
"GAIChoy.AutoCompletionDelay": {
"description": "The delay in seconds before automatic code completion triggers.",
Expand All @@ -107,7 +113,7 @@
3
],
"default": 2,
"order": 8
"order": 9
},
"GAIChoy.CompletionMaxTokens": {
"description": "Maximum number of tokens for which suggestions will be displayed",
Expand All @@ -122,7 +128,7 @@
4096
],
"default": 64,
"order": 9
"order": 10
},
"GAIChoy.ChatMaxTokens": {
"description": "Maximum number of tokens for which chat messages will be displayed",
Expand All @@ -136,20 +142,20 @@
32768
],
"default": 2048,
"order": 10
"order": 11
},
"GAIChoy.EnableDebugMessage": {
"description": "Prints debug message to extension output.",
"type": "boolean",
"default": false,
"order": 11
"order": 12
},
"GAIChoy.ClearChatHistory": {
"description": "Clear the chat history",
"type": "null",
"scope": "application",
"markdownDescription": "[Clear chat history](command:gaichoy.clear_chat_history)",
"order": 12
"order": 13
}
}
},
Expand Down
6 changes: 6 additions & 0 deletions src/RequestCompletion.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable */
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";
import {Agent} from "https"
import { workspace } from "vscode";
import { translate } from "./LanguageHelper";
import ExtensionResource from "./ExtensionResource";
Expand All @@ -13,6 +14,11 @@ export async function postCompletion(fileName: string, fimPrefixCode: string, fi
const serverAddress = workspace.getConfiguration("GAIChoy").get("ServerAddress") as string;
let maxtokens = workspace.getConfiguration("GAIChoy").get("CompletionMaxTokens") as number;
const modelEnv = workspace.getConfiguration("GAIChoy").get("RunEnvForLLMs") as string;
const allowSelfSignedCert = workspace.getConfiguration("GAIChoy").get("AllowSelfSignedCert") as boolean

if (allowSelfSignedCert) {
axios.defaults.httpsAgent = new Agent({ rejectUnauthorized: false });
}

if ("Azure OpenAI" == modelEnv) {
return AzureOAI.completeCode(fileName, fimPrefixCode, fimSuffixCode, axiosInstance);
Expand Down
31 changes: 24 additions & 7 deletions src/RequestEventStream.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable */
import { Agent } from "https";
import { workspace } from "vscode";
import { FetchStream } from "./FetchStream";
import { ChatItem } from "./ChatMemory";
Expand All @@ -17,6 +18,7 @@ export async function postEventStream(prompt: string, chatList: Array<ChatItem>,
const api_version = workspace.getConfiguration("GAIChoy").get("ApiVersion") as string;
const maxtokens = workspace.getConfiguration("GAIChoy").get("ChatMaxTokens") as number;
const modelEnv = workspace.getConfiguration("GAIChoy").get("RunEnvForLLMs") as string;
const allowSelfSignedCert = workspace.getConfiguration("GAIChoy").get("AllowSelfSignedCert") as boolean

// get API key from secret storage
let api_key = await ExtensionResource.instance.getApiKey();
Expand All @@ -34,8 +36,8 @@ export async function postEventStream(prompt: string, chatList: Array<ChatItem>,
"Content-Type": "application/json",
};
body = {
"prompt": "|<end>|" + prompt, "n_predict": maxtokens,
"temperature": 0.8, "repetition_penalty": 1.2, "top_k":40, "top_p":0.95, "stream": true,
"prompt": "|<end>|" + prompt, "n_predict": maxtokens,
"temperature": 0.8, "repetition_penalty": 1.2, "top_k": 40, "top_p": 0.95, "stream": true,
"stop": ["|<end>|", "|end|", "<|endoftext|>", "## human"]
};
}
Expand All @@ -49,7 +51,7 @@ export async function postEventStream(prompt: string, chatList: Array<ChatItem>,
"inputs": prompt,
"parameters": {
"max_new_tokens": maxtokens,
"temperature": 0.6, "repetition_penalty": 1.2, "top_p": 0.95, "do_sample": true,
"temperature": 0.6, "repetition_penalty": 1.2, "top_p": 0.95, "do_sample": true,
"stop": ["|<end>|", "|end|", "<|endoftext|>", "## human"]
}
};
Expand Down Expand Up @@ -108,14 +110,29 @@ export async function postEventStream(prompt: string, chatList: Array<ChatItem>,
}
}
abortController = new AbortController();
new FetchStream({
url: serverAddress + uri,
requestInit: {
var requestInit = {}
// Enable option to trust self-signed certificate
if (allowSelfSignedCert) {
requestInit = {
method: "POST",
headers: headers,
body: JSON.stringify(body),
signal: abortController.signal,
agent: new Agent({
rejectUnauthorized: false
})
}
} else {
requestInit = {
method: "POST",
headers: headers,
body: JSON.stringify(body),
signal: abortController.signal
},
}
}
new FetchStream({
url: serverAddress + uri,
requestInit: requestInit,
onmessage: msgCallback,
ondone: doneCallback,
onerror: errorCallback
Expand Down

0 comments on commit 01c08a5

Please sign in to comment.