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 | import os |
| #2 | from typing import Any, Dict, Optional |
| #3 | |
| #4 | from pydantic import BaseModel, ConfigDict, Field, model_validator |
| #5 | |
| #6 | |
| #7 | class PineconeConfig(BaseModel): |
| #8 | """Configuration for Pinecone vector database.""" |
| #9 | |
| #10 | collection_name: str = Field("mem0", description="Name of the index/collection") |
| #11 | embedding_model_dims: int = Field(1536, description="Dimensions of the embedding model") |
| #12 | client: Optional[Any] = Field(None, description="Existing Pinecone client instance") |
| #13 | api_key: Optional[str] = Field(None, description="API key for Pinecone") |
| #14 | environment: Optional[str] = Field(None, description="Pinecone environment") |
| #15 | serverless_config: Optional[Dict[str, Any]] = Field(None, description="Configuration for serverless deployment") |
| #16 | pod_config: Optional[Dict[str, Any]] = Field(None, description="Configuration for pod-based deployment") |
| #17 | hybrid_search: bool = Field(False, description="Whether to enable hybrid search") |
| #18 | metric: str = Field("cosine", description="Distance metric for vector similarity") |
| #19 | batch_size: int = Field(100, description="Batch size for operations") |
| #20 | extra_params: Optional[Dict[str, Any]] = Field(None, description="Additional parameters for Pinecone client") |
| #21 | namespace: Optional[str] = Field(None, description="Namespace for the collection") |
| #22 | |
| #23 | @model_validator(mode="before") |
| #24 | @classmethod |
| #25 | def check_api_key_or_client(cls, values: Dict[str, Any]) -> Dict[str, Any]: |
| #26 | api_key, client = values.get("api_key"), values.get("client") |
| #27 | if not api_key and not client and "PINECONE_API_KEY" not in os.environ: |
| #28 | raise ValueError( |
| #29 | "Either 'api_key' or 'client' must be provided, or PINECONE_API_KEY environment variable must be set." |
| #30 | ) |
| #31 | return values |
| #32 | |
| #33 | @model_validator(mode="before") |
| #34 | @classmethod |
| #35 | def check_pod_or_serverless(cls, values: Dict[str, Any]) -> Dict[str, Any]: |
| #36 | pod_config, serverless_config = values.get("pod_config"), values.get("serverless_config") |
| #37 | if pod_config and serverless_config: |
| #38 | raise ValueError( |
| #39 | "Both 'pod_config' and 'serverless_config' cannot be specified. Choose one deployment option." |
| #40 | ) |
| #41 | return values |
| #42 | |
| #43 | @model_validator(mode="before") |
| #44 | @classmethod |
| #45 | def validate_extra_fields(cls, values: Dict[str, Any]) -> Dict[str, Any]: |
| #46 | allowed_fields = set(cls.model_fields.keys()) |
| #47 | input_fields = set(values.keys()) |
| #48 | extra_fields = input_fields - allowed_fields |
| #49 | if extra_fields: |
| #50 | raise ValueError( |
| #51 | f"Extra fields not allowed: {', '.join(extra_fields)}. Please input only the following fields: {', '.join(allowed_fields)}" |
| #52 | ) |
| #53 | return values |
| #54 | |
| #55 | model_config = ConfigDict(arbitrary_types_allowed=True) |
| #56 |