Databricks OpenAI Integration
The databricks-openai package provides seamless integration of Databricks AI features into OpenAI applications.
Installation
From PyPI
pip install databricks-openai
From Source
pip install git+https://git@github.com/databricks/databricks-ai-bridge.git#subdirectory=integrations/openai
Key Features
- Vector Search: Store and query vector representations using
VectorSearchRetrieverTool.
Getting Started
Use Vector Search on Databricks
# Step 1: call model with VectorSearchRetrieverTool defined
dbvs_tool = VectorSearchRetrieverTool(index_name="catalog.schema.my_index_name")
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{
"role": "user",
"content": "Using the Databricks documentation, answer what is Spark?"
}
]
first_response = client.chat.completions.create(
model="gpt-4o",
messages=messages,
tools=[dbvs_tool.tool]
)
# Step 2: Execute function code – parse the model's response and handle function calls.
tool_call = first_response.choices[0].message.tool_calls[0]
args = json.loads(tool_call.function.arguments)
result = dbvs_tool.execute(query=args["query"]) # For self-managed embeddings, optionally pass in openai_client=client
# Step 3: Supply model with results – so it can incorporate them into its final response.
messages.append(first_response.choices[0].message)
messages.append({
"role": "tool",
"tool_call_id": tool_call.id,
"content": json.dumps(result)
})
second_response = client.chat.completions.create(
model="gpt-4o",
messages=messages,
tools=tools
)
Contribution Guide
We welcome contributions! Please see our contribution guidelines for details.
License
This project is licensed under the MIT License.
Thank you for using Databricks OpenAI!
Metadata
Release files for databricks-openai 0.17.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| databricks_openai-0.17.1.tar.gz | 17.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| databricks_openai-0.17.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.3 kB
Release files / databricks_openai-0.17.1.tar.gz
| Download URL | databricks_openai-0.17.1.tar.gz |
|---|---|
| Size | 17.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
539ed84c1131a807c21e1eb3f0f6eb40ca980dfb78dafd1519f5001e14ba77e0
|
|
BLAKE2b-256 checksum How to use checksums |
8e4d117348a87bb22ba87f24605f7195ed9515f0ef7405fe7a5d4ea0371d9f7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / databricks_openai-0.17.1-py3-none-any.whl
| Download URL | databricks_openai-0.17.1-py3-none-any.whl |
|---|---|
| Size | 21.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
29b98f04984f800c44e4351c19fbd87e5c07a374f9dfda4def1dff2f2d3b3c69
|
|
BLAKE2b-256 checksum How to use checksums |
bb773b52ae812ea11bb072def2c96b9159fe203f7cbd3e2fe56809d1588a70fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|