mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-11 02:33:51 +08:00
- 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>
53 lines
1.2 KiB
Python
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,
|
|
)
|
|
|