|
| 1 | +from typing import Annotated, TypedDict, Unpack |
| 2 | + |
| 3 | +import click |
| 4 | +from pydantic import SecretStr |
| 5 | + |
| 6 | +from ....cli.cli import ( |
| 7 | + CommonTypedDict, |
| 8 | + cli, |
| 9 | + click_parameter_decorators_from_typed_dict, |
| 10 | + run, |
| 11 | +) |
| 12 | +from .. import DB |
| 13 | +from ..api import EmptyDBCaseConfig |
| 14 | + |
| 15 | + |
| 16 | +class PineconeTypedDict(TypedDict): |
| 17 | + api_key: Annotated[ |
| 18 | + str, |
| 19 | + click.option("--api-key", type=str, help="Pinecone API key", required=True), |
| 20 | + ] |
| 21 | + index_name: Annotated[ |
| 22 | + str, |
| 23 | + click.option("--index-name", type=str, help="Pinecone index name", required=True), |
| 24 | + ] |
| 25 | + version: Annotated[ |
| 26 | + str, |
| 27 | + click.option("--version", type=str, help="Database version", default="", show_default=True), |
| 28 | + ] |
| 29 | + note: Annotated[ |
| 30 | + str, |
| 31 | + click.option("--note", type=str, help="Additional notes", default="", show_default=True), |
| 32 | + ] |
| 33 | + |
| 34 | + |
| 35 | +class PineconeIndexTypedDict(CommonTypedDict, PineconeTypedDict): ... |
| 36 | + |
| 37 | + |
| 38 | +@cli.command() |
| 39 | +@click_parameter_decorators_from_typed_dict(PineconeIndexTypedDict) |
| 40 | +def Pinecone(**parameters: Unpack[PineconeIndexTypedDict]): |
| 41 | + from .config import PineconeConfig |
| 42 | + |
| 43 | + run( |
| 44 | + db=DB.Pinecone, |
| 45 | + db_config=PineconeConfig( |
| 46 | + db_label=parameters["db_label"], |
| 47 | + version=parameters["version"], |
| 48 | + note=parameters["note"], |
| 49 | + api_key=SecretStr(parameters["api_key"]), |
| 50 | + index_name=parameters["index_name"], |
| 51 | + ), |
| 52 | + db_case_config=EmptyDBCaseConfig(), |
| 53 | + **parameters, |
| 54 | + ) |
0 commit comments