From ff70e3604534bcafee420542072bcb21952ee8eb Mon Sep 17 00:00:00 2001 From: Cole Arendt Date: Fri, 13 Sep 2024 00:44:46 -0400 Subject: [PATCH 1/4] rename base_url parameter --- chatstream/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chatstream/__init__.py b/chatstream/__init__.py index c78e3c7..959dafa 100644 --- a/chatstream/__init__.py +++ b/chatstream/__init__.py @@ -348,7 +348,7 @@ async def perform_query(): extra_kwargs = {} if self.url() is not None: - extra_kwargs["url"] = self.url() + extra_kwargs["base_url"] = self.url() # Launch a Task that updates the chat string asynchronously. We run this in # a separate task so that the data can come in without need to await it in From 638382b7187a46da1eab0003f18714d3bc2ea5d5 Mon Sep 17 00:00:00 2001 From: Cole Arendt Date: Fri, 13 Sep 2024 01:01:36 -0400 Subject: [PATCH 2/4] move where client is initialized to set the base_url --- chatstream/__init__.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/chatstream/__init__.py b/chatstream/__init__.py index 959dafa..93c1834 100644 --- a/chatstream/__init__.py +++ b/chatstream/__init__.py @@ -48,10 +48,6 @@ from typing import ParamSpec, TypeGuard -client = AsyncOpenAI( - api_key=os.environ["OPENAI_API_KEY"], # this is also the default, it can be omitted -) - DEFAULT_MODEL: OpenAiModel = "gpt-3.5-turbo" DEFAULT_SYSTEM_PROMPT = "You are a helpful assistant." DEFAULT_TEMPERATURE = 0.7 @@ -347,8 +343,11 @@ async def perform_query(): print(f"TOKENS USED: {tokens_total}") extra_kwargs = {} - if self.url() is not None: - extra_kwargs["base_url"] = self.url() + + client = AsyncOpenAI( + base_url=self.url(), + api_key=os.environ["OPENAI_API_KEY"], # this is also the default, it can be omitted + ) # Launch a Task that updates the chat string asynchronously. We run this in # a separate task so that the data can come in without need to await it in From ee745fb3e198ff2e1b4538c6507252e65097c3a4 Mon Sep 17 00:00:00 2001 From: Cole Arendt Date: Fri, 13 Sep 2024 02:22:02 -0400 Subject: [PATCH 3/4] avoid a key error when the env var is missing --- chatstream/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chatstream/__init__.py b/chatstream/__init__.py index 93c1834..80f2f94 100644 --- a/chatstream/__init__.py +++ b/chatstream/__init__.py @@ -343,10 +343,10 @@ async def perform_query(): print(f"TOKENS USED: {tokens_total}") extra_kwargs = {} + client = AsyncOpenAI( base_url=self.url(), - api_key=os.environ["OPENAI_API_KEY"], # this is also the default, it can be omitted ) # Launch a Task that updates the chat string asynchronously. We run this in From b7db53ccf37b6941f5424be89505e1f19a27af60 Mon Sep 17 00:00:00 2001 From: Cole Arendt Date: Fri, 13 Sep 2024 02:33:49 -0400 Subject: [PATCH 4/4] add test api key --- chatstream/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/chatstream/__init__.py b/chatstream/__init__.py index 80f2f94..1114b63 100644 --- a/chatstream/__init__.py +++ b/chatstream/__init__.py @@ -347,6 +347,7 @@ async def perform_query(): client = AsyncOpenAI( base_url=self.url(), + api_key="test", ) # Launch a Task that updates the chat string asynchronously. We run this in