Files
Claude-Code-Workflow/ccw-litellm/src/ccw_litellm/interfaces/embedder.py
catlog22 bf66b095c7 feat: Add unified LiteLLM API management with dashboard UI and CLI integration
- Create ccw-litellm Python package with AbstractEmbedder and AbstractLLMClient interfaces
- Add BaseEmbedder abstraction and factory pattern to codex-lens for pluggable backends
- Implement API Settings dashboard page for provider credentials and custom endpoints
- Add REST API routes for CRUD operations on providers and endpoints
- Extend CLI with --model parameter for custom endpoint routing
- Integrate existing context-cache for @pattern file resolution
- Add provider model registry with predefined models per provider type
- Include i18n translations (en/zh) for all new UI elements

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 20:36:32 +08:00

53 lines
1.2 KiB
Python

from __future__ import annotations
import asyncio
from abc import ABC, abstractmethod
from typing import Any, Sequence
import numpy as np
from numpy.typing import NDArray
class AbstractEmbedder(ABC):
"""Embedding interface compatible with fastembed-style embedders.
Implementers only need to provide the synchronous `embed` method; an
asynchronous `aembed` wrapper is provided for convenience.
"""
@property
@abstractmethod
def dimensions(self) -> int:
"""Embedding vector size."""
@abstractmethod
def embed(
self,
texts: str | Sequence[str],
*,
batch_size: int | None = None,
**kwargs: Any,
) -> NDArray[np.floating]:
"""Embed one or more texts.
Returns:
A numpy array of shape (n_texts, dimensions).
"""
async def aembed(
self,
texts: str | Sequence[str],
*,
batch_size: int | None = None,
**kwargs: Any,
) -> NDArray[np.floating]:
"""Async wrapper around `embed` using a worker thread by default."""
return await asyncio.to_thread(
self.embed,
texts,
batch_size=batch_size,
**kwargs,
)