File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -246,6 +246,46 @@ result = guard(
246
246
print (f " { result.validated_output} " )
247
247
```
248
248
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
+
249
289
## Other LLMs
250
290
251
291
See LiteLLM’s documentation [ here] ( https://docs.litellm.ai/docs/providers ) for details on many other llms.
You can’t perform that action at this time.
0 commit comments