From 5cdd7eb2478a8f103d24ea1949305f02511ebba4 Mon Sep 17 00:00:00 2001 From: Insop Song Date: Fri, 1 Mar 2024 17:22:26 -0800 Subject: [PATCH] BootstrapFewShot failing due to lm.copy for AzureOpenAI, #521 BootstrapFewShot failing due to lm.copy for AzureOpenAI, likely due to positional argument issue from recent changes. - code: 98304a2eb9d1dddaaa846e30258cd5d8fc6b5d8d - model azure openai - during `BootstrapFewShot` run, code errored out due to missing arguments, `api_version` ``` >[dspy/dsp/modules/lm.py](https://file+.vscode-resource.vscode-cdn.net/Users/insop/Projects/Github/NLP/dspy/dsp/modules/lm.py)(106)copy() 102 model = kwargs.pop('model') 105 --> 106 return self.__class__(model, **kwargs) ``` AzureOpenAI expects positional arguments, so it is failing. I will add my fixes and see if that will impact other models. ``` class AzureOpenAI(LM): ... def __init__( self, api_base: str, api_version: str, model: str = "gpt-3.5-turbo-instruct", api_key: Optional[str] = None, model_type: Literal["chat", "text"] = "chat", **kwargs, ): --- dsp/modules/azure_openai.py | 3 +++ dsp/modules/lm.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/dsp/modules/azure_openai.py b/dsp/modules/azure_openai.py index d930bec6b..c90f634e4 100644 --- a/dsp/modules/azure_openai.py +++ b/dsp/modules/azure_openai.py @@ -107,6 +107,9 @@ def __init__( kwargs["model"] = model self.kwargs = { + "api_base": api_base, + "api_version": api_version, + "api_key": api_key, "temperature": 0.0, "max_tokens": 150, "top_p": 1, diff --git a/dsp/modules/lm.py b/dsp/modules/lm.py index e2965d49a..5d3866079 100644 --- a/dsp/modules/lm.py +++ b/dsp/modules/lm.py @@ -101,4 +101,4 @@ def copy(self, **kwargs): kwargs = {**self.kwargs, **kwargs} model = kwargs.pop('model') - return self.__class__(model, **kwargs) + return self.__class__(model=model, **kwargs)