Skip to main content

Support for Databricks AI support with OpenAI

Project description

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!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

databricks_openai-0.16.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

databricks_openai-0.16.0-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file databricks_openai-0.16.0.tar.gz.

File metadata

  • Download URL: databricks_openai-0.16.0.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for databricks_openai-0.16.0.tar.gz
Algorithm Hash digest
SHA256 bd0f5ec85ad3217a3d3973f5b19a83c4ccb34ccdcdf5c4e39d7d7c75fd13f266
MD5 d6bf8033130f9a97034a6db353ebef20
BLAKE2b-256 622ed83032ac73a4cea4bf51e7049fb769f7dc922d3901f0b1c5ebe73689c44f

See more details on using hashes here.

File details

Details for the file databricks_openai-0.16.0-py3-none-any.whl.

File metadata

File hashes

Hashes for databricks_openai-0.16.0-py3-none-any.whl
Algorithm Hash digest
SHA256 012e8a70a5b5bdf75679a992d1b95b54b4a72addbc5f4b062c2b6ed326ddaff6
MD5 0a58635244f7163d6beaa88edc7026c9
BLAKE2b-256 5a0dd057c085f953ab99a6d153a3613532c935cb5c62cd3bb0d54ddb2a09eab6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page