Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Databricks Integration: Integrate Databricks SDK as optional mechanism for fetching API base and token, if unspecified #5746

Merged
merged 17 commits into from
Sep 19, 2024

Conversation

dbczumar
Copy link
Contributor

Title

Integrate Databricks SDK as optional mechanism for fetching API base and token, if unspecified

Relevant issues

Type

🆕 New Feature

Changes

This PR introduces support for using the Databricks SDK to automatically fetch an API token and API base from the current environment when handling completions requests, if the user does not specify a token / base manually.

Unit tests

Screenshot 2024-09-17 at 12 28 19 AM

Manual tests

Ran the following script and confirmed that the output is sane:

import asyncio
from litellm import completion, acompletion, embedding, aembedding
import os

response = completion(
    model="databricks/databricks-dbrx-instruct", 
    messages = [{ "content": "Hello, how are you?","role": "user"}],
    stream=False,
)

print(response)
print(list(response))

os.environ["DATABRICKS_API_KEY"] = "...."
os.environ["DATABRICKS_API_BASE"] = "...."


response = completion(
    model="databricks/databricks-dbrx-instruct", 
    messages = [{ "content": "Hello, how are you?","role": "user"}],
    stream=True
)
print(response)
print(list(response))

response = asyncio.run(acompletion(
    model="databricks/databricks-dbrx-instruct", 
    messages = [{ "content": "Hello, how are you?","role": "user"}]
))
print(response)

response = asyncio.run(acompletion(
    model="databricks/databricks-dbrx-instruct", 
    messages = [{ "content": "Hello, how are you?","role": "user"}],
    stream=True
))
print(response)
print(asyncio.run(anext(asyncio.run(response.fetch_stream()))))

response = embedding(
    model="databricks/databricks-bge-large-en",
    input=["Hello, how are you?"],
)

print(response)
print(list(response))

response = asyncio.run(aembedding(
    model="databricks/databricks-bge-large-en",
    input=["Hello, how are you?"],
))

print(response)
print(list(response))

krrishdholakia and others added 15 commits September 16, 2024 22:11
* coverage (BerriAI#5713)

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Move (BerriAI#5714)

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* fix(litellm_logging.py): fix logging client re-init (BerriAI#5710)

Fixes BerriAI#5695

* fix(presidio.py): Fix logging_hook response and add support for additional presidio variables in guardrails config

Fixes BerriAI#5682

* feat(o1_handler.py): fake streaming for openai o1 models

Fixes BerriAI#5694

* docs: deprecated traceloop integration in favor of native otel (BerriAI#5249)

* fix: fix linting errors

* fix: fix linting errors

* fix(main.py): fix o1 import

---------

Signed-off-by: dbczumar <corey.zumar@databricks.com>
Co-authored-by: Corey Zumar <39497902+dbczumar@users.noreply.github.com>
Co-authored-by: Nir Gazit <nirga@users.noreply.github.com>
…ndpoint for updating material view (BerriAI#5730)

* feat(spend_management_endpoints.py): expose `/global/spend/refresh` endpoint for updating material view

Supports having `MonthlyGlobalSpend` view be a material view, and exposes an endpoint to refresh it

* fix(custom_logger.py): reset calltype

* fix: fix linting errors
Signed-off-by: dbczumar <corey.zumar@databricks.com>
Signed-off-by: dbczumar <corey.zumar@databricks.com>
Signed-off-by: dbczumar <corey.zumar@databricks.com>
Signed-off-by: dbczumar <corey.zumar@databricks.com>
Signed-off-by: dbczumar <corey.zumar@databricks.com>
Signed-off-by: dbczumar <corey.zumar@databricks.com>
Signed-off-by: dbczumar <corey.zumar@databricks.com>
Signed-off-by: dbczumar <corey.zumar@databricks.com>
Signed-off-by: dbczumar <corey.zumar@databricks.com>
Signed-off-by: dbczumar <corey.zumar@databricks.com>
Copy link

vercel bot commented Sep 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 17, 2024 7:06pm

Signed-off-by: dbczumar <corey.zumar@databricks.com>
Signed-off-by: dbczumar <corey.zumar@databricks.com>
@dbczumar
Copy link
Contributor Author

@krrishdholakia I refiled this against main, since https://github.com/BerriAI/litellm/pull/5733/files was closed when the target branch was deleted. Can you take another look?

@krrishdholakia
Copy link
Contributor

Yup. Assigning myself to this ticket. Great work on this @dbczumar

@krrishdholakia krrishdholakia self-assigned this Sep 17, 2024
@krrishdholakia
Copy link
Contributor

Aiming to have this merged into tomorrow's release

@dbczumar
Copy link
Contributor Author

@krrishdholakia Did you get a chance to take a look at this?

@krrishdholakia krrishdholakia changed the base branch from main to litellm_dev_09_18_2024 September 19, 2024 01:17
@krrishdholakia krrishdholakia merged commit c96fccb into BerriAI:litellm_dev_09_18_2024 Sep 19, 2024
3 checks passed
@krrishdholakia
Copy link
Contributor

thanks for the bump @dbczumar

krrishdholakia added a commit that referenced this pull request Sep 19, 2024
* fix(proxy_server.py): fix azure key vault logic to not require client id/secret

* feat(cost_calculator.py): support fireworks ai cost tracking

* build(docker-compose.yml): add lines for mounting config.yaml to docker compose

Closes #5739

* fix(input.md): update docs to clarify litellm supports content as a list of dictionaries

Fixes #5755

* fix(input.md): update input.md to include all message values

* fix(image_handling.py): follow image url redirects

Fixes #5763

* fix(router.py): Fix model key/base leak in error message

Fixes #5762

* fix(http_handler.py): fix linting error

* fix(azure.py): fix logging to show azure_ad_token being used

Fixes #5767

* fix(_redis.py): add redis sentinel support

Closes #4381

* feat(_redis.py): add redis sentinel support

Closes #4381

* test(test_completion_cost.py): fix test

* Databricks Integration: Integrate Databricks SDK as optional mechanism for fetching API base and token, if unspecified (#5746)

* LiteLLM Minor Fixes & Improvements (09/16/2024)  (#5723)

* coverage (#5713)

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Move (#5714)

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* fix(litellm_logging.py): fix logging client re-init (#5710)

Fixes #5695

* fix(presidio.py): Fix logging_hook response and add support for additional presidio variables in guardrails config

Fixes #5682

* feat(o1_handler.py): fake streaming for openai o1 models

Fixes #5694

* docs: deprecated traceloop integration in favor of native otel (#5249)

* fix: fix linting errors

* fix: fix linting errors

* fix(main.py): fix o1 import

---------

Signed-off-by: dbczumar <corey.zumar@databricks.com>
Co-authored-by: Corey Zumar <39497902+dbczumar@users.noreply.github.com>
Co-authored-by: Nir Gazit <nirga@users.noreply.github.com>

* feat(spend_management_endpoints.py): expose `/global/spend/refresh` endpoint for updating material view (#5730)

* feat(spend_management_endpoints.py): expose `/global/spend/refresh` endpoint for updating material view

Supports having `MonthlyGlobalSpend` view be a material view, and exposes an endpoint to refresh it

* fix(custom_logger.py): reset calltype

* fix: fix linting errors

* fix: fix linting error

* fix

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* fix: fix import

* Fix

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* fix

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* DB test

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Coverage

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* progress

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* fix

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* fix

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* fix

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* fix test name

Signed-off-by: dbczumar <corey.zumar@databricks.com>

---------

Signed-off-by: dbczumar <corey.zumar@databricks.com>
Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
Co-authored-by: Nir Gazit <nirga@users.noreply.github.com>

* test: fix test

* test(test_databricks.py): fix test

* fix(databricks/chat.py): handle custom endpoint (e.g. sagemaker)

* Apply code scanning fix for clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* fix(__init__.py): fix known fireworks ai models

---------

Signed-off-by: dbczumar <corey.zumar@databricks.com>
Co-authored-by: Corey Zumar <39497902+dbczumar@users.noreply.github.com>
Co-authored-by: Nir Gazit <nirga@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants