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, Field, model_validator |
| #4 | |
| #5 | |
| #6 | class PGVectorConfig(BaseModel): |
| #7 | dbname: str = Field("postgres", description="Default name for the database") |
| #8 | collection_name: str = Field("mem0", description="Default name for the collection") |
| #9 | embedding_model_dims: Optional[int] = Field(1536, description="Dimensions of the embedding model") |
| #10 | user: Optional[str] = Field(None, description="Database user") |
| #11 | password: Optional[str] = Field(None, description="Database password") |
| #12 | host: Optional[str] = Field(None, description="Database host. Default is localhost") |
| #13 | port: Optional[int] = Field(None, description="Database port. Default is 1536") |
| #14 | diskann: Optional[bool] = Field(False, description="Use diskann for approximate nearest neighbors search") |
| #15 | hnsw: Optional[bool] = Field(True, description="Use hnsw for faster search") |
| #16 | minconn: Optional[int] = Field(1, description="Minimum number of connections in the pool") |
| #17 | maxconn: Optional[int] = Field(5, description="Maximum number of connections in the pool") |
| #18 | # New SSL and connection options |
| #19 | sslmode: Optional[str] = Field(None, description="SSL mode for PostgreSQL connection (e.g., 'require', 'prefer', 'disable')") |
| #20 | connection_string: Optional[str] = Field(None, description="PostgreSQL connection string (overrides individual connection parameters)") |
| #21 | connection_pool: Optional[Any] = Field(None, description="psycopg connection pool object (overrides connection string and individual parameters)") |
| #22 | |
| #23 | @model_validator(mode="before") |
| #24 | def check_auth_and_connection(cls, values): |
| #25 | # If connection_pool is provided, skip validation of individual connection parameters |
| #26 | if values.get("connection_pool") is not None: |
| #27 | return values |
| #28 | |
| #29 | # If connection_string is provided, skip validation of individual connection parameters |
| #30 | if values.get("connection_string") is not None: |
| #31 | return values |
| #32 | |
| #33 | # Otherwise, validate individual connection parameters |
| #34 | user, password = values.get("user"), values.get("password") |
| #35 | host, port = values.get("host"), values.get("port") |
| #36 | if not user and not password: |
| #37 | raise ValueError("Both 'user' and 'password' must be provided when not using connection_string.") |
| #38 | if not host and not port: |
| #39 | raise ValueError("Both 'host' and 'port' must be provided when not using connection_string.") |
| #40 | return values |
| #41 | |
| #42 | @model_validator(mode="before") |
| #43 | @classmethod |
| #44 | def validate_extra_fields(cls, values: Dict[str, Any]) -> Dict[str, Any]: |
| #45 | allowed_fields = set(cls.model_fields.keys()) |
| #46 | input_fields = set(values.keys()) |
| #47 | extra_fields = input_fields - allowed_fields |
| #48 | if extra_fields: |
| #49 | raise ValueError( |
| #50 | f"Extra fields not allowed: {', '.join(extra_fields)}. Please input only the following fields: {', '.join(allowed_fields)}" |
| #51 | ) |
| #52 | return values |
| #53 |