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, List, Optional |
| #2 | |
| #3 | from pydantic import BaseModel, Field, model_validator |
| #4 | |
| #5 | |
| #6 | class CassandraConfig(BaseModel): |
| #7 | """Configuration for Apache Cassandra vector database.""" |
| #8 | |
| #9 | contact_points: List[str] = Field( |
| #10 | ..., |
| #11 | description="List of contact point addresses (e.g., ['127.0.0.1', '127.0.0.2'])" |
| #12 | ) |
| #13 | port: int = Field(9042, description="Cassandra port") |
| #14 | username: Optional[str] = Field(None, description="Database username") |
| #15 | password: Optional[str] = Field(None, description="Database password") |
| #16 | keyspace: str = Field("mem0", description="Keyspace name") |
| #17 | collection_name: str = Field("memories", description="Table name") |
| #18 | embedding_model_dims: int = Field(1536, description="Dimensions of the embedding model") |
| #19 | secure_connect_bundle: Optional[str] = Field( |
| #20 | None, |
| #21 | description="Path to secure connect bundle for DataStax Astra DB" |
| #22 | ) |
| #23 | protocol_version: int = Field(4, description="CQL protocol version") |
| #24 | load_balancing_policy: Optional[Any] = Field( |
| #25 | None, |
| #26 | description="Custom load balancing policy object" |
| #27 | ) |
| #28 | |
| #29 | @model_validator(mode="before") |
| #30 | @classmethod |
| #31 | def check_auth(cls, values: Dict[str, Any]) -> Dict[str, Any]: |
| #32 | """Validate authentication parameters.""" |
| #33 | username = values.get("username") |
| #34 | password = values.get("password") |
| #35 | |
| #36 | # Both username and password must be provided together or not at all |
| #37 | if (username and not password) or (password and not username): |
| #38 | raise ValueError( |
| #39 | "Both 'username' and 'password' must be provided together for authentication" |
| #40 | ) |
| #41 | |
| #42 | return values |
| #43 | |
| #44 | @model_validator(mode="before") |
| #45 | @classmethod |
| #46 | def check_connection_config(cls, values: Dict[str, Any]) -> Dict[str, Any]: |
| #47 | """Validate connection configuration.""" |
| #48 | secure_connect_bundle = values.get("secure_connect_bundle") |
| #49 | contact_points = values.get("contact_points") |
| #50 | |
| #51 | # Either secure_connect_bundle or contact_points must be provided |
| #52 | if not secure_connect_bundle and not contact_points: |
| #53 | raise ValueError( |
| #54 | "Either 'contact_points' or 'secure_connect_bundle' must be provided" |
| #55 | ) |
| #56 | |
| #57 | return values |
| #58 | |
| #59 | @model_validator(mode="before") |
| #60 | @classmethod |
| #61 | def validate_extra_fields(cls, values: Dict[str, Any]) -> Dict[str, Any]: |
| #62 | """Validate that no extra fields are provided.""" |
| #63 | allowed_fields = set(cls.model_fields.keys()) |
| #64 | input_fields = set(values.keys()) |
| #65 | extra_fields = input_fields - allowed_fields |
| #66 | |
| #67 | if extra_fields: |
| #68 | raise ValueError( |
| #69 | f"Extra fields not allowed: {', '.join(extra_fields)}. " |
| #70 | f"Please input only the following fields: {', '.join(allowed_fields)}" |
| #71 | ) |
| #72 | |
| #73 | return values |
| #74 | |
| #75 | class Config: |
| #76 | arbitrary_types_allowed = True |
| #77 | |
| #78 |