Add configurable model parameter to jina_embed function

- Add model parameter to jina_embed
- Pass model from API server
- Default to jina-embeddings-v4
- Update function documentation
- Make model selection flexible
This commit is contained in:
yangdx 2025-11-28 15:38:29 +08:00
parent 1b02684e2f
commit 56e0365cf0
2 changed files with 5 additions and 1 deletions

View file

@ -780,6 +780,7 @@ def create_app(args):
) )
return await actual_func( return await actual_func(
texts, texts,
model=model,
embedding_dim=embedding_dim, embedding_dim=embedding_dim,
base_url=host, base_url=host,
api_key=api_key, api_key=api_key,

View file

@ -69,6 +69,7 @@ async def fetch_data(url, headers, data):
) )
async def jina_embed( async def jina_embed(
texts: list[str], texts: list[str],
model: str = "jina-embeddings-v4",
embedding_dim: int = 2048, embedding_dim: int = 2048,
late_chunking: bool = False, late_chunking: bool = False,
base_url: str = None, base_url: str = None,
@ -78,6 +79,8 @@ async def jina_embed(
Args: Args:
texts: List of texts to embed. texts: List of texts to embed.
model: The Jina embedding model to use (default: jina-embeddings-v4).
Supported models: jina-embeddings-v3, jina-embeddings-v4, etc.
embedding_dim: The embedding dimensions (default: 2048 for jina-embeddings-v4). embedding_dim: The embedding dimensions (default: 2048 for jina-embeddings-v4).
**IMPORTANT**: This parameter is automatically injected by the EmbeddingFunc wrapper. **IMPORTANT**: This parameter is automatically injected by the EmbeddingFunc wrapper.
Do NOT manually pass this parameter when calling the function directly. Do NOT manually pass this parameter when calling the function directly.
@ -107,7 +110,7 @@ async def jina_embed(
"Authorization": f"Bearer {os.environ['JINA_API_KEY']}", "Authorization": f"Bearer {os.environ['JINA_API_KEY']}",
} }
data = { data = {
"model": "jina-embeddings-v4", "model": model,
"task": "text-matching", "task": "text-matching",
"dimensions": embedding_dim, "dimensions": embedding_dim,
"embedding_type": "base64", "embedding_type": "base64",