From a91257bed08e72c22da8fa0372b470662735636c Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Thu, 15 Feb 2024 13:20:12 -0800 Subject: [PATCH] Fix after openai proxy support --- backend/app/llms.py | 16 +++++++++++++--- backend/poetry.lock | 14 +++++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/backend/app/llms.py b/backend/app/llms.py index 859fdaa6..90add763 100644 --- a/backend/app/llms.py +++ b/backend/app/llms.py @@ -9,16 +9,26 @@ @lru_cache(maxsize=4) def get_openai_llm(gpt_4: bool = False, azure: bool = False): - proxy_url = os.environ["PROXY_URL"] + proxy_url = os.getenv("PROXY_URL") if proxy_url is not None or proxy_url != "": http_client = httpx.AsyncClient(proxies=proxy_url) else: http_client = None if not azure: if gpt_4: - llm = ChatOpenAI(http_client=http_client, model="gpt-4-1106-preview", temperature=0, streaming=True) + llm = ChatOpenAI( + http_client=http_client, + model="gpt-4-1106-preview", + temperature=0, + streaming=True, + ) else: - llm = ChatOpenAI(http_client=http_client, model="gpt-3.5-turbo-1106", temperature=0, streaming=True) + llm = ChatOpenAI( + http_client=http_client, + model="gpt-3.5-turbo-1106", + temperature=0, + streaming=True, + ) else: llm = AzureChatOpenAI( http_client=http_client, diff --git a/backend/poetry.lock b/backend/poetry.lock index ce9a7e57..d368bb04 100644 --- a/backend/poetry.lock +++ b/backend/poetry.lock @@ -1393,6 +1393,7 @@ certifi = "*" httpcore = "==1.*" idna = "*" sniffio = "*" +socksio = {version = "==1.*", optional = true, markers = "extra == \"socks\""} [package.extras] brotli = ["brotli", "brotlicffi"] @@ -2871,6 +2872,17 @@ files = [ {file = "sniffio-1.3.0.tar.gz", hash = "sha256:e60305c5e5d314f5389259b7f22aaa33d8f7dee49763119234af3755c55b9101"}, ] +[[package]] +name = "socksio" +version = "1.0.0" +description = "Sans-I/O implementation of SOCKS4, SOCKS4A, and SOCKS5." +optional = false +python-versions = ">=3.6" +files = [ + {file = "socksio-1.0.0-py3-none-any.whl", hash = "sha256:95dc1f15f9b34e8d7b16f06d74b8ccf48f609af32ab33c608d08761c5dcbb1f3"}, + {file = "socksio-1.0.0.tar.gz", hash = "sha256:f88beb3da5b5c38b9890469de67d0cb0f9d494b78b106ca1845f96c10b91c4ac"}, +] + [[package]] name = "soupsieve" version = "2.5" @@ -3616,4 +3628,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "^3.9.0" -content-hash = "5f2b0fad01dbfd25926f4d68dfcc8b03364eb2a76dfe8937c0b1d15fb80590a1" +content-hash = "08d25c6ac983f211b011a85e0e941c7afe5d1877c41b252e151f4b667a50ee02"