Skip to content

feat: add grpc support for the huggingface text embedding inference (TEI) components - #3870

Open
maxdswain wants to merge 3 commits into
deepset-ai:mainfrom
maxdswain:tei-grpc
Open

feat: add grpc support for the huggingface text embedding inference (TEI) components#3870
maxdswain wants to merge 3 commits into
deepset-ai:mainfrom
maxdswain:tei-grpc

Conversation

@maxdswain

@maxdswain maxdswain commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

Add grpc support through optional grpc extras for the hugging face text embedding inference (TEI). To support this implementation, I generated a grpc client from the latest TEI protobuf. Instructions on how to regenerate the files from the protobuf have been added to the README.

This needed to be done as the existing huggingface hub inference client does not support grpc, and does not intend to.

How did you test it?

Added unit and integration tests. You need to run docker compose up -d before running the integration tests.

Notes for the reviewer

The TEI grpc API doesn't have an API where it takes a list of inputs to embed, so instead for the document embedder components, I used the EmbedStream interface. In my testing, this is faster then using multiple streams one after the other and batching requests.

I kept grpc client initialisation in the __init__ method to prevent wasted compute/time on every run or run_async call.

Checklist

@maxdswain
maxdswain requested a review from a team as a code owner August 29, 2026 12:58
@maxdswain
maxdswain requested review from bogdankostic and removed request for a team August 29, 2026 12:58
@github-actions

Copy link
Copy Markdown
Contributor

Heads-up for maintainers

This PR is from a fork and touches integrations whose integration tests require API keys.
Those tests are skipped in CI because fork PRs don't have access to repo secrets for security reasons.

Affected integrations:

  • huggingface_api

Please run the integration tests locally (hatch run test:integration inside each folder) before approving.

@github-actions github-actions Bot added the type:documentation Improvements or additions to documentation label Aug 29, 2026
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedpypi/​grpcio@​1.83.17210010010070

View full report

@github-actions

Copy link
Copy Markdown
Contributor

Coverage report (huggingface_api)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  integrations/huggingface_api/src/haystack_integrations/components/embedders/huggingface_api
  document_embedder.py 190-191, 292, 308-309, 337, 356-357, 430, 466
  sparse_document_embedder.py 150, 173, 196-197
  sparse_text_embedder.py
  text_embedder.py 153-154, 157-161, 249-252, 287-290
  integrations/huggingface_api/src/haystack_integrations/components/embedders/huggingface_api/_grpc
  tei_pb2.py 33-97
  tei_pb2_grpc.py 15-16, 19, 37, 49-51, 55-65, 83, 146-148, 152-154, 158-160, 164-166, 170-172, 176-178, 182-217, 235, 262, 289, 316, 343, 370, 396-411, 423-425, 429-431, 435-437, 441-443, 447-472, 490, 517, 544, 571, 597-602, 614-616, 620-622, 626-641, 659, 686, 712-727, 739-741, 745-747, 751-753, 757-759, 763-788, 806, 833, 860, 887
Project Total  

This report was generated by python-coverage-comment-action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:huggingface-api topic:CI type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support gRPC interface of TEI

1 participant