From 0b2ff45ed91690e34d07089038b0e561631496c6 Mon Sep 17 00:00:00 2001 From: kanak8278 Date: Thu, 25 Jul 2024 18:28:43 +0530 Subject: [PATCH 1/2] chore: Set GPT_MODEL environment variable in mini_llm.py --- env.template | 1 + nl2dsl/utils/mini_llm.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/env.template b/env.template index f0c2f88..824a841 100644 --- a/env.template +++ b/env.template @@ -1,4 +1,5 @@ OPENAI_API_KEY= +MODEL_NAME= #AZURE_OPENAI_API_KEY= #AZURE_OPENAI_ENDPOINT= diff --git a/nl2dsl/utils/mini_llm.py b/nl2dsl/utils/mini_llm.py index 6210cc9..4e17c44 100644 --- a/nl2dsl/utils/mini_llm.py +++ b/nl2dsl/utils/mini_llm.py @@ -15,8 +15,10 @@ else: client = OpenAI() -GPT_MODEL = "gpt-4-turbo" +GPT_MODEL = os.getenv('MODEL_NAME') +if GPT_MODEL is None: + raise EnvironmentError("MODEL_NAME environment variable is not set.") @retry(wait=wait_random_exponential(multiplier=1, max=40), stop=stop_after_attempt(10)) def mini_llm(utterance, model="gpt-4-turbo", temperature=0.3): From 394a894240b6473a73d7ec507cdf444d8c1c7f4b Mon Sep 17 00:00:00 2001 From: kanak8278 Date: Fri, 26 Jul 2024 09:55:04 +0530 Subject: [PATCH 2/2] chore: Update environment variables in mini_llm.py and env.template Using SLOW_MODEL --- env.template | 5 ++++- nl2dsl/utils/mini_llm.py | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/env.template b/env.template index 824a841..5e2c917 100644 --- a/env.template +++ b/env.template @@ -1,5 +1,8 @@ OPENAI_API_KEY= -MODEL_NAME= +FAST_MODEL= +# Internally we use SLOW_MODEL for the DSL generation +SLOW_MODEL= + #AZURE_OPENAI_API_KEY= #AZURE_OPENAI_ENDPOINT= diff --git a/nl2dsl/utils/mini_llm.py b/nl2dsl/utils/mini_llm.py index 4e17c44..0866fea 100644 --- a/nl2dsl/utils/mini_llm.py +++ b/nl2dsl/utils/mini_llm.py @@ -15,10 +15,10 @@ else: client = OpenAI() -GPT_MODEL = os.getenv('MODEL_NAME') +SLOW_MODEL = os.getenv('SLOW_MODEL') -if GPT_MODEL is None: - raise EnvironmentError("MODEL_NAME environment variable is not set.") +if SLOW_MODEL is None: + raise EnvironmentError("SLOW_MODEL environment variable is not set.") @retry(wait=wait_random_exponential(multiplier=1, max=40), stop=stop_after_attempt(10)) def mini_llm(utterance, model="gpt-4-turbo", temperature=0.3): @@ -35,7 +35,7 @@ def mini_llm(utterance, model="gpt-4-turbo", temperature=0.3): @retry(wait=wait_random_exponential(multiplier=1, max=40), stop=stop_after_attempt(10)) def chat_completion_request( - messages, tools=None, tool_choice=None, model=GPT_MODEL, response_format=None + messages, tools=None, tool_choice=None, model=SLOW_MODEL, response_format=None ): response = client.chat.completions.create( model=model,