From 766cbecb854550b092dce12f00a2022d67779479 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Fri, 13 Oct 2023 11:27:26 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20always=20use=20custom=20ai?= =?UTF-8?q?ohttp=20session=20for=20openai?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/continuedev/libs/llm/openai.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/server/continuedev/libs/llm/openai.py b/server/continuedev/libs/llm/openai.py index 2276c1c99..49b70abd3 100644 --- a/server/continuedev/libs/llm/openai.py +++ b/server/continuedev/libs/llm/openai.py @@ -101,9 +101,8 @@ class OpenAI(LLM): openai.ca_bundle_path = self.ca_bundle_path or certifi.where() - if self.headers is not None or self.ca_bundle_path is not None or self.timeout != 300: - session = self.create_client_session() - openai.aiosession.set(session) + session = self.create_client_session() + openai.aiosession.set(session) def collect_args(self, options): args = super().collect_args(options) @@ -128,7 +127,9 @@ class OpenAI(LLM): if len(chunk.choices) > 0 and "content" in chunk.choices[0].delta: yield chunk.choices[0].delta.content else: - async for chunk in await openai.Completion.acreate(prompt=prompt, **args, headers=self.headers): + async for chunk in await openai.Completion.acreate( + prompt=prompt, **args, headers=self.headers + ): if len(chunk.choices) > 0: yield chunk.choices[0].text @@ -157,5 +158,11 @@ class OpenAI(LLM): return resp.choices[0].message.content else: return ( - (await openai.Completion.acreate(prompt=prompt, **args, headers=self.headers)).choices[0].text + ( + await openai.Completion.acreate( + prompt=prompt, **args, headers=self.headers + ) + ) + .choices[0] + .text )