Skip to content

Commit 0c4ecc5

Browse files
authored
Merge pull request #990 from guardrails-ai/dbrx-docs
Add Databricks to Using LLMs doc
2 parents 278b9cd + 515942f commit 0c4ecc5

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

docs/how_to_guides/using_llms.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,46 @@ result = guard(
246246
print(f"{result.validated_output}")
247247
```
248248

249+
## Databricks
250+
251+
### Basic Usage
252+
253+
```python
254+
from guardrails import Guard
255+
256+
os.environ["DATABRICKS_API_KEY"] = "" # your databricks key
257+
os.environ["DATABRICKS_API_BASE"] = "" # e.g.: https://abc-123ab12a-1234.cloud.databricks.com
258+
259+
guard = Guard()
260+
261+
result = guard(
262+
messages=[{"role":"user", "content":"How many moons does Jupiter have?"}],
263+
model="databricks/databricks-dbrx-instruct",
264+
)
265+
266+
print(f"{result.validated_output}")
267+
```
268+
269+
### Streaming
270+
271+
```python
272+
from guardrails import Guard
273+
274+
os.environ["DATABRICKS_API_KEY"] = "" # your databricks key
275+
os.environ["DATABRICKS_API_BASE"] = "" # e.g.: https://abc-123ab12a-1234.cloud.databricks.com
276+
277+
guard = Guard()
278+
279+
stream_chunk_generator = guard(
280+
messages=[{"role":"user", "content":"How many moons does Jupiter have?"}],
281+
model="databricks/databricks-dbrx-instruct",
282+
stream=True,
283+
)
284+
285+
for chunk in stream_chunk_generator
286+
print(f"{chunk.validated_output}")
287+
```
288+
249289
## Other LLMs
250290

251291
See LiteLLM’s documentation [here](https://docs.litellm.ai/docs/providers) for details on many other llms.

0 commit comments

Comments
 (0)