Skip to content

armgit / dspy

Public Imported from GitHub
0

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

Python

updated with LM documentation

Arnav Singhvidf8372acf292
diff --git a/docs/language_models_client.md b/docs/language_models_client.md
index f72d46cdf..d2a72b381 100644
--- a/docs/language_models_client.md
+++ b/docs/language_models_client.md
@@ -216,3 +216,44 @@ class Together(HFModel):
### Methods
Refer to [`dspy.OpenAI`](#openai) documentation.
+
+
+## Databricks (Model Serving Endpoints)
+
+### Usage
+```python
+lm = dspy.Databricks(model="databricks-mpt-30b-instruct")
+```
+
+### Constructor
+
+The constructor inherits from the `GPT3` class and verifies the Databricks authentication credentials for using Databricks Model Serving API through the OpenAI SDK.
+We expect the following environment variables to be set:
+- `openai.api_key`: Databricks API key.
+- `openai.base_url`: Databricks Model Endpoint url
+
+The `kwargs` attribute is initialized with default values for relevant text generation parameters needed for communicating with the Databricks OpenAI SDK, such as `temperature`, `max_tokens`, `top_p`, and `n`. However, it removes the `frequency_penalty` and `presence_penalty` arguments as these are not currently supported by the Databricks API.
+
+```python
+class Databricks(GPT3):
+ def __init__(
+ self,
+ model: str,
+ api_key: Optional[str] = None,
+ api_base: Optional[str] = None,
+ model_type: Literal["chat", "text"] = None,
+ **kwargs,
+ ):
+```
+
+**Parameters:**
+- `model` (_str_): models hosted on Databricks.
+- `stop` (_List[str]_, _optional_): List of stopping tokens to end generation.
+- `api_key` (_Optional[str]_): Databricks API key. Defaults to None
+- `api_base` (_Optional[str]_): Databricks Model Endpoint url Defaults to None.
+- `model_type` (_Literal["chat", "text", "embeddings"]_): Specified model type to use.
+- `**kwargs`: Additional language model arguments to pass to the API provider.
+
+### Methods
+
+Refer to [`dspy.OpenAI`](#openai) documentation.
\ No newline at end of file
diff --git a/dsp/modules/databricks.py b/dsp/modules/databricks.py
index 191f25140..be350c77e 100644
--- a/dsp/modules/databricks.py
+++ b/dsp/modules/databricks.py
@@ -55,7 +55,7 @@ class Databricks(GPT3):
model: str,
api_key: Optional[str] = None,
api_base: Optional[str] = None,
- model_type: Literal["chat", "text"] = None,
+ model_type: Literal["chat", "text", "embeddings"] = None,
**kwargs,
):
super().__init__(