repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | from typing import Any, Dict, Optional |
| #2 | |
| #3 | from pydantic import BaseModel, ConfigDict, Field, model_validator |
| #4 | |
| #5 | |
| #6 | class FAISSConfig(BaseModel): |
| #7 | collection_name: str = Field("mem0", description="Default name for the collection") |
| #8 | path: Optional[str] = Field(None, description="Path to store FAISS index and metadata") |
| #9 | distance_strategy: str = Field( |
| #10 | "euclidean", description="Distance strategy to use. Options: 'euclidean', 'inner_product', 'cosine'" |
| #11 | ) |
| #12 | normalize_L2: bool = Field( |
| #13 | False, description="Whether to normalize L2 vectors (only applicable for euclidean distance)" |
| #14 | ) |
| #15 | embedding_model_dims: int = Field(1536, description="Dimension of the embedding vector") |
| #16 | |
| #17 | @model_validator(mode="before") |
| #18 | @classmethod |
| #19 | def validate_distance_strategy(cls, values: Dict[str, Any]) -> Dict[str, Any]: |
| #20 | distance_strategy = values.get("distance_strategy") |
| #21 | if distance_strategy and distance_strategy not in ["euclidean", "inner_product", "cosine"]: |
| #22 | raise ValueError("Invalid distance_strategy. Must be one of: 'euclidean', 'inner_product', 'cosine'") |
| #23 | return values |
| #24 | |
| #25 | @model_validator(mode="before") |
| #26 | @classmethod |
| #27 | def validate_extra_fields(cls, values: Dict[str, Any]) -> Dict[str, Any]: |
| #28 | allowed_fields = set(cls.model_fields.keys()) |
| #29 | input_fields = set(values.keys()) |
| #30 | extra_fields = input_fields - allowed_fields |
| #31 | if extra_fields: |
| #32 | raise ValueError( |
| #33 | f"Extra fields not allowed: {', '.join(extra_fields)}. Please input only the following fields: {', '.join(allowed_fields)}" |
| #34 | ) |
| #35 | return values |
| #36 | |
| #37 | model_config = ConfigDict(arbitrary_types_allowed=True) |
| #38 |