Skip to content

armgit / dspy

Public Imported from GitHub
0

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

Python

Allow to configure Anyscale API in constructor

Alex7fc074653454
diff --git a/dsp/modules/hf_client.py b/dsp/modules/hf_client.py
index 5885058a3..68f92af09 100644
--- a/dsp/modules/hf_client.py
+++ b/dsp/modules/hf_client.py
@@ -397,11 +397,11 @@ class Together(HFModel):
class Anyscale(HFModel):
- def __init__(self, model, **kwargs):
+ def __init__(self, model, api_base="https://api.endpoints.anyscale.com/v1", api_key=None, **kwargs):
super().__init__(model=model, is_client=True)
self.session = requests.Session()
- self.api_base = os.getenv("ANYSCALE_API_BASE")
- self.token = os.getenv("ANYSCALE_API_KEY")
+ self.api_base = os.getenv("ANYSCALE_API_BASE") or api_base
+ self.token = os.getenv("ANYSCALE_API_KEY") or api_key
self.model = model
self.kwargs = {
"temperature": 0.0,