rig-tei
Rig adapter for TEI (Text Embedding Inference). This crate integrates local or remote TEI-style endpoints into the Rig ecosystem through a consistent, strongly-typed interface for:
- Text embeddings
- Reranking
- Simple endpoint overrides (per feature)
Documentation: https://docs.rs/rig-tei Repository: https://github.com/ooiai/rig-extend
Features
- Consistent Rig API surface:
Client::from_env()andClient::builder().embeddings(model)builder APIrerank(query, docs, top_k)convenience method
- Flexible routing:
- Global
TEI_BASE_URLor per-feature endpoint overrides (embed_endpoint,rerank_endpoint,predict_endpoint)
- Global
- Works with local or remote TEI routers
- Zero-auth by default (aligns with many local setups), but easily extensible if your router requires auth
- Typed requests/responses and structured errors aligned with Rig
Key defaults:
TEI_DEFAULT_BASE_URL:http://127.0.0.1:8080
Installation
From crates.io (recommended):
[]
= "0.1"
= "0.23" # Rig core
= "0.1" # Optional: for derive macros like Embed
From a workspace/path (if you’re developing locally):
[]
= { = "../rig-tei" }
= "0.23"
= "0.1"
Configuration (Environment Variables)
TEI_BASE_URL(optional): Override the base URL for the TEI router. Defaults to:http://127.0.0.1:8080
Example:
You can also bypass the environment variable and override feature endpoints directly via the builder:
.embed_endpoint("http://localhost:6280").rerank_endpoint("http://localhost:6290").predict_endpoint("http://localhost:6300")(if your router supports it)
Quick Start
Below are minimal snippets for embeddings and reranking.
Embeddings
use Embed;
use *;
use Embed;
async
Reranking
async
Examples
More end‑to‑end samples are available in this crate’s examples directory:
tei_embeddings.rstei_rerank.rs
Run from this crate directory:
# If needed, export TEI_BASE_URL or override endpoints in code
Versioning and Compatibility
- Rust edition: 2024
- This crate aligns its public surface with the Rig core abstractions. Check your
rigcrate version for compatibility (examples userig = "0.23").
License
MIT. See the LICENSE file (or package metadata) for details.