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

Updated Hugging Face chat and magics processing with new APIs, clients #784

Merged
merged 7 commits into from
May 16, 2024

Conversation

srdas
Copy link
Collaborator

@srdas srdas commented May 15, 2024

Fixes #772

(1) The API has changed and uses the HuggingFaceEndpoint class instead of HuggingFaceHub, which is deprecated.
(2) InferenceClient replaces InferenceAPI
(3) Removed legacy code that does not work with the new APIs
(4) Added logic to detect the task from the response type and handle text or images as needed.

References to the new langchain source for the new classes and APIs:

Test Example:
Use the mistral model
image
Chat question:
image

(1) The API has changed and uses the HuggingFaceClient class instead of HuggingFaceHub, which is deprecated.
(2) InferenceClient replaces InferenceAPI
(3) Removed legacy code that does not work with the new APIs/
@srdas srdas added the bug Something isn't working label May 15, 2024
@srdas srdas requested a review from dlqqq May 15, 2024 20:20
Copy link
Member

@dlqqq dlqqq left a comment

Choose a reason for hiding this comment

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

Left a comment below, but didn't complete a full review.

We should try to preserve the image generation capability when this provider is used in magics. Dropping that feature, although minor, would constitute a breaking change. I'm looking into the options available to us to support this.

packages/jupyter-ai-magics/jupyter_ai_magics/providers.py Outdated Show resolved Hide resolved
srdas and others added 2 commits May 16, 2024 07:11
Added logic to branch to one of text-gen or text-to-image tasks based on the type of response received.
@srdas srdas self-assigned this May 16, 2024
@srdas srdas changed the title Updated Hugging Face chat processing with new APIs, clients Updated Hugging Face chat and magics processing with new APIs, clients May 16, 2024
Copy link
Collaborator

@JasonWeill JasonWeill left a comment

Choose a reason for hiding this comment

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

Verified with images.ipynb in the examples directory of the code. Thanks!

@srdas srdas marked this pull request as ready for review May 16, 2024 20:15
@srdas srdas requested a review from dlqqq May 16, 2024 20:16
Copy link
Member

@dlqqq dlqqq left a comment

Choose a reason for hiding this comment

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

Awesome work @srdas!

@srdas srdas merged commit 20875ad into jupyterlab:main May 16, 2024
8 checks passed
@dlqqq
Copy link
Member

dlqqq commented May 16, 2024

Note: this PR will not be backported to 1.x as JupyterLab 3 reached end-of-maintenance yesterday. See #761.

krassowski added a commit to krassowski/jupyter-ai that referenced this pull request Jul 12, 2024
the overridden method is no longer overriding
allowed task list since jupyterlab#784 but is only breaking
streaming -  it can be removed
dlqqq pushed a commit to krassowski/jupyter-ai that referenced this pull request Jul 12, 2024
the overridden method is no longer overriding
allowed task list since jupyterlab#784 but is only breaking
streaming -  it can be removed
dlqqq pushed a commit that referenced this pull request Jul 12, 2024
the overridden method is no longer overriding
allowed task list since #784 but is only breaking
streaming -  it can be removed
Marchlak pushed a commit to Marchlak/jupyter-ai that referenced this pull request Oct 28, 2024
jupyterlab#784)

* Updated HF chat processing

(1) The API has changed and uses the HuggingFaceClient class instead of HuggingFaceHub, which is deprecated.
(2) InferenceClient replaces InferenceAPI
(3) Removed legacy code that does not work with the new APIs/

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Handle text gen and text_to_image tasks

Added logic to branch to one of text-gen or text-to-image tasks based on the type of response received.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Reworking conditional branching for text vs image

Used a different approach to check for task type

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Marchlak pushed a commit to Marchlak/jupyter-ai that referenced this pull request Oct 28, 2024
the overridden method is no longer overriding
allowed task list since jupyterlab#784 but is only breaking
streaming -  it can be removed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HuggingFaceHub fails with "Error raised by inference API: Cannot override task for LLM models"
3 participants