ssl certificate fix

This commit is contained in:
Nate Sesti 2023-07-02 12:47:08 -07:00
parent 4871ff4f6e
commit 03499fc0b7
6 changed files with 31 additions and 21 deletions

View file

@ -6,7 +6,7 @@ authors = ["Nate Sesti <sestinj@gmail.com>"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.9"
python = "^3.8"
diff-match-patch = "^20230430"
fastapi = "^0.95.1"
typer = "^0.7.0"

View file

@ -5,6 +5,11 @@ import aiohttp
from ...core.main import ChatMessage
from ..llm import LLM
from ..util.count_tokens import DEFAULT_ARGS, DEFAULT_MAX_TOKENS, compile_chat_messages, CHAT_MODELS, count_tokens
import certifi
import ssl
ca_bundle_path = certifi.where()
ssl_context = ssl.create_default_context(cafile=ca_bundle_path)
# SERVER_URL = "http://127.0.0.1:8080"
SERVER_URL = "https://proxy-server-l6vsfbzhba-uw.a.run.app"
@ -31,7 +36,7 @@ class ProxyServer(LLM):
async def complete(self, prompt: str, with_history: List[ChatMessage] = [], **kwargs) -> Coroutine[Any, Any, str]:
args = self.default_args | kwargs
async with aiohttp.ClientSession() as session:
async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl_context=ssl_context)) as session:
async with session.post(f"{SERVER_URL}/complete", json={
"messages": compile_chat_messages(args["model"], with_history, prompt, functions=None),
"unique_id": self.unique_id,
@ -47,7 +52,7 @@ class ProxyServer(LLM):
messages = compile_chat_messages(
self.default_model, messages, None, functions=args.get("functions", None))
async with aiohttp.ClientSession() as session:
async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl_context=ssl_context)) as session:
async with session.post(f"{SERVER_URL}/stream_chat", json={
"messages": messages,
"unique_id": self.unique_id,
@ -71,7 +76,7 @@ class ProxyServer(LLM):
messages = compile_chat_messages(
self.default_model, with_history, prompt, functions=args.get("functions", None))
async with aiohttp.ClientSession() as session:
async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl_context=ssl_context)) as session:
async with session.post(f"{SERVER_URL}/stream_complete", json={
"messages": messages,
"unique_id": self.unique_id,

View file

@ -1,12 +1,12 @@
{
"name": "continue",
"version": "0.0.99",
"version": "0.0.102",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "continue",
"version": "0.0.99",
"version": "0.0.102",
"license": "Apache-2.0",
"dependencies": {
"@electron/rebuild": "^3.2.10",

View file

@ -14,7 +14,7 @@
"displayName": "Continue",
"pricing": "Free",
"description": "The open-source coding autopilot",
"version": "0.0.99",
"version": "0.0.102",
"publisher": "Continue",
"engines": {
"vscode": "^1.60.0"

View file

@ -0,0 +1 @@
0.0.101

View file

@ -71,9 +71,11 @@ async function getPythonPipCommands() {
}
}
let pipCmd = pythonCmd.endsWith("3") ? "pip3" : "pip";
const version = stdout.split(" ")[1];
const [major, minor] = version.split(".");
if (parseInt(major) !== 3 || parseInt(minor) < 7) {
if (parseInt(major) !== 3 || parseInt(minor) < 8) {
// Need to check specific versions
const checkPython3VersionExists = async (minorVersion: number) => {
const [stdout, stderr] = await runCommand(
@ -82,24 +84,27 @@ async function getPythonPipCommands() {
return typeof stderr === "undefined" || stderr === "";
};
const validVersions = [7, 8, 9, 10, 11, 12];
const VALID_VERSIONS = [8, 9, 10, 11, 12];
let versionExists = false;
for (const minorVersion of validVersions) {
for (const minorVersion of VALID_VERSIONS) {
if (await checkPython3VersionExists(minorVersion)) {
versionExists = true;
break;
pythonCmd = `python3.${minorVersion}`;
pipCmd = `pip3.${minorVersion}`;
}
}
if (!versionExists) {
vscode.window.showErrorMessage(
"Continue requires Python3 version 3.7 or greater. Please update your Python3 installation, reload VS Code, and try again."
"Continue requires Python3 version 3.8 or greater. Please update your Python3 installation, reload VS Code, and try again."
);
throw new Error("Python3 is not installed.");
throw new Error("Python3.8 or greater is not installed.");
}
} else {
pythonCmd = `python${major}.${minor}`;
pipCmd = `pip${major}.${minor}`;
}
const pipCmd = pythonCmd.endsWith("3") ? "pip3" : "pip";
return [pythonCmd, pipCmd];
}
@ -298,14 +303,13 @@ export async function startContinuePythonServer() {
// Do this after above check so we don't have to waste time setting up the env
await setupPythonEnv();
let activateCmd = ". env/bin/activate";
let pythonCmd = "python3";
if (process.platform == "win32") {
activateCmd = ".\\env\\Scripts\\activate";
pythonCmd = "python";
}
const [pythonCmd] = await getPythonPipCommands();
const activateCmd =
process.platform == "win32"
? ".\\env\\Scripts\\activate"
: ". env/bin/activate";
let command = `cd "${path.join(
const command = `cd "${path.join(
getExtensionUri().fsPath,
"scripts"
)}" && ${activateCmd} && cd .. && ${pythonCmd} -m scripts.run_continue_server`;