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

Feat: IBM watsonx.ai llm and embeddings integration #13600

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

Mateusz-Switala
Copy link

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Summary:
The aim of this PR is to introduce the official IBM watsonx.ai integration. Changes contains llm class WatsonxLLM that extend llama_index.core.llms.custom.customLLM and embeddings class WatsonxEmbeddings that extend llama_index.core.base.embeddings.base.Baseembeddings. Under the hood, integration uses components of ibm-watsonx-ai package and is aligned with the recent changes in ibm-watsonx-ai sdk.

Currently, there exist close llm integration in llamaindex to the proposed one: WatsonX https://docs.llamaindex.ai/en/stable/examples/llm/watsonx/ . However, since the mentioned integration uses old IBM python client sdk (i.e. ibm-watson-machine-learning), does not contain fully functionality of watsonx.ai service (i.a. deployment inferencing) and is not consistent with IBM watsonx.ai other open-source integrations (e.g. LangChain) we decided to introduce a new package: llama-index-llms-ibm. Simultaneously, we add deprecation warnings to the current llm WatsonX integration and change documentation accordingly.

fyi @LukaszCmielowski @acasaletto

New Package?

Did I fill in the tool.llamahub section in the pyproject.toml and provide a detailed README.md for my new integration or package?

  • Yes
  • No

Version Bump?

Did I bump the version in the pyproject.toml file of the package I am updating? (Except for the llama-index-core package)

  • Yes
  • No

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Added new unit/integration tests
  • Added new notebook (that tests end-to-end)
  • I stared at the code and made sure it makes sense

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added Google Colab support for the newly added notebooks.
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I ran make format; make lint to appease the lint gods

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@LukaszCmielowski
Copy link

@Mateusz-Switala Looks good. Let's switch to review and start the thread with the community.

@Mateusz-Switala Mateusz-Switala marked this pull request as ready for review May 20, 2024 14:54
@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label May 20, 2024
@Mateusz-Switala Mateusz-Switala marked this pull request as draft May 20, 2024 15:45
@Mateusz-Switala Mateusz-Switala marked this pull request as ready for review May 27, 2024 07:59
description = "llama-index llms IBM watsonx.ai integration"
exclude = ["**/BUILD"]
license = "MIT"
name = "llama-index-llms-ibm"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have a Watson integration in llama-index-integrations/llms/llama-index-llms-watsonx -- is this different?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@logan-markewich Changes contain both LLM and Embeddings integration. Currently, there exist close LLM integration in llamaindex to the proposed one: WatsonX https://docs.llamaindex.ai/en/stable/examples/llm/watsonx/ . However, since the mentioned integration uses old IBM python client sdk (i.e. ibm-watson-machine-learning), does not contain fully functionality of watsonx.ai service (i.a. deployment inferencing) and is not consistent with the IBM watsonx.ai other open-source integrations (e.g. LangChain) we decided to introduce a new package: llama-index-llms-ibm. Making the proposed changes in llama-index-llms-watsonx package instead of creating a new integration package may cause a few breaking changes. Simultaneously, we add deprecation warnings to the current llm WatsonX integration and change documentation accordingly.

Please note that this would be an official IBM watsonx.ai integration. Also, if the PR will be positively reviewed quickly, please DO NOT merge yet.

@Mateusz-Switala
Copy link
Author

@logan-markewich Changes are ready for official review.

fyi @LukaszCmielowski

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 12, 2024
)

parsed_url = urllib.parse.urlparse(creds["url"].get_secret_value())
if parsed_url.netloc.endswith("cloud.ibm.com"):

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

The string
cloud.ibm.com
may be at an arbitrary position in the sanitized URL.
)

parsed_url = urllib.parse.urlparse(creds["url"].get_secret_value())
if parsed_url.netloc.endswith("cloud.ibm.com"):

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

The string
cloud.ibm.com
may be at an arbitrary position in the sanitized URL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants