Skip to content

Add LiteLLM embedding model support to RAG retriever - #1920

Merged
bgruening merged 7 commits into
bgruening:masterfrom
arash77:rag-litellm-embeddings
Sep 4, 2026
Merged

Add LiteLLM embedding model support to RAG retriever#1920
bgruening merged 7 commits into
bgruening:masterfrom
arash77:rag-litellm-embeddings

Conversation

@arash77

@arash77 arash77 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

This PR adds support for LiteLLM-hosted embedding models to the RAG Retriever tool, reusing the genai_models configuration from LLM Hub. The version suffix has also been bumped to 2.

Comment thread tools/rag/tool-data/genai_models.loc.sample Outdated
Comment thread tools/rag/rag_retriever.xml Outdated
Comment thread tools/rag/rag_retriever.xml Outdated
@bgruening

Copy link
Copy Markdown
Owner

Still draft?

@bgruening bgruening left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@arash77

arash77 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Still draft?

Yes, I need test it more before making it ready.

@arash77
arash77 marked this pull request as ready for review July 27, 2026 18:21
@anuprulez

Copy link
Copy Markdown
Contributor

I will have a look at it this week. thanks @arash77

@arash77

arash77 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

For testing it you can use Ollama locally and for example using this model:
ollama pull nomic-embed-text
then you can use this config files

  • tool-data/genai_models.loc:
    nomic-embed-text-ollama	nomic-embed-text	Nomic Embed Text (Ollama Local)	embedding	ollama-local	Free
    
  • litellm_config.yaml:
    servers:
      ollama-local:
        LITELLM_API_KEY: ollama
        LITELLM_BASE_URL: http://127.0.0.1:11434/v1

And then serve it with planemo:

planemo serve \
  --biocontainers \
  --docker_run_extra_arguments "--network host -e LITELLM_CONFIG_FILE='$PWD/litellm_config.yaml'" \
  --tool_data_table "$PWD/tool_data_table_conf.xml.sample" \
  --tool_data_path "$PWD/tool-data" \
  rag_retriever.xml

@IvoLeist

IvoLeist commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

@arash77 Anup asked me to test it and go through the changes as well:
I can confirm that testing it locally works 🚀

One thing I was stumbling about, since llm-hub just recently got the support for per-user quotas (#1922) maybe it would be worth to "equip" the RAG retriever tool with that functionality as well (?) 🤔

@arash77

arash77 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@arash77 Anup asked me to test it and go through the changes as well: I can confirm that testing it locally works 🚀

One thing I was stumbling about, since llm-hub just recently got the support for per-user quotas (#1922) maybe it would be worth to "equip" the RAG retriever tool with that functionality as well (?) 🤔

Thank you for testing it. Actually, yes, that is worth adding here, as they are using the same thing. I will work on it.

@anuprulez anuprulez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks @arash77 I have added my comments inline.

Can I run models coming from both tables at the same time locally? I just wanted to test models from litellm and huggingface table to compare runtime, quality etc.

Comment thread tools/rag/tool-data/genai_models.loc.sample
Comment thread tools/rag/rag_retriever.xml Outdated
@arash77

arash77 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Can I run models coming from both tables at the same time locally? I just wanted to test models from litellm and huggingface table to compare runtime, quality etc.

This should be already possible if you add both datatables.

@arash77
arash77 marked this pull request as draft July 29, 2026 13:37
arash77 added a commit to arash77/galaxytools that referenced this pull request Jul 29, 2026
The preinstalled (huggingface) path filters on free_tag=vector-rag and
version=1; it does not use the domain column. Fix the documented/example
domain value from 'text' to 'embedding' so the huggingface data table is
consistent with the genai_models table used by the LiteLLM path.

Addresses review feedback in bgruening#1920: the domain column should mark text
embedding models as 'embedding' in both tables rather than 'text'.

Also expand the sample header into a per-column reference matching the
tabpfn huggingface.loc.sample, documenting the shared table and that
free_tag is the per-tool selection key.
arash77 added a commit to arash77/galaxytools that referenced this pull request Jul 29, 2026
Mirror llm_hub's per-user request attribution (PR bgruening#1922): pass
$__user_id__ and $__galaxy_url__ from the wrapper and forward them to
the LiteLLM proxy as the standard OpenAI user field via
OpenAIEmbedding's additional_kwargs (a SHA-256 of
galaxy_url|user_id, namespaced per-instance and hashed so no personal
data leaves for the provider). Anonymous sessions fall back to a
per-instance shared "anonymous" bucket.

The hash formula and "Anonymous" normalization are identical to
llm_hub.py so both tools map one Galaxy user to one proxy identity,
enabling per-user metering and budgets/rate limits on a shared proxy.

Scoped to the LiteLLM path; local HuggingFace embeddings are unchanged
(no proxy call).

Addresses bgruening#1920 (comment)
@arash77
arash77 marked this pull request as ready for review July 29, 2026 15:03
bgruening pushed a commit to usegalaxy-eu/infrastructure-playbook that referenced this pull request Jul 29, 2026
The RAG Retriever's preinstalled path selects models via free_tag=vector-rag
and version=1; it does not filter on the domain column. Set domain to
'embedding' for the two RAG embedding rows so the column is consistent with
the genai_models.loc table used by the LiteLLM path.

Also add 'tabular' and 'embedding' to the domain column's documented example
values in the header (tabular was already in use by the tabpfn rows).

This is a documentation/consistency change only — the tool's selection logic
is unaffected since it filters on free_tag, not domain.

Companion to bgruening/galaxytools#1920.
@anuprulez

Copy link
Copy Markdown
Contributor

This looks good to me if no further changes are required :)

arash77 and others added 7 commits August 6, 2026 13:29
Remove the space around the slice colon in texts[i : i + batch] to
satisfy flake8/PEP 8.
- Comment out example rows in genai_models.loc.sample (samples must not
  contain uncommented rows)
- Drop LiteLLM proxy / genai_models / huggingface data-table details from
  the user-facing help and the no_options validator message
- Mention hosted embedding models in .shed.yml long_description
Replace the custom LiteLLMEmbedding subclass with llama_index's built-in
OpenAIEmbedding, passing the proxy model id via model_name= (the class's
escape hatch around the hardcoded OpenAI model enum). This reuses the
framework's batching, retry and client handling instead of hand-rolling
an OpenAI client inside a BaseEmbedding subclass.

Collapse the seven positional argv arguments (embed source, path, value,
provider, top_k) into a single EMBED JSON blob built in the wrapper, so
the Python side reads one typed config object instead of five loose
strings. Restore explicit validation of the model/provider/path fields
the old positional layout checked.

Inline the litellm_client config resolution (load_litellm_config /
resolve_server) into rag_retriever.py so the RAG tool is self-contained,
and guard against an empty/blank LiteLLM config file. Make the request
timeout and SDK retry count configurable via environment variables,
read inline at the call site.

Verified locally with planemo test (3/3 passing).
Co-authored-by: Anup Kumar, PhD <anup.rulez@gmail.com>
The preinstalled (huggingface) path filters on free_tag=vector-rag and
version=1; it does not use the domain column. Fix the documented/example
domain value from 'text' to 'embedding' so the huggingface data table is
consistent with the genai_models table used by the LiteLLM path.

Addresses review feedback in bgruening#1920: the domain column should mark text
embedding models as 'embedding' in both tables rather than 'text'.

Also expand the sample header into a per-column reference matching the
tabpfn huggingface.loc.sample, documenting the shared table and that
free_tag is the per-tool selection key.
Mirror llm_hub's per-user request attribution (PR bgruening#1922): pass
$__user_id__ and $__galaxy_url__ from the wrapper and forward them to
the LiteLLM proxy as the standard OpenAI user field via
OpenAIEmbedding's additional_kwargs (a SHA-256 of
galaxy_url|user_id, namespaced per-instance and hashed so no personal
data leaves for the provider). Anonymous sessions fall back to a
per-instance shared "anonymous" bucket.

The hash formula and "Anonymous" normalization are identical to
llm_hub.py so both tools map one Galaxy user to one proxy identity,
enabling per-user metering and budgets/rate limits on a shared proxy.

Scoped to the LiteLLM path; local HuggingFace embeddings are unchanged
(no proxy call).

Addresses bgruening#1920 (comment)
@arash77
arash77 force-pushed the rag-litellm-embeddings branch from ae1c84e to f1e9c8c Compare August 6, 2026 11:29
@arash77

arash77 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Is anything blocking this, or can it be merged?

@bgruening
bgruening merged commit 48d8cfd into bgruening:master Sep 4, 2026
10 checks passed
@bgruening

Copy link
Copy Markdown
Owner

Thanks everyone!

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.

4 participants