Skip to content

Commit

Permalink
Merge pull request #187 from langchain-ai/nc/15feb/fix-socks
Browse files Browse the repository at this point in the history
Fix after openai proxy support
  • Loading branch information
nfcampos authored Feb 15, 2024
2 parents d3425b1 + a91257b commit 96a1b1a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
16 changes: 13 additions & 3 deletions backend/app/llms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 13 additions & 1 deletion backend/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 96a1b1a

Please sign in to comment.