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, Type, Union |
| #2 | |
| #3 | from pydantic import BaseModel, Field, model_validator |
| #4 | |
| #5 | |
| #6 | class OpenSearchConfig(BaseModel): |
| #7 | collection_name: str = Field("mem0", description="Name of the index") |
| #8 | host: str = Field("localhost", description="OpenSearch host") |
| #9 | port: int = Field(9200, description="OpenSearch port") |
| #10 | user: Optional[str] = Field(None, description="Username for authentication") |
| #11 | password: Optional[str] = Field(None, description="Password for authentication") |
| #12 | api_key: Optional[str] = Field(None, description="API key for authentication (if applicable)") |
| #13 | embedding_model_dims: int = Field(1536, description="Dimension of the embedding vector") |
| #14 | verify_certs: bool = Field(False, description="Verify SSL certificates (default False for OpenSearch)") |
| #15 | use_ssl: bool = Field(False, description="Use SSL for connection (default False for OpenSearch)") |
| #16 | http_auth: Optional[object] = Field(None, description="HTTP authentication method / AWS SigV4") |
| #17 | connection_class: Optional[Union[str, Type]] = Field( |
| #18 | "RequestsHttpConnection", description="Connection class for OpenSearch" |
| #19 | ) |
| #20 | pool_maxsize: int = Field(20, description="Maximum number of connections in the pool") |
| #21 | |
| #22 | @model_validator(mode="before") |
| #23 | @classmethod |
| #24 | def validate_auth(cls, values: Dict[str, Any]) -> Dict[str, Any]: |
| #25 | # Check if host is provided |
| #26 | if not values.get("host"): |
| #27 | raise ValueError("Host must be provided for OpenSearch") |
| #28 | |
| #29 | return values |
| #30 | |
| #31 | @model_validator(mode="before") |
| #32 | @classmethod |
| #33 | def validate_extra_fields(cls, values: Dict[str, Any]) -> Dict[str, Any]: |
| #34 | allowed_fields = set(cls.model_fields.keys()) |
| #35 | input_fields = set(values.keys()) |
| #36 | extra_fields = input_fields - allowed_fields |
| #37 | if extra_fields: |
| #38 | raise ValueError( |
| #39 | f"Extra fields not allowed: {', '.join(extra_fields)}. Allowed fields: {', '.join(allowed_fields)}" |
| #40 | ) |
| #41 | return values |
| #42 |