Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

fix: update parameters for azure v1

KCaverly4e0d37072dd9
diff --git a/dsp/modules/gpt3.py b/dsp/modules/gpt3.py
index 89e836ff4..9bbca4b0a 100644
--- a/dsp/modules/gpt3.py
+++ b/dsp/modules/gpt3.py
@@ -19,7 +19,7 @@ from dsp.modules.cache_utils import CacheMemory, NotebookCacheMemory, cache_turn
from dsp.modules.lm import LM
try:
- OPENAI_LEGACY = int(openai.version.__version__[0]) == 0
+ OPENAI_LEGACY = int(openai.__version__[0]) == 0
except Exception:
OPENAI_LEGACY = True
@@ -46,9 +46,6 @@ def backoff_hdlr(details):
)
-client = None
-
-
class GPT3(LM):
"""Wrapper around OpenAI's GPT API. Supports both the OpenAI and Azure APIs.
@@ -113,14 +110,13 @@ class GPT3(LM):
)
self.model_type = model_type if model_type else default_model_type
- if api_provider == "azure" and "model" not in kwargs:
+ if not OPENAI_LEGACY and api_provider == "azure" and "model" not in kwargs:
if "deployment_id" in kwargs:
kwargs["model"] = kwargs["deployment_id"]
del kwargs["deployment_id"]
- elif "engine" in kwargs:
- kwargs["model"] = kwargs["engine"]
- del kwargs["api_version"]
+ if "api_version" in kwargs:
+ del kwargs["api_version"]
if "model" not in kwargs:
kwargs["model"] = model