diff --git a/Makefile b/Makefile index 6095376a45..59a7ad29c9 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ down: .PHONY: run-unit-tests run-unit-tests: - poetry run pytest src/backend/tests/unit --cov=src/backend --cov-report=xml + poetry run pytest src/backend/tests/unit/$(file) --cov=src/backend --cov-report=xml .PHONY: run-community-tests run-community-tests: diff --git a/src/backend/chat/custom/utils.py b/src/backend/chat/custom/utils.py index aea5513216..d70a28a4e9 100644 --- a/src/backend/chat/custom/utils.py +++ b/src/backend/chat/custom/utils.py @@ -1,11 +1,9 @@ from typing import Any -from backend.config.deployments import ( - AVAILABLE_MODEL_DEPLOYMENTS, - get_default_deployment, -) +from backend.exceptions import DeploymentNotFoundError from backend.model_deployments.base import BaseDeployment from backend.schemas.context import Context +from backend.services import deployment as deployment_service def get_deployment(name: str, ctx: Context, **kwargs: Any) -> BaseDeployment: @@ -16,22 +14,11 @@ def get_deployment(name: str, ctx: Context, **kwargs: Any) -> BaseDeployment: Returns: BaseDeployment: Deployment implementation instance based on the deployment name. - - Raises: - ValueError: If the deployment is not supported. """ kwargs["ctx"] = ctx - deployment = AVAILABLE_MODEL_DEPLOYMENTS.get(name) - - # Check provided deployment against config const - if deployment is not None: - return deployment.deployment_class(**kwargs, **deployment.kwargs) - - # Fallback to first available deployment - default = get_default_deployment(**kwargs) - if default is not None: - return default + try: + deployment = deployment_service.get_deployment_by_name(name) + except DeploymentNotFoundError: + deployment = deployment_service.get_default_deployment() - raise ValueError( - f"Deployment {name} is not supported, and no available deployments were found." - ) + return deployment(**kwargs) diff --git a/src/backend/cli/main.py b/src/backend/cli/main.py index 40d6eb7e79..0def62b2d0 100755 --- a/src/backend/cli/main.py +++ b/src/backend/cli/main.py @@ -20,9 +20,6 @@ from backend.config.deployments import ( AVAILABLE_MODEL_DEPLOYMENTS as MANAGED_DEPLOYMENTS_SETUP, ) -from community.config.deployments import ( - AVAILABLE_MODEL_DEPLOYMENTS as COMMUNITY_DEPLOYMENTS_SETUP, -) def start(): @@ -50,9 +47,6 @@ def start(): # SET UP ENVIRONMENT FOR DEPLOYMENTS all_deployments = MANAGED_DEPLOYMENTS_SETUP.copy() - if use_community_features: - all_deployments.update(COMMUNITY_DEPLOYMENTS_SETUP) - selected_deployments = select_deployments_prompt(all_deployments, secrets) for deployment in selected_deployments: diff --git a/src/backend/config/default_agent.py b/src/backend/config/default_agent.py index 69ca098ec8..6397cf5bbe 100644 --- a/src/backend/config/default_agent.py +++ b/src/backend/config/default_agent.py @@ -1,11 +1,11 @@ import datetime -from backend.config.deployments import ModelDeploymentName from backend.config.tools import Tool +from backend.model_deployments.cohere_platform import CohereDeployment from backend.schemas.agent import AgentPublic DEFAULT_AGENT_ID = "default" -DEFAULT_DEPLOYMENT = ModelDeploymentName.CoherePlatform +DEFAULT_DEPLOYMENT = CohereDeployment.name() DEFAULT_MODEL = "command-r-plus" def get_default_agent() -> AgentPublic: diff --git a/src/backend/config/deployments.py b/src/backend/config/deployments.py index 32eb8e0e59..188cc56133 100644 --- a/src/backend/config/deployments.py +++ b/src/backend/config/deployments.py @@ -1,140 +1,35 @@ -from enum import StrEnum - from backend.config.settings import Settings -from backend.model_deployments import ( - AzureDeployment, - BedrockDeployment, - CohereDeployment, - SageMakerDeployment, - SingleContainerDeployment, -) -from backend.model_deployments.azure import AZURE_ENV_VARS from backend.model_deployments.base import BaseDeployment -from backend.model_deployments.bedrock import BEDROCK_ENV_VARS -from backend.model_deployments.cohere_platform import COHERE_ENV_VARS -from backend.model_deployments.sagemaker import SAGE_MAKER_ENV_VARS -from backend.model_deployments.single_container import SC_ENV_VARS -from backend.schemas.deployment import Deployment from backend.services.logger.utils import LoggerFactory logger = LoggerFactory().get_logger() -class ModelDeploymentName(StrEnum): - CoherePlatform = "Cohere Platform" - SageMaker = "SageMaker" - Azure = "Azure" - Bedrock = "Bedrock" - SingleContainer = "Single Container" - - -use_community_features = Settings().get('feature_flags.use_community_features') +ALL_MODEL_DEPLOYMENTS = { d.name(): d for d in BaseDeployment.__subclasses__() } -# TODO names in the map below should not be the display names but ids -ALL_MODEL_DEPLOYMENTS = { - ModelDeploymentName.CoherePlatform: Deployment( - id="cohere_platform", - name=ModelDeploymentName.CoherePlatform, - deployment_class=CohereDeployment, - models=CohereDeployment.list_models(), - is_available=CohereDeployment.is_available(), - env_vars=COHERE_ENV_VARS, - ), - ModelDeploymentName.SingleContainer: Deployment( - id="single_container", - name=ModelDeploymentName.SingleContainer, - deployment_class=SingleContainerDeployment, - models=SingleContainerDeployment.list_models(), - is_available=SingleContainerDeployment.is_available(), - env_vars=SC_ENV_VARS, - ), - ModelDeploymentName.SageMaker: Deployment( - id="sagemaker", - name=ModelDeploymentName.SageMaker, - deployment_class=SageMakerDeployment, - models=SageMakerDeployment.list_models(), - is_available=SageMakerDeployment.is_available(), - env_vars=SAGE_MAKER_ENV_VARS, - ), - ModelDeploymentName.Azure: Deployment( - id="azure", - name=ModelDeploymentName.Azure, - deployment_class=AzureDeployment, - models=AzureDeployment.list_models(), - is_available=AzureDeployment.is_available(), - env_vars=AZURE_ENV_VARS, - ), - ModelDeploymentName.Bedrock: Deployment( - id="bedrock", - name=ModelDeploymentName.Bedrock, - deployment_class=BedrockDeployment, - models=BedrockDeployment.list_models(), - is_available=BedrockDeployment.is_available(), - env_vars=BEDROCK_ENV_VARS, - ), -} +def get_installed_deployments() -> list[type[BaseDeployment]]: + installed_deployments = list(ALL_MODEL_DEPLOYMENTS.values()) -def get_available_deployments() -> dict[ModelDeploymentName, Deployment]: - if use_community_features: + if Settings().get("feature_flags.use_community_features"): try: from community.config.deployments import ( AVAILABLE_MODEL_DEPLOYMENTS as COMMUNITY_DEPLOYMENTS_SETUP, ) - - model_deployments = ALL_MODEL_DEPLOYMENTS.copy() - model_deployments.update(COMMUNITY_DEPLOYMENTS_SETUP) - return model_deployments - except ImportError: + installed_deployments.extend(COMMUNITY_DEPLOYMENTS_SETUP.values()) + except ImportError as e: logger.warning( - event="[Deployments] No available community deployments have been configured" + event="[Deployments] No available community deployments have been configured", ex=e ) - deployments = Settings().get('deployments.enabled_deployments') - if deployments is not None and len(deployments) > 0: - return { - key: value - for key, value in ALL_MODEL_DEPLOYMENTS.items() - if value.id in Settings().get('deployments.enabled_deployments') - } - - return ALL_MODEL_DEPLOYMENTS - - -def get_default_deployment(**kwargs) -> BaseDeployment: - # Fallback to the first available deployment - fallback = None - for deployment in AVAILABLE_MODEL_DEPLOYMENTS.values(): - if deployment.is_available: - fallback = deployment.deployment_class(**kwargs) - break - - default = Settings().get('deployments.default_deployment') - if default: - return next( - ( - v.deployment_class(**kwargs) - for k, v in AVAILABLE_MODEL_DEPLOYMENTS.items() - if v.id == default - ), - fallback, - ) - else: - return fallback - - -def find_config_by_deployment_id(deployment_id: str) -> Deployment: - for deployment in AVAILABLE_MODEL_DEPLOYMENTS.values(): - if deployment.id == deployment_id: - return deployment - return None - - -def find_config_by_deployment_name(deployment_name: str) -> Deployment: - for deployment in AVAILABLE_MODEL_DEPLOYMENTS.values(): - if deployment.name == deployment_name: - return deployment - return None + enabled_deployment_ids = Settings().get("deployments.enabled_deployments") + if enabled_deployment_ids: + return [ + deployment + for deployment in installed_deployments + if deployment.id() in enabled_deployment_ids + ] + return installed_deployments -AVAILABLE_MODEL_DEPLOYMENTS = get_available_deployments() +AVAILABLE_MODEL_DEPLOYMENTS = get_installed_deployments() diff --git a/src/backend/crud/deployment.py b/src/backend/crud/deployment.py index a6a94c7046..d1a8b92c04 100644 --- a/src/backend/crud/deployment.py +++ b/src/backend/crud/deployment.py @@ -4,12 +4,12 @@ from backend.database_models import Deployment from backend.model_deployments.utils import class_name_validator -from backend.schemas.deployment import Deployment as DeploymentSchema -from backend.schemas.deployment import DeploymentCreate, DeploymentUpdate -from backend.services.transaction import validate_transaction -from community.config.deployments import ( - AVAILABLE_MODEL_DEPLOYMENTS as COMMUNITY_DEPLOYMENTS, +from backend.schemas.deployment import ( + DeploymentCreate, + DeploymentDefinition, + DeploymentUpdate, ) +from backend.services.transaction import validate_transaction @validate_transaction @@ -19,7 +19,7 @@ def create_deployment(db: Session, deployment: DeploymentCreate) -> Deployment: Args: db (Session): Database session. - deployment (DeploymentSchema): Deployment data to be created. + deployment (DeploymentDefinition): Deployment data to be created. Returns: Deployment: Created deployment. @@ -132,14 +132,14 @@ def delete_deployment(db: Session, deployment_id: str) -> None: @validate_transaction -def create_deployment_by_config(db: Session, deployment_config: DeploymentSchema) -> Deployment: +def create_deployment_by_config(db: Session, deployment_config: DeploymentDefinition) -> Deployment: """ Create a new deployment by config. Args: db (Session): Database session. deployment (str): Deployment data to be created. - deployment_config (DeploymentSchema): Deployment config. + deployment_config (DeploymentDefinition): Deployment config. Returns: Deployment: Created deployment. @@ -152,7 +152,7 @@ def create_deployment_by_config(db: Session, deployment_config: DeploymentSchema for env_var in deployment_config.env_vars }, deployment_class_name=deployment_config.deployment_class.__name__, - is_community=deployment_config.name in COMMUNITY_DEPLOYMENTS + is_community=deployment_config.is_community, ) db.add(deployment) db.commit() diff --git a/src/backend/crud/model.py b/src/backend/crud/model.py index a891c74ccc..e3a179acac 100644 --- a/src/backend/crud/model.py +++ b/src/backend/crud/model.py @@ -2,7 +2,7 @@ from backend.database_models import Deployment from backend.database_models.model import Model -from backend.schemas.deployment import Deployment as DeploymentSchema +from backend.schemas.deployment import DeploymentDefinition from backend.schemas.model import ModelCreate, ModelUpdate from backend.services.transaction import validate_transaction @@ -127,14 +127,44 @@ def delete_model(db: Session, model_id: str) -> None: db.commit() -def create_model_by_config(db: Session, deployment: Deployment, deployment_config: DeploymentSchema, model: str) -> Model: +def get_models_by_agent_id( + db: Session, agent_id: str, offset: int = 0, limit: int = 100 +) -> list[Model]: + """ + List all models by user id + + Args: + db (Session): Database session. + agent_id (str): User ID + offset (int): Offset to start the list. + limit (int): Limit of models to be listed. + + Returns: + list[Model]: List of models. + """ + + return ( + db.query(Model) + .join( + AgentDeploymentModel, + agent_id == AgentDeploymentModel.agent_id, + ) + .filter(Model.deployment_id == AgentDeploymentModel.deployment_id) + .order_by(Model.name) + .limit(limit) + .offset(offset) + .all() + ) + + +def create_model_by_config(db: Session, deployment: Deployment, deployment_config: DeploymentDefinition, model: str) -> Model: """ Create a new model by config if present Args: db (Session): Database session. deployment (Deployment): Deployment data. - deployment_config (DeploymentSchema): Deployment config data. + deployment_config (DeploymentDefinition): Deployment config data. model (str): Model data. Returns: diff --git a/src/backend/database_models/seeders/deplyments_models_seed.py b/src/backend/database_models/seeders/deplyments_models_seed.py index 0b8cef3685..ce1ba26d90 100644 --- a/src/backend/database_models/seeders/deplyments_models_seed.py +++ b/src/backend/database_models/seeders/deplyments_models_seed.py @@ -6,8 +6,15 @@ from sqlalchemy import text from sqlalchemy.orm import Session -from backend.config.deployments import ALL_MODEL_DEPLOYMENTS, ModelDeploymentName +from backend.config.deployments import ALL_MODEL_DEPLOYMENTS from backend.database_models import Deployment, Model, Organization +from backend.model_deployments import ( + CohereDeployment, + SingleContainerDeployment, + SageMakerDeployment, + AzureDeployment, + BedrockDeployment, +) from community.config.deployments import ( AVAILABLE_MODEL_DEPLOYMENTS as COMMUNITY_DEPLOYMENTS_SETUP, ) @@ -18,7 +25,7 @@ model_deployments.update(COMMUNITY_DEPLOYMENTS_SETUP) MODELS_NAME_MAPPING = { - ModelDeploymentName.CoherePlatform: { + CohereDeployment.name(): { "command": { "cohere_name": "command", "is_default": False, @@ -60,7 +67,7 @@ "is_default": False, }, }, - ModelDeploymentName.SingleContainer: { + SingleContainerDeployment.name(): { "command": { "cohere_name": "command", "is_default": False, @@ -102,19 +109,19 @@ "is_default": False, }, }, - ModelDeploymentName.SageMaker: { + SageMakerDeployment.name(): { "sagemaker-command": { "cohere_name": "command", "is_default": True, }, }, - ModelDeploymentName.Azure: { + AzureDeployment.name(): { "azure-command": { "cohere_name": "command-r", "is_default": True, }, }, - ModelDeploymentName.Bedrock: { + BedrockDeployment.name(): { "cohere.command-r-plus-v1:0": { "cohere_name": "command-r-plus", "is_default": True, @@ -166,12 +173,12 @@ def deployments_models_seed(op): default_deployment_config=json.dumps( { env_var: os.environ.get(env_var, "") - for env_var in model_deployments[deployment].env_vars + for env_var in model_deployments[deployment].env_vars() } ), deployment_class_name=model_deployments[ deployment - ].deployment_class.__name__, + ].__name__, is_community=deployment in COMMUNITY_DEPLOYMENTS_SETUP, ) op.execute(sql_command) diff --git a/src/backend/exceptions.py b/src/backend/exceptions.py new file mode 100644 index 0000000000..d8402a221d --- /dev/null +++ b/src/backend/exceptions.py @@ -0,0 +1,13 @@ +class ToolkitException(Exception): + """ + Base class for all toolkit exceptions. + """ + +class DeploymentNotFoundError(ToolkitException): + def __init__(self, deployment_id: str): + super(DeploymentNotFoundError, self).__init__(f"Deployment {deployment_id} not found") + self.deployment_id = deployment_id + +class NoAvailableDeploymentsError(ToolkitException): + def __init__(self): + super(NoAvailableDeploymentsError, self).__init__("No deployments have been configured. Have the appropriate config values been added to configuration.yaml or secrets.yaml?") diff --git a/src/backend/main.py b/src/backend/main.py index 2cd85a7d58..1835f9997d 100644 --- a/src/backend/main.py +++ b/src/backend/main.py @@ -16,6 +16,7 @@ ) from backend.config.routers import ROUTER_DEPENDENCIES from backend.config.settings import Settings +from backend.exceptions import DeploymentNotFoundError from backend.routers.agent import router as agent_router from backend.routers.auth import router as auth_router from backend.routers.chat import router as chat_router @@ -117,6 +118,21 @@ async def validation_exception_handler(request: Request, exc: Exception): }, ) + +@app.exception_handler(DeploymentNotFoundError) +async def deployment_not_found_handler(request: Request, exc: DeploymentNotFoundError): + ctx = get_context(request) + logger = ctx.get_logger() + logger.error( + event="Deployment not found", + deployment_id=exc.deployment_id, + ) + return JSONResponse( + status_code=404, + content={"detail": str(exc)}, + ) + + @app.on_event("startup") async def startup_event(): """ diff --git a/src/backend/model_deployments/azure.py b/src/backend/model_deployments/azure.py index e7849f0371..bea01b7743 100644 --- a/src/backend/model_deployments/azure.py +++ b/src/backend/model_deployments/azure.py @@ -13,7 +13,6 @@ # Example URL: "https://..inference.ai.azure.com/v1" # Note: It must have /v1 and it should not have /chat AZURE_CHAT_URL_ENV_VAR = "AZURE_CHAT_ENDPOINT_URL" -AZURE_ENV_VARS = [AZURE_API_KEY_ENV_VAR, AZURE_CHAT_URL_ENV_VAR] class AzureDeployment(BaseDeployment): @@ -44,8 +43,16 @@ def __init__(self, **kwargs: Any): base_url=self.chat_endpoint_url, api_key=self.api_key ) - @property - def rerank_enabled(self) -> bool: + @classmethod + def name(cls) -> str: + return "Azure" + + @classmethod + def env_vars(cls) -> List[str]: + return [AZURE_API_KEY_ENV_VAR, AZURE_CHAT_URL_ENV_VAR] + + @classmethod + def rerank_enabled(cls) -> bool: return False @classmethod diff --git a/src/backend/model_deployments/base.py b/src/backend/model_deployments/base.py index 6436421e5a..88eaa1382d 100644 --- a/src/backend/model_deployments/base.py +++ b/src/backend/model_deployments/base.py @@ -1,11 +1,13 @@ -from abc import abstractmethod +from abc import ABC, abstractmethod from typing import Any, AsyncGenerator, Dict, List +from backend.config.settings import Settings from backend.schemas.cohere_chat import CohereChatRequest from backend.schemas.context import Context +from backend.schemas.deployment import DeploymentDefinition -class BaseDeployment: +class BaseDeployment(ABC): """Base for all model deployment options. rerank_enabled: bool: Whether the deployment supports reranking. @@ -14,16 +16,50 @@ class BaseDeployment: list_models: List[str]: List all models. is_available: bool: Check if the deployment is available. """ + @classmethod + def id(cls) -> str: + return cls.name().replace(" ", "_").lower() - @property + @classmethod @abstractmethod - def rerank_enabled(self) -> bool: ... + def name(cls) -> str: ... - @staticmethod - def list_models() -> List[str]: ... + @classmethod + @abstractmethod + def env_vars(cls) -> List[str]: ... + + @classmethod + @abstractmethod + def rerank_enabled(cls) -> bool: ... + + @classmethod + @abstractmethod + def list_models(cls) -> List[str]: ... + + @classmethod + @abstractmethod + def is_available(cls) -> bool: ... + + @classmethod + def is_community(cls) -> bool: + return False + + @classmethod + def config(cls) -> Dict[str, Any]: + config = Settings().get(f"deployments.{cls.id()}") + return config.dict() if config else {} - @staticmethod - def is_available() -> bool: ... + @classmethod + def to_deployment_definition(cls) -> DeploymentDefinition: + return DeploymentDefinition( + id=cls.id(), + name=cls.name(), + description=None, + models=cls.list_models(), + is_community=cls.is_community(), + is_available=cls.is_available(), + config=cls.config(), + ) @abstractmethod async def invoke_chat( diff --git a/src/backend/model_deployments/bedrock.py b/src/backend/model_deployments/bedrock.py index 094ed243a3..7241c79dd1 100644 --- a/src/backend/model_deployments/bedrock.py +++ b/src/backend/model_deployments/bedrock.py @@ -13,12 +13,6 @@ BEDROCK_SECRET_KEY_ENV_VAR = "BEDROCK_SECRET_KEY" BEDROCK_SESSION_TOKEN_ENV_VAR = "BEDROCK_SESSION_TOKEN" BEDROCK_REGION_NAME_ENV_VAR = "BEDROCK_REGION_NAME" -BEDROCK_ENV_VARS = [ - BEDROCK_ACCESS_KEY_ENV_VAR, - BEDROCK_SECRET_KEY_ENV_VAR, - BEDROCK_SESSION_TOKEN_ENV_VAR, - BEDROCK_REGION_NAME_ENV_VAR, -] class BedrockDeployment(BaseDeployment): @@ -48,8 +42,21 @@ def __init__(self, **kwargs: Any): ), ) - @property - def rerank_enabled(self) -> bool: + @classmethod + def name(cls) -> str: + return "Bedrock" + + @classmethod + def env_vars(cls) -> List[str]: + return [ + BEDROCK_ACCESS_KEY_ENV_VAR, + BEDROCK_SECRET_KEY_ENV_VAR, + BEDROCK_SESSION_TOKEN_ENV_VAR, + BEDROCK_REGION_NAME_ENV_VAR, + ] + + @classmethod + def rerank_enabled(cls) -> bool: return False @classmethod diff --git a/src/backend/model_deployments/cohere_platform.py b/src/backend/model_deployments/cohere_platform.py index f8da71693d..4c771f66e6 100644 --- a/src/backend/model_deployments/cohere_platform.py +++ b/src/backend/model_deployments/cohere_platform.py @@ -12,7 +12,6 @@ from backend.services.logger.utils import LoggerFactory COHERE_API_KEY_ENV_VAR = "COHERE_API_KEY" -COHERE_ENV_VARS = [COHERE_API_KEY_ENV_VAR] DEFAULT_RERANK_MODEL = "rerank-english-v2.0" @@ -29,8 +28,16 @@ def __init__(self, **kwargs: Any): ) self.client = cohere.Client(api_key, client_name=self.client_name) - @property - def rerank_enabled(self) -> bool: + @classmethod + def name(cls) -> str: + return "Cohere Platform" + + @classmethod + def env_vars(cls) -> List[str]: + return [COHERE_API_KEY_ENV_VAR] + + @classmethod + def rerank_enabled(cls) -> bool: return True @classmethod diff --git a/src/backend/model_deployments/sagemaker.py b/src/backend/model_deployments/sagemaker.py index 56d2a96555..b8de329230 100644 --- a/src/backend/model_deployments/sagemaker.py +++ b/src/backend/model_deployments/sagemaker.py @@ -15,13 +15,6 @@ SAGE_MAKER_SESSION_TOKEN_ENV_VAR = "SAGE_MAKER_SESSION_TOKEN" SAGE_MAKER_REGION_NAME_ENV_VAR = "SAGE_MAKER_REGION_NAME" SAGE_MAKER_ENDPOINT_NAME_ENV_VAR = "SAGE_MAKER_ENDPOINT_NAME" -SAGE_MAKER_ENV_VARS = [ - SAGE_MAKER_ACCESS_KEY_ENV_VAR, - SAGE_MAKER_SECRET_KEY_ENV_VAR, - SAGE_MAKER_SESSION_TOKEN_ENV_VAR, - SAGE_MAKER_REGION_NAME_ENV_VAR, - SAGE_MAKER_ENDPOINT_NAME_ENV_VAR, -] class SageMakerDeployment(BaseDeployment): @@ -72,8 +65,22 @@ def __init__(self, **kwargs: Any): "ContentType": "application/json", } - @property - def rerank_enabled(self) -> bool: + @classmethod + def name(cls) -> str: + return "SageMaker" + + @classmethod + def env_vars(cls) -> List[str]: + return [ + SAGE_MAKER_ACCESS_KEY_ENV_VAR, + SAGE_MAKER_SECRET_KEY_ENV_VAR, + SAGE_MAKER_SESSION_TOKEN_ENV_VAR, + SAGE_MAKER_REGION_NAME_ENV_VAR, + SAGE_MAKER_ENDPOINT_NAME_ENV_VAR, + ] + + @classmethod + def rerank_enabled(cls) -> bool: return False @classmethod diff --git a/src/backend/model_deployments/single_container.py b/src/backend/model_deployments/single_container.py index 9c727a2186..a9d69ab6a9 100644 --- a/src/backend/model_deployments/single_container.py +++ b/src/backend/model_deployments/single_container.py @@ -12,16 +12,15 @@ DEFAULT_RERANK_MODEL = "rerank-english-v2.0" SC_URL_ENV_VAR = "SINGLE_CONTAINER_URL" SC_MODEL_ENV_VAR = "SINGLE_CONTAINER_MODEL" -SC_ENV_VARS = [SC_URL_ENV_VAR, SC_MODEL_ENV_VAR] class SingleContainerDeployment(BaseDeployment): """Single Container Deployment.""" client_name = "cohere-toolkit" - config = Settings().get('deployments.single_container') - default_url = config.url - default_model = config.model + sc_config = Settings().get('deployments.single_container') + default_url = sc_config.url + default_model = sc_config.model def __init__(self, **kwargs: Any): self.url = get_model_config_var( @@ -34,8 +33,16 @@ def __init__(self, **kwargs: Any): base_url=self.url, client_name=self.client_name, api_key="none" ) - @property - def rerank_enabled(self) -> bool: + @classmethod + def name(cls) -> str: + return "Single Container" + + @classmethod + def env_vars(cls) -> List[str]: + return [SC_URL_ENV_VAR, SC_MODEL_ENV_VAR] + + @classmethod + def rerank_enabled(cls) -> bool: return SingleContainerDeployment.default_model.startswith("rerank") @classmethod diff --git a/src/backend/routers/agent.py b/src/backend/routers/agent.py index 0c63f3dc16..8674391923 100644 --- a/src/backend/routers/agent.py +++ b/src/backend/routers/agent.py @@ -35,7 +35,7 @@ UpdateAgentToolMetadataRequest, ) from backend.schemas.context import Context -from backend.schemas.deployment import Deployment as DeploymentSchema +from backend.schemas.deployment import DeploymentDefinition from backend.schemas.file import ( DeleteAgentFileResponse, FileMetadata, @@ -211,10 +211,10 @@ async def get_agent_by_id( return agent -@router.get("/{agent_id}/deployments", response_model=list[DeploymentSchema]) -async def get_agent_deployment( - agent_id: str, session: DBSessionDep, ctx: Context = Depends(get_context) -) -> DeploymentSchema: +@router.get("/{agent_id}/deployments", response_model=list[DeploymentDefinition]) +async def get_agent_deployments( + agent_id: str, session: DBSessionDep, ctx: Context = Depends(get_context) +) -> list[DeploymentDefinition]: """ Args: agent_id (str): Agent ID. @@ -233,7 +233,10 @@ async def get_agent_deployment( agent_schema = Agent.model_validate(agent) ctx.with_agent(agent_schema) - return DeploymentSchema.custom_transform(agent.deployment) + return [ + DeploymentDefinition.from_db_deployment(deployment) + for deployment in agent.deployments + ] @router.put( diff --git a/src/backend/routers/deployment.py b/src/backend/routers/deployment.py index 1aab86b3c8..faeea3219c 100644 --- a/src/backend/routers/deployment.py +++ b/src/backend/routers/deployment.py @@ -1,19 +1,19 @@ -from fastapi import APIRouter, Depends, HTTPException, Response +from fastapi import APIRouter, Depends, HTTPException -from backend.config.deployments import AVAILABLE_MODEL_DEPLOYMENTS from backend.config.routers import RouterName from backend.crud import deployment as deployment_crud from backend.database_models.database import DBSessionDep +from backend.exceptions import DeploymentNotFoundError from backend.schemas.context import Context from backend.schemas.deployment import ( DeleteDeployment, DeploymentCreate, + DeploymentDefinition, DeploymentUpdate, UpdateDeploymentEnv, ) -from backend.schemas.deployment import Deployment as DeploymentSchema +from backend.services import deployment as deployment_service from backend.services.context import get_context -from backend.services.env import update_env_file from backend.services.request_validators import ( validate_create_deployment_request, validate_env_vars, @@ -27,12 +27,12 @@ @router.post( "", - response_model=DeploymentSchema, + response_model=DeploymentDefinition, dependencies=[Depends(validate_create_deployment_request)], ) def create_deployment( deployment: DeploymentCreate, session: DBSessionDep -) -> DeploymentSchema: +) -> DeploymentDefinition: """ Create a new deployment. @@ -41,20 +41,20 @@ def create_deployment( session (DBSessionDep): Database session. Returns: - DeploymentSchema: Created deployment. + DeploymentDefinition: Created deployment. """ try: - return DeploymentSchema.custom_transform( + return DeploymentDefinition.from_db_deployment( deployment_crud.create_deployment(session, deployment) ) except Exception as e: raise HTTPException(status_code=400, detail=str(e)) -@router.put("/{deployment_id}", response_model=DeploymentSchema) +@router.put("/{deployment_id}", response_model=DeploymentDefinition) def update_deployment( deployment_id: str, new_deployment: DeploymentUpdate, session: DBSessionDep -) -> DeploymentSchema: +) -> DeploymentDefinition: """ Update a deployment. @@ -71,31 +71,28 @@ def update_deployment( """ deployment = deployment_crud.get_deployment(session, deployment_id) if not deployment: - raise HTTPException(status_code=404, detail="Deployment not found") + raise DeploymentNotFoundError(deployment_id=deployment_id) - return DeploymentSchema.custom_transform( + return DeploymentDefinition.from_db_deployment( deployment_crud.update_deployment(session, deployment, new_deployment) ) -@router.get("/{deployment_id}", response_model=DeploymentSchema) -def get_deployment(deployment_id: str, session: DBSessionDep) -> DeploymentSchema: +@router.get("/{deployment_id}", response_model=DeploymentDefinition) +def get_deployment(deployment_id: str, session: DBSessionDep) -> DeploymentDefinition: """ Get a deployment by ID. Returns: Deployment: Deployment with the given ID. """ - deployment = deployment_crud.get_deployment(session, deployment_id) - if not deployment: - raise HTTPException(status_code=404, detail="Deployment not found") - return DeploymentSchema.custom_transform(deployment) + return deployment_service.get_deployment_definition(session, deployment_id) -@router.get("", response_model=list[DeploymentSchema]) +@router.get("", response_model=list[DeploymentDefinition]) def list_deployments( session: DBSessionDep, all: bool = False, ctx: Context = Depends(get_context) -) -> list[DeploymentSchema]: +) -> list[DeploymentDefinition]: """ List all available deployments and their models. @@ -108,28 +105,11 @@ def list_deployments( """ logger = ctx.get_logger() - if all: - available_db_deployments = [ - DeploymentSchema.custom_transform(_) - for _ in deployment_crud.get_deployments(session) - ] - - else: - available_db_deployments = [ - DeploymentSchema.custom_transform(_) - for _ in deployment_crud.get_available_deployments(session) - ] - + installed_deployments = deployment_service.get_deployment_definitions(session) available_deployments = [ - deployment - for _, deployment in AVAILABLE_MODEL_DEPLOYMENTS.items() - if all or deployment.is_available + deployment for deployment in installed_deployments if deployment.is_available or all ] - # If no config deployments found, return DB deployments - if not available_deployments: - available_deployments = available_db_deployments - # No available deployments if not available_deployments: logger.warning( event="[Deployment] No deployments available to list.", @@ -167,21 +147,20 @@ async def delete_deployment( deployment = deployment_crud.get_deployment(session, deployment_id) if not deployment: - raise HTTPException( - status_code=404, detail=f"Deployment with ID: {deployment_id} not found." - ) + raise DeploymentNotFoundError(deployment_id=deployment_id) deployment_crud.delete_deployment(session, deployment_id) return DeleteDeployment() -@router.post("/{name}/set_env_vars", response_class=Response) -async def set_env_vars( - name: str, +@router.post("/{deployment_id}/update_config") +async def update_config( + deployment_id: str, + session: DBSessionDep, env_vars: UpdateDeploymentEnv, - valid_env_vars=Depends(validate_env_vars), - ctx: Context = Depends(get_context), + valid_env_vars = Depends(validate_env_vars), + # ctx: Context = Depends(get_context), ): """ Set environment variables for the deployment. @@ -194,4 +173,4 @@ async def set_env_vars( Returns: str: Empty string. """ - update_env_file(env_vars.env_vars) + return deployment_service.update_config(session, deployment_id, valid_env_vars) diff --git a/src/backend/routers/utils.py b/src/backend/routers/utils.py index dada42e225..fa4ce54d89 100644 --- a/src/backend/routers/utils.py +++ b/src/backend/routers/utils.py @@ -1,5 +1,5 @@ -from backend.config.deployments import ModelDeploymentName from backend.database_models.database import DBSessionDep +from backend.model_deployments.cohere_platform import CohereDeployment from backend.schemas.agent import Agent @@ -27,7 +27,7 @@ def get_deployment_model_from_agent(agent: Agent, session: DBSessionDep): def get_default_deployment_model(session: DBSessionDep): from backend.crud import deployment as deployment_crud - deployment_db = deployment_crud.get_deployment_by_name(session, ModelDeploymentName.CoherePlatform) + deployment_db = deployment_crud.get_deployment_by_name(session, CohereDeployment.name()) model_db = None if deployment_db: model_db = next( diff --git a/src/backend/schemas/deployment.py b/src/backend/schemas/deployment.py index f4e0909454..3e934d9db6 100644 --- a/src/backend/schemas/deployment.py +++ b/src/backend/schemas/deployment.py @@ -1,8 +1,7 @@ -from typing import Any, Dict, List, Optional, Type +from typing import Dict, List, Optional from pydantic import BaseModel, Field -# from backend.model_deployments.base import BaseDeployment from backend.schemas.model import ModelSimple @@ -22,49 +21,38 @@ class DeploymentWithModels(BaseModel): id: Optional[str] = None name: str description: Optional[str] = None + deployment_class_name: Optional[str] = Field(exclude=True, default="") + env_vars: Optional[List[str]] is_available: bool = False is_community: Optional[bool] = False - env_vars: Optional[List[str]] - deployment_class_name: Optional[str] = Field(exclude=True, default="") models: list[ModelSimple] class Config: from_attributes = True -class Deployment(BaseModel): - id: Optional[str] = None +class DeploymentDefinition(BaseModel): + id: str name: str - models: list[str] - is_available: bool = False - deployment_class: Optional[Type[Any]] = Field(exclude=True, default=None) - env_vars: Optional[List[str]] description: Optional[str] = None - deployment_class_name: Optional[str] = Field(exclude=True, default="") - is_community: Optional[bool] = False - default_deployment_config: Optional[Dict[str, str]] = Field( - default_factory=dict, exclude=True - ) - kwargs: Optional[dict] = Field(exclude=True, default={}) + config: Dict[str, str] = {} + is_available: bool = False + is_community: bool = False + models: list[str] class Config: from_attributes = True @classmethod - def custom_transform(cls, obj): + def from_db_deployment(cls, obj): data = { "id": obj.id, "name": obj.name, - "description": obj.description, - "deployment_class": obj.deployment_class if obj.deployment_class else None, - "deployment_class_name": ( - obj.deployment_class_name if obj.deployment_class_name else None - ), + "description": obj.description if obj.description else None, "models": [model.name for model in obj.models], "is_community": obj.is_community, "is_available": obj.is_available, - "env_vars": obj.env_vars, - "default_deployment_config": obj.default_deployment_config, + "config": obj.default_deployment_config, } return cls(**data) diff --git a/src/backend/services/deployment.py b/src/backend/services/deployment.py new file mode 100644 index 0000000000..f1745a2fc9 --- /dev/null +++ b/src/backend/services/deployment.py @@ -0,0 +1,104 @@ +"""Functions for handling operations with deployments. + +This module contains functions for handling backend operations with deployments. A Deployment +represents the information required to interact with an LLM. New deployments are defined +by creating a class that inherits from BaseDeployment and implementing the required methods in +the model_deployments directory. + +Deployments can be configured in two different ways: by providing appropriate config values +through the config (which itself should be set in a configuration.yaml file, or through setting +environment variables), or by dynamically defining a deployment in the database through the +deployment_crud module. This service attempts to abstract the differences between these two +styles so that higher layers don't need to know about these differences. + +We assume that for each kind of deployment, it will be configured either through the config or +through the database, but not both. If a deployment is configured in the database, it is assumed +to the be the correct definition. +""" + +from backend.config.deployments import AVAILABLE_MODEL_DEPLOYMENTS +from backend.config.settings import Settings +from backend.crud import deployment as deployment_crud +from backend.database_models.database import DBSessionDep +from backend.exceptions import DeploymentNotFoundError, NoAvailableDeploymentsError +from backend.model_deployments.base import BaseDeployment +from backend.schemas.deployment import DeploymentDefinition, DeploymentUpdate +from backend.services.env import update_env_file +from backend.services.logger.utils import LoggerFactory + +logger = LoggerFactory().get_logger() + + +def get_default_deployment() -> type[BaseDeployment]: + try: + fallback = next(d for d in AVAILABLE_MODEL_DEPLOYMENTS if d.is_available) + except StopIteration: + raise NoAvailableDeploymentsError() + + default_deployment = Settings().get("deployments.default_deployment") + if default_deployment: + return next( + ( + d + for d in AVAILABLE_MODEL_DEPLOYMENTS + if d.id() == default_deployment + ), + fallback, + ) + + return fallback + +def get_deployment(session: DBSessionDep, deployment_id: str) -> type[BaseDeployment]: + definition = get_deployment_definition(session, deployment_id) + return get_deployment_by_name(definition.name) + +def get_deployment_by_name(deployment_name: str) -> type[BaseDeployment]: + try: + return next(d for d in AVAILABLE_MODEL_DEPLOYMENTS if d.name() == deployment_name) + except StopIteration: + raise DeploymentNotFoundError(deployment_id=deployment_name) + +def get_deployment_definition(session: DBSessionDep, deployment_id: str) -> DeploymentDefinition: + db_deployment = deployment_crud.get_deployment(session, deployment_id) + if db_deployment: + return DeploymentDefinition.from_db_deployment(db_deployment) + + try: + deployment = next(d for d in AVAILABLE_MODEL_DEPLOYMENTS if d.id() == deployment_id) + except StopIteration: + raise DeploymentNotFoundError(deployment_id=deployment_id) + + return deployment.to_deployment_definition() + +def get_deployment_definition_by_name(session: DBSessionDep, deployment_name: str) -> DeploymentDefinition: + definitions = get_deployment_definitions(session) + try: + return next(definition for definition in definitions if definition.name == deployment_name) + except StopIteration: + raise DeploymentNotFoundError(deployment_id=deployment_name) + +def get_deployment_definitions(session: DBSessionDep) -> list[DeploymentDefinition]: + db_deployments = { + db_deployment.name: DeploymentDefinition.from_db_deployment(db_deployment) + for db_deployment in deployment_crud.get_deployments(session) + } + + installed_deployments = [ + deployment.to_deployment_definition() + for deployment in AVAILABLE_MODEL_DEPLOYMENTS + if deployment.name() not in db_deployments + ] + + return [*db_deployments.values(), *installed_deployments] + +def update_config(session: DBSessionDep, deployment_id: str, env_vars: dict[str, str]) -> DeploymentDefinition: + db_deployment = deployment_crud.get_deployment(session, deployment_id) + if db_deployment: + update = DeploymentUpdate(default_deployment_config=env_vars) + updated_db_deployment = deployment_crud.update_deployment(session, db_deployment, update) + updated_deployment = DeploymentDefinition.from_db_deployment(updated_db_deployment) + else: + update_env_file(env_vars) + updated_deployment = get_deployment_definition(session, deployment_id) + + return updated_deployment diff --git a/src/backend/services/env.py b/src/backend/services/env.py index cb62b86a5e..2e7d61c16a 100644 --- a/src/backend/services/env.py +++ b/src/backend/services/env.py @@ -9,6 +9,6 @@ def update_env_file(env_vars: dict[str, str]): open(dotenv_path, "a").close() for key in env_vars: - set_key(dotenv_path, key, env_vars[key]) + set_key(dotenv_path, key, str(env_vars[key])) load_dotenv(dotenv_path) diff --git a/src/backend/services/request_validators.py b/src/backend/services/request_validators.py index 21d6012628..61f0978ceb 100644 --- a/src/backend/services/request_validators.py +++ b/src/backend/services/request_validators.py @@ -3,11 +3,7 @@ from fastapi import HTTPException, Request import backend.crud.user as user_crud -from backend.config.deployments import ( - AVAILABLE_MODEL_DEPLOYMENTS, - find_config_by_deployment_id, - find_config_by_deployment_name, -) +from backend.config.deployments import AVAILABLE_MODEL_DEPLOYMENTS from backend.config.tools import get_available_tools from backend.crud import agent as agent_crud from backend.crud import conversation as conversation_crud @@ -16,6 +12,7 @@ from backend.crud import organization as organization_crud from backend.database_models.database import DBSessionDep from backend.model_deployments.utils import class_name_validator +from backend.services import deployment as deployment_service from backend.services.agent import validate_agent_exists from backend.services.auth.utils import get_header_user_id from backend.services.logger.utils import LoggerFactory @@ -36,47 +33,43 @@ def validate_deployment_model(deployment: str, model: str, session: DBSessionDep HTTPException: If the deployment and model are not compatible """ - deployment_db = deployment_crud.get_deployment_by_name(session, deployment) - if not deployment_db: - deployment_db = deployment_crud.get_deployment(session, deployment) - - # Check deployment config settings availability - deployment_config = find_config_by_deployment_id(deployment) - if not deployment_config: - deployment_config = find_config_by_deployment_name(deployment) - if not deployment_config: + found = deployment_service.get_deployment_definition_by_name(session, deployment) + if not found: + found = deployment_service.get_deployment_definition(session, deployment) + if not found: raise HTTPException( status_code=400, detail=f"Deployment {deployment} not found or is not available in the Database.", ) - if not deployment_db: - deployment_db = deployment_crud.create_deployment_by_config(session, deployment_config) - if not deployment_db: - raise HTTPException( - status_code=400, - detail=f"Deployment {deployment} not found or is not available in the Database.", - ) # Validate model + # deployment_model = next( + # ( + # model_db + # for model_db in found.models + # if model_db.name == model or model_db.id == model + # ), + # None, + # ) deployment_model = next( ( model_db - for model_db in deployment_db.models - if model_db.name == model or model_db.id == model + for model_db in found.models + if model_db == model ), None, ) if not deployment_model: deployment_model = model_crud.create_model_by_config( - session, deployment_db, deployment_config, model + session, found, deployment_config, model ) if not deployment_model: raise HTTPException( - status_code=404, + status_code=400, detail=f"Model {model} not found for deployment {deployment}.", ) - return deployment_db, deployment_model + return found, deployment_model def validate_deployment_config(deployment_config, deployment_db): @@ -226,7 +219,7 @@ async def validate_chat_request(session: DBSessionDep, request: Request): ) -async def validate_env_vars(request: Request): +async def validate_env_vars(session: DBSessionDep, request: Request): """ Validate that the request has valid env vars. @@ -241,16 +234,11 @@ async def validate_env_vars(request: Request): env_vars = body.get("env_vars") invalid_keys = [] - name = unquote_plus(request.path_params.get("name")) - - if not (deployment := AVAILABLE_MODEL_DEPLOYMENTS.get(name)): - raise HTTPException( - status_code=404, - detail="Deployment not found", - ) + deployment_id = unquote_plus(request.path_params.get("deployment_id")) + deployment = deployment_service.get_deployment(session, deployment_id) for key in env_vars: - if key not in deployment.env_vars: + if key not in deployment.env_vars(): invalid_keys.append(key) if invalid_keys: @@ -262,6 +250,8 @@ async def validate_env_vars(request: Request): ), ) + return env_vars + async def validate_create_agent_request(session: DBSessionDep, request: Request): """ diff --git a/src/backend/tests/integration/conftest.py b/src/backend/tests/integration/conftest.py index 5932ab18e4..646e7487f1 100644 --- a/src/backend/tests/integration/conftest.py +++ b/src/backend/tests/integration/conftest.py @@ -9,13 +9,13 @@ from sqlalchemy import create_engine from sqlalchemy.orm import Session -from backend.config.deployments import AVAILABLE_MODEL_DEPLOYMENTS, ModelDeploymentName +from backend.config.deployments import ALL_MODEL_DEPLOYMENTS from backend.database_models import get_session from backend.database_models.agent import Agent from backend.database_models.deployment import Deployment from backend.database_models.model import Model from backend.main import app, create_app -from backend.schemas.deployment import Deployment as DeploymentSchema +# from backend.schemas.deployment import DeploymentDefinition from backend.schemas.organization import Organization from backend.schemas.user import User from backend.tests.unit.factories import get_factory @@ -184,43 +184,13 @@ def mock_available_model_deployments(request): MockSageMakerDeployment, ) - is_available_values = getattr(request, "param", {}) + # is_available_values = getattr(request, "param", {}) MOCKED_DEPLOYMENTS = { - ModelDeploymentName.CoherePlatform: DeploymentSchema( - id="cohere_platform", - name=ModelDeploymentName.CoherePlatform, - models=MockCohereDeployment.list_models(), - is_available=is_available_values.get( - ModelDeploymentName.CoherePlatform, True - ), - deployment_class=MockCohereDeployment, - env_vars=["COHERE_VAR_1", "COHERE_VAR_2"], - ), - ModelDeploymentName.SageMaker: DeploymentSchema( - id="sagemaker", - name=ModelDeploymentName.SageMaker, - models=MockSageMakerDeployment.list_models(), - is_available=is_available_values.get(ModelDeploymentName.SageMaker, True), - deployment_class=MockSageMakerDeployment, - env_vars=["SAGEMAKER_VAR_1", "SAGEMAKER_VAR_2"], - ), - ModelDeploymentName.Azure: DeploymentSchema( - id="azure", - name=ModelDeploymentName.Azure, - models=MockAzureDeployment.list_models(), - is_available=is_available_values.get(ModelDeploymentName.Azure, True), - deployment_class=MockAzureDeployment, - env_vars=["SAGEMAKER_VAR_1", "SAGEMAKER_VAR_2"], - ), - ModelDeploymentName.Bedrock: DeploymentSchema( - id="bedrock", - name=ModelDeploymentName.Bedrock, - models=MockBedrockDeployment.list_models(), - is_available=is_available_values.get(ModelDeploymentName.Bedrock, True), - deployment_class=MockBedrockDeployment, - env_vars=["BEDROCK_VAR_1", "BEDROCK_VAR_2"], - ), + MockCohereDeployment.name(): MockCohereDeployment, + MockAzureDeployment.name(): MockAzureDeployment, + MockSageMakerDeployment.name(): MockSageMakerDeployment, + MockBedrockDeployment.name(): MockBedrockDeployment, } - with patch.dict(AVAILABLE_MODEL_DEPLOYMENTS, MOCKED_DEPLOYMENTS) as mock: + with patch.dict(ALL_MODEL_DEPLOYMENTS, MOCKED_DEPLOYMENTS) as mock: yield mock diff --git a/src/backend/tests/integration/routers/test_agent.py b/src/backend/tests/integration/routers/test_agent.py index 9ba0be0649..c771ee58ba 100644 --- a/src/backend/tests/integration/routers/test_agent.py +++ b/src/backend/tests/integration/routers/test_agent.py @@ -2,10 +2,15 @@ from fastapi.testclient import TestClient from sqlalchemy.orm import Session +<<<<<<< HEAD +from backend.config.tools import ToolName +======= from backend.config.deployments import ModelDeploymentName from backend.config.tools import Tool +>>>>>>> main from backend.database_models.agent import Agent from backend.database_models.agent_tool_metadata import AgentToolMetadata +from backend.model_deployments.cohere_platform import CohereDeployment from backend.tests.unit.factories import get_factory @@ -17,8 +22,13 @@ def test_create_agent(session_client: TestClient, session: Session, user) -> Non "preamble": "test preamble", "temperature": 0.5, "model": "command-r-plus", +<<<<<<< HEAD + "deployment": CohereDeployment.name(), + "tools": [ToolName.Calculator, ToolName.Search_File, ToolName.Read_File], +======= "deployment": ModelDeploymentName.CoherePlatform, "tools": [Tool.Calculator.value.ID, Tool.Search_File.value.ID, Tool.Read_File.value.ID], +>>>>>>> main } response = session_client.post( @@ -58,8 +68,13 @@ def test_create_agent_with_tool_metadata( "preamble": "test preamble", "temperature": 0.5, "model": "command-r-plus", +<<<<<<< HEAD + "deployment": CohereDeployment.name(), + "tools": [ToolName.Google_Drive, ToolName.Search_File], +======= "deployment": ModelDeploymentName.CoherePlatform, "tools": [Tool.Google_Drive.value.ID, Tool.Search_File.value.ID], +>>>>>>> main "tools_metadata": [ { "tool_name": Tool.Google_Drive.value.ID, @@ -112,7 +127,7 @@ def test_create_agent_missing_non_required_fields( request_json = { "name": "test agent", "model": "command-r-plus", - "deployment": ModelDeploymentName.CoherePlatform, + "deployment": CohereDeployment.name(), } response = session_client.post( @@ -155,7 +170,7 @@ def test_update_agent(session_client: TestClient, session: Session, user) -> Non "preamble": "updated preamble", "temperature": 0.7, "model": "command-r", - "deployment": ModelDeploymentName.CoherePlatform, + "deployment": CohereDeployment.name(), } response = session_client.put( @@ -172,4 +187,4 @@ def test_update_agent(session_client: TestClient, session: Session, user) -> Non assert updated_agent["preamble"] == "updated preamble" assert updated_agent["temperature"] == 0.7 assert updated_agent["model"] == "command-r" - assert updated_agent["deployment"] == ModelDeploymentName.CoherePlatform + assert updated_agent["deployment"] == CohereDeployment.name() diff --git a/src/backend/tests/integration/routers/test_conversation.py b/src/backend/tests/integration/routers/test_conversation.py index 7d48fc4305..3a471b6eed 100644 --- a/src/backend/tests/integration/routers/test_conversation.py +++ b/src/backend/tests/integration/routers/test_conversation.py @@ -5,8 +5,8 @@ from sqlalchemy.orm import Session from backend.config import Settings -from backend.config.deployments import ModelDeploymentName from backend.database_models import Conversation +from backend.model_deployments.cohere_platform import CohereDeployment from backend.schemas.user import User from backend.tests.unit.factories import get_factory @@ -54,7 +54,7 @@ def test_search_conversations_with_reranking( "/v1/conversations:search", headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, params={"query": "color"}, ) diff --git a/src/backend/tests/unit/configuration.yaml b/src/backend/tests/unit/configuration.yaml index 501c4b531e..7f8d27f109 100644 --- a/src/backend/tests/unit/configuration.yaml +++ b/src/backend/tests/unit/configuration.yaml @@ -2,15 +2,22 @@ deployments: default_deployment: enabled_deployments: sagemaker: - region_name: - endpoint_name: + access_key: "sagemaker_access_key" + secret_key: "sagemaker_secret" + session_token: "sagemaker_session_token" + region_name: "sagemaker-region" + endpoint_name: "http://www.example.com/sagemaker" azure: - endpoint_url: + api_key: "azure_api_key" + endpoint_url: "http://www.example.com/azure" bedrock: - region_name: + region_name: "bedrock-region" + access_key: "bedrock_access_key" + secret_key: "bedrock_secret" + session_token: "bedrock_session_token" single_container: - model: - url: + model: "single_container_model" + url: "http://www.example.com/single_container" database: url: redis: diff --git a/src/backend/tests/unit/conftest.py b/src/backend/tests/unit/conftest.py index 3e0c6c8ca9..4e3a804199 100644 --- a/src/backend/tests/unit/conftest.py +++ b/src/backend/tests/unit/conftest.py @@ -9,11 +9,10 @@ from sqlalchemy import create_engine from sqlalchemy.orm import Session -from backend.config.deployments import AVAILABLE_MODEL_DEPLOYMENTS, ModelDeploymentName +from backend.config.deployments import ALL_MODEL_DEPLOYMENTS from backend.database_models import get_session from backend.database_models.base import CustomFilterQuery from backend.main import app, create_app -from backend.schemas.deployment import Deployment from backend.schemas.organization import Organization from backend.schemas.user import User from backend.tests.unit.factories import get_factory @@ -165,43 +164,15 @@ def mock_available_model_deployments(request): MockSageMakerDeployment, ) - is_available_values = getattr(request, "param", {}) + # is_available_values = getattr(request, "param", {}) MOCKED_DEPLOYMENTS = { - ModelDeploymentName.CoherePlatform: Deployment( - id="cohere_platform", - name=ModelDeploymentName.CoherePlatform, - models=MockCohereDeployment.list_models(), - is_available=is_available_values.get( - ModelDeploymentName.CoherePlatform, True - ), - deployment_class=MockCohereDeployment, - env_vars=["COHERE_VAR_1", "COHERE_VAR_2"], - ), - ModelDeploymentName.SageMaker: Deployment( - id="sagemaker", - name=ModelDeploymentName.SageMaker, - models=MockSageMakerDeployment.list_models(), - is_available=is_available_values.get(ModelDeploymentName.SageMaker, True), - deployment_class=MockSageMakerDeployment, - env_vars=["SAGEMAKER_VAR_1", "SAGEMAKER_VAR_2"], - ), - ModelDeploymentName.Azure: Deployment( - id="azure", - name=ModelDeploymentName.Azure, - models=MockAzureDeployment.list_models(), - is_available=is_available_values.get(ModelDeploymentName.Azure, True), - deployment_class=MockAzureDeployment, - env_vars=["SAGEMAKER_VAR_1", "SAGEMAKER_VAR_2"], - ), - ModelDeploymentName.Bedrock: Deployment( - id="bedrock", - name=ModelDeploymentName.Bedrock, - models=MockBedrockDeployment.list_models(), - is_available=is_available_values.get(ModelDeploymentName.Bedrock, True), - deployment_class=MockBedrockDeployment, - env_vars=["BEDROCK_VAR_1", "BEDROCK_VAR_2"], - ), + MockCohereDeployment.name(): MockCohereDeployment, + MockAzureDeployment.name(): MockAzureDeployment, + MockSageMakerDeployment.name(): MockSageMakerDeployment, + MockBedrockDeployment.name(): MockBedrockDeployment, } - with patch.dict(AVAILABLE_MODEL_DEPLOYMENTS, MOCKED_DEPLOYMENTS) as mock: + # with patch.dict(AVAILABLE_MODEL_DEPLOYMENTS, MOCKED_DEPLOYMENTS) as mock: + with patch("backend.config.deployments.AVAILABLE_MODEL_DEPLOYMENTS", list(MOCKED_DEPLOYMENTS.values())) as mock: + # with patch.dict(ALL_MODEL_DEPLOYMENTS, MOCKED_DEPLOYMENTS) as mock: yield mock diff --git a/src/backend/tests/unit/model_deployments/mock_deployments/mock_azure.py b/src/backend/tests/unit/model_deployments/mock_deployments/mock_azure.py index 7104e5c603..4dde6d8d86 100644 --- a/src/backend/tests/unit/model_deployments/mock_deployments/mock_azure.py +++ b/src/backend/tests/unit/model_deployments/mock_deployments/mock_azure.py @@ -3,18 +3,28 @@ from cohere.types import StreamedChatResponse from backend.chat.enums import StreamEvent -from backend.model_deployments.base import BaseDeployment from backend.schemas.cohere_chat import CohereChatRequest from backend.schemas.context import Context +from backend.tests.unit.model_deployments.mock_deployments.mock_base import ( + MockDeployment, +) -class MockAzureDeployment(BaseDeployment): +class MockAzureDeployment(MockDeployment): """Mocked Azure Deployment.""" DEFAULT_MODELS = ["azure-command"] - @property - def rerank_enabled(self) -> bool: + @classmethod + def name(cls) -> str: + return "Azure" + + @classmethod + def env_vars(cls) -> List[str]: + return ["AZURE_API_KEY", "AZURE_CHAT_ENDPOINT_URL"] + + @classmethod + def rerank_enabled(cls) -> bool: return False @classmethod diff --git a/src/backend/tests/unit/model_deployments/mock_deployments/mock_base.py b/src/backend/tests/unit/model_deployments/mock_deployments/mock_base.py new file mode 100644 index 0000000000..584f36e399 --- /dev/null +++ b/src/backend/tests/unit/model_deployments/mock_deployments/mock_base.py @@ -0,0 +1,4 @@ +from backend.model_deployments.base import BaseDeployment + + +class MockDeployment(BaseDeployment): ... diff --git a/src/backend/tests/unit/model_deployments/mock_deployments/mock_bedrock.py b/src/backend/tests/unit/model_deployments/mock_deployments/mock_bedrock.py index 798d235070..6a7fe4e09c 100644 --- a/src/backend/tests/unit/model_deployments/mock_deployments/mock_bedrock.py +++ b/src/backend/tests/unit/model_deployments/mock_deployments/mock_bedrock.py @@ -3,16 +3,26 @@ from cohere.types import StreamedChatResponse from backend.chat.enums import StreamEvent -from backend.model_deployments.base import BaseDeployment from backend.schemas.cohere_chat import CohereChatRequest from backend.schemas.context import Context +from backend.tests.unit.model_deployments.mock_deployments.mock_base import ( + MockDeployment, +) -class MockBedrockDeployment(BaseDeployment): +class MockBedrockDeployment(MockDeployment): """Bedrock Deployment""" DEFAULT_MODELS = ["cohere.command-r-plus-v1:0"] + @classmethod + def name(cls) -> str: + return "Bedrock" + + @classmethod + def env_vars(cls) -> List[str]: + return [] + @property def rerank_enabled(self) -> bool: return False diff --git a/src/backend/tests/unit/model_deployments/mock_deployments/mock_cohere_platform.py b/src/backend/tests/unit/model_deployments/mock_deployments/mock_cohere_platform.py index 3fe818d497..3839974cdb 100644 --- a/src/backend/tests/unit/model_deployments/mock_deployments/mock_cohere_platform.py +++ b/src/backend/tests/unit/model_deployments/mock_deployments/mock_cohere_platform.py @@ -3,16 +3,26 @@ from cohere.types import StreamedChatResponse from backend.chat.enums import StreamEvent -from backend.model_deployments.base import BaseDeployment from backend.schemas.cohere_chat import CohereChatRequest from backend.schemas.context import Context +from backend.tests.unit.model_deployments.mock_deployments.mock_base import ( + MockDeployment, +) -class MockCohereDeployment(BaseDeployment): +class MockCohereDeployment(MockDeployment): """Mocked Cohere Platform Deployment.""" DEFAULT_MODELS = ["command", "command-r"] + @classmethod + def name(cls) -> str: + return "Cohere Platform" + + @classmethod + def env_vars(cls) -> List[str]: + return ["COHERE_API_KEY"] + @property def rerank_enabled(self) -> bool: return True diff --git a/src/backend/tests/unit/model_deployments/mock_deployments/mock_sagemaker.py b/src/backend/tests/unit/model_deployments/mock_deployments/mock_sagemaker.py index b68e312518..2f64aebd91 100644 --- a/src/backend/tests/unit/model_deployments/mock_deployments/mock_sagemaker.py +++ b/src/backend/tests/unit/model_deployments/mock_deployments/mock_sagemaker.py @@ -3,16 +3,26 @@ from cohere.types import StreamedChatResponse from backend.chat.enums import StreamEvent -from backend.model_deployments.base import BaseDeployment from backend.schemas.cohere_chat import CohereChatRequest from backend.schemas.context import Context +from backend.tests.unit.model_deployments.mock_deployments.mock_base import ( + MockDeployment, +) -class MockSageMakerDeployment(BaseDeployment): +class MockSageMakerDeployment(MockDeployment): """SageMaker Deployment""" DEFAULT_MODELS = ["command-r"] + @classmethod + def name(cls) -> str: + return "SageMaker" + + @classmethod + def env_vars(cls) -> List[str]: + return [] + @property def rerank_enabled(self) -> bool: return False @@ -25,6 +35,11 @@ def list_models(cls) -> List[str]: def is_available(cls) -> bool: return True + def invoke_chat( + self, chat_request: CohereChatRequest, ctx: Context, **kwargs: Any + ) -> Generator[StreamedChatResponse, None, None]: + pass + def invoke_chat_stream( self, chat_request: CohereChatRequest, ctx: Context, **kwargs: Any ) -> Generator[StreamedChatResponse, None, None]: diff --git a/src/backend/tests/unit/model_deployments/mock_deployments/mock_single_container.py b/src/backend/tests/unit/model_deployments/mock_deployments/mock_single_container.py index c64f7f5f94..85c2279d8f 100644 --- a/src/backend/tests/unit/model_deployments/mock_deployments/mock_single_container.py +++ b/src/backend/tests/unit/model_deployments/mock_deployments/mock_single_container.py @@ -3,16 +3,26 @@ from cohere.types import StreamedChatResponse from backend.chat.enums import StreamEvent -from backend.model_deployments.base import BaseDeployment from backend.schemas.cohere_chat import CohereChatRequest from backend.schemas.context import Context +from backend.tests.unit.model_deployments.mock_deployments.mock_base import ( + MockDeployment, +) -class MockSingleContainerDeployment(BaseDeployment): +class MockSingleContainerDeployment(MockDeployment): """Mocked Single Container Deployment.""" DEFAULT_MODELS = ["command-r"] + @classmethod + def name(cls) -> str: + return "Single Container" + + @classmethod + def env_vars(cls) -> List[str]: + return [] + @property def rerank_enabled(self) -> bool: return False diff --git a/src/backend/tests/unit/model_deployments/test_azure.py b/src/backend/tests/unit/model_deployments/test_azure.py index c55cab4e36..afefd12e6a 100644 --- a/src/backend/tests/unit/model_deployments/test_azure.py +++ b/src/backend/tests/unit/model_deployments/test_azure.py @@ -1,7 +1,7 @@ from fastapi.testclient import TestClient -from backend.config.deployments import ModelDeploymentName from backend.database_models.user import User +from backend.model_deployments.azure import AzureDeployment from backend.tests.unit.model_deployments.mock_deployments import MockAzureDeployment @@ -16,7 +16,7 @@ def test_streamed_chat( "/v1/chat-stream", headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.Azure, + "Deployment-Name": AzureDeployment.name(), }, json={"message": "Hello", "max_tokens": 10}, ) @@ -35,7 +35,7 @@ def test_non_streamed_chat( "/v1/chat", headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.Azure, + "Deployment-Name": AzureDeployment.name(), }, json={"message": "Hello", "max_tokens": 10}, ) diff --git a/src/backend/tests/unit/model_deployments/test_bedrock.py b/src/backend/tests/unit/model_deployments/test_bedrock.py index 645b00a779..fa3f77fdea 100644 --- a/src/backend/tests/unit/model_deployments/test_bedrock.py +++ b/src/backend/tests/unit/model_deployments/test_bedrock.py @@ -1,7 +1,7 @@ from fastapi.testclient import TestClient -from backend.config.deployments import ModelDeploymentName from backend.database_models.user import User +from backend.model_deployments.bedrock import BedrockDeployment from backend.tests.unit.model_deployments.mock_deployments import MockBedrockDeployment @@ -16,7 +16,7 @@ def test_streamed_chat( "/v1/chat-stream", headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.Bedrock, + "Deployment-Name": BedrockDeployment.name(), }, json={"message": "Hello", "max_tokens": 10}, ) @@ -33,7 +33,7 @@ def test_non_streamed_chat( mock_bedrock_deployment.return_value response = session_client_chat.post( "/v1/chat", - headers={"User-Id": user.id, "Deployment-Name": ModelDeploymentName.Bedrock}, + headers={"User-Id": user.id, "Deployment-Name": BedrockDeployment.name(),}, json={"message": "Hello", "max_tokens": 10}, ) diff --git a/src/backend/tests/unit/model_deployments/test_cohere_platform.py b/src/backend/tests/unit/model_deployments/test_cohere_platform.py index 2ab82cfe56..2041a27f8c 100644 --- a/src/backend/tests/unit/model_deployments/test_cohere_platform.py +++ b/src/backend/tests/unit/model_deployments/test_cohere_platform.py @@ -1,7 +1,7 @@ from fastapi.testclient import TestClient -from backend.config.deployments import ModelDeploymentName from backend.database_models.user import User +from backend.model_deployments.cohere_platform import CohereDeployment from backend.tests.unit.model_deployments.mock_deployments import MockCohereDeployment @@ -16,7 +16,7 @@ def test_streamed_chat( "/v1/chat-stream", headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, json={"message": "Hello", "max_tokens": 10}, ) @@ -35,7 +35,7 @@ def test_non_streamed_chat( "/v1/chat", headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, json={"message": "Hello", "max_tokens": 10}, ) diff --git a/src/backend/tests/unit/model_deployments/test_sagemaker.py b/src/backend/tests/unit/model_deployments/test_sagemaker.py index db499498a9..8498329188 100644 --- a/src/backend/tests/unit/model_deployments/test_sagemaker.py +++ b/src/backend/tests/unit/model_deployments/test_sagemaker.py @@ -1,8 +1,8 @@ import pytest from fastapi.testclient import TestClient -from backend.config.deployments import ModelDeploymentName from backend.database_models.user import User +from backend.model_deployments.sagemaker import SageMakerDeployment from backend.tests.unit.model_deployments.mock_deployments import ( MockSageMakerDeployment, ) @@ -17,7 +17,7 @@ def test_streamed_chat( deployment = mock_sagemaker_deployment.return_value response = session_client_chat.post( "/v1/chat-stream", - headers={"User-Id": user.id, "Deployment-Name": ModelDeploymentName.SageMaker}, + headers={"User-Id": user.id, "Deployment-Name": SageMakerDeployment.name()}, json={"message": "Hello", "max_tokens": 10}, ) @@ -32,7 +32,7 @@ def test_non_streamed_chat( mock_sagemaker_deployment.return_value response = session_client_chat.post( "/v1/chat", - headers={"User-Id": user.id, "Deployment-Name": ModelDeploymentName.SageMaker}, + headers={"User-Id": user.id, "Deployment-Name": SageMakerDeployment.name()}, json={"message": "Hello", "max_tokens": 10}, ) diff --git a/src/backend/tests/unit/model_deployments/test_single_container.py b/src/backend/tests/unit/model_deployments/test_single_container.py index f74a761bf7..be602f00eb 100644 --- a/src/backend/tests/unit/model_deployments/test_single_container.py +++ b/src/backend/tests/unit/model_deployments/test_single_container.py @@ -1,7 +1,7 @@ from fastapi.testclient import TestClient -from backend.config.deployments import ModelDeploymentName from backend.database_models.user import User +from backend.model_deployments.single_container import SingleContainerDeployment from backend.tests.unit.model_deployments.mock_deployments import ( MockSingleContainerDeployment, ) @@ -18,7 +18,7 @@ def test_streamed_chat( "/v1/chat-stream", headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.SingleContainer, + "Deployment-Name": SingleContainerDeployment.name(), }, json={"message": "Hello", "max_tokens": 10}, ) @@ -35,7 +35,7 @@ def test_non_streamed_chat( "/v1/chat", headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": SingleContainerDeployment.name(), }, json={"message": "Hello", "max_tokens": 10}, ) diff --git a/src/backend/tests/unit/routers/test_agent.py b/src/backend/tests/unit/routers/test_agent.py index 20bee41aa0..25341705a4 100644 --- a/src/backend/tests/unit/routers/test_agent.py +++ b/src/backend/tests/unit/routers/test_agent.py @@ -5,12 +5,13 @@ from sqlalchemy.orm import Session from backend.config.default_agent import DEFAULT_AGENT_ID -from backend.config.deployments import ModelDeploymentName from backend.config.tools import Tool from backend.crud import deployment as deployment_crud from backend.database_models.agent import Agent from backend.database_models.agent_tool_metadata import AgentToolMetadata from backend.database_models.snapshot import Snapshot +from backend.exceptions import DeploymentNotFoundError +from backend.model_deployments.cohere_platform import CohereDeployment from backend.tests.unit.factories import get_factory is_cohere_env_set = ( @@ -29,7 +30,7 @@ def test_create_agent_missing_name( "preamble": "test preamble", "temperature": 0.5, "model": "command-r-plus", - "deployment": ModelDeploymentName.CoherePlatform, + "deployment": CohereDeployment.name(), } response = session_client.post( "/v1/agents", json=request_json, headers={"User-Id": user.id} @@ -46,7 +47,7 @@ def test_create_agent_missing_model( "description": "test description", "preamble": "test preamble", "temperature": 0.5, - "deployment": ModelDeploymentName.CoherePlatform, + "deployment": CohereDeployment.name(), } response = session_client.post( "/v1/agents", json=request_json, headers={"User-Id": user.id} @@ -78,7 +79,7 @@ def test_create_agent_missing_user_id_header( request_json = { "name": "test agent", "model": "command-r-plus", - "deployment": ModelDeploymentName.CoherePlatform, + "deployment": CohereDeployment.name(), } response = session_client.post("/v1/agents", json=request_json) assert response.status_code == 401 @@ -97,13 +98,10 @@ def test_create_agent_invalid_deployment( "deployment": "not a real deployment", } - response = session_client.post( - "/v1/agents", json=request_json, headers={"User-Id": user.id} - ) - assert response.status_code == 400 - assert response.json() == { - "detail": "Deployment not a real deployment not found or is not available in the Database." - } + with pytest.raises(DeploymentNotFoundError): + session_client.post( + "/v1/agents", json=request_json, headers={"User-Id": user.id} + ) @pytest.mark.skipif(not is_cohere_env_set, reason="Cohere API key not set") @@ -116,14 +114,14 @@ def test_create_agent_deployment_not_in_db( "preamble": "test preamble", "temperature": 0.5, "model": "command-r-plus", - "deployment": ModelDeploymentName.CoherePlatform, + "deployment": CohereDeployment.name(), } - cohere_deployment = deployment_crud.get_deployment_by_name(session, ModelDeploymentName.CoherePlatform) + cohere_deployment = deployment_crud.get_deployment_by_name(session, CohereDeployment.name()) deployment_crud.delete_deployment(session, cohere_deployment.id) response = session_client.post( "/v1/agents", json=request_json, headers={"User-Id": user.id} ) - cohere_deployment = deployment_crud.get_deployment_by_name(session, ModelDeploymentName.CoherePlatform) + cohere_deployment = deployment_crud.get_deployment_by_name(session, CohereDeployment.name()) deployment_models = cohere_deployment.models deployment_models_list = [model.name for model in deployment_models] assert response.status_code == 200 @@ -137,7 +135,7 @@ def test_create_agent_invalid_tool( request_json = { "name": "test agent", "model": "command-r-plus", - "deployment": ModelDeploymentName.CoherePlatform, + "deployment": CohereDeployment.name(), "tools": [Tool.Calculator.value.ID, "fake_tool"], } @@ -436,7 +434,7 @@ def test_update_agent(session_client: TestClient, session: Session, user) -> Non "preamble": "updated preamble", "temperature": 0.7, "model": "command-r", - "deployment": ModelDeploymentName.CoherePlatform, + "deployment": CohereDeployment.name(), } response = session_client.put( @@ -453,7 +451,7 @@ def test_update_agent(session_client: TestClient, session: Session, user) -> Non assert updated_agent["preamble"] == "updated preamble" assert updated_agent["temperature"] == 0.7 assert updated_agent["model"] == "command-r" - assert updated_agent["deployment"] == ModelDeploymentName.CoherePlatform + assert updated_agent["deployment"] == CohereDeployment.name() def test_partial_update_agent(session_client: TestClient, session: Session) -> None: @@ -722,7 +720,7 @@ def test_update_agent_invalid_model( request_json = { "model": "not a real model", - "deployment": ModelDeploymentName.CoherePlatform, + "deployment": CohereDeployment.name(), } response = session_client.put( @@ -751,13 +749,10 @@ def test_update_agent_invalid_deployment( "deployment": "not a real deployment", } - response = session_client.put( - f"/v1/agents/{agent.id}", json=request_json, headers={"User-Id": user.id} - ) - assert response.status_code == 400 - assert response.json() == { - "detail": "Deployment not a real deployment not found or is not available in the Database." - } + with pytest.raises(DeploymentNotFoundError): + session_client.put( + f"/v1/agents/{agent.id}", json=request_json, headers={"User-Id": user.id} + ) def test_update_agent_invalid_tool( diff --git a/src/backend/tests/unit/routers/test_chat.py b/src/backend/tests/unit/routers/test_chat.py index f26599aa66..dcda2562fc 100644 --- a/src/backend/tests/unit/routers/test_chat.py +++ b/src/backend/tests/unit/routers/test_chat.py @@ -2,18 +2,22 @@ import os import uuid from typing import Any +from unittest.mock import patch import pytest from fastapi.testclient import TestClient from sqlalchemy.orm import Session from backend.chat.enums import StreamEvent -from backend.config.deployments import ModelDeploymentName from backend.database_models.conversation import Conversation from backend.database_models.message import Message, MessageAgent from backend.database_models.user import User +from backend.model_deployments.cohere_platform import CohereDeployment from backend.schemas.tool import ToolCategory from backend.tests.unit.factories import get_factory +from backend.tests.unit.model_deployments.mock_deployments.mock_cohere_platform import ( + MockCohereDeployment, +) is_cohere_env_set = ( os.environ.get("COHERE_API_KEY") is not None @@ -31,14 +35,15 @@ def user(session_chat: Session) -> User: def test_streaming_new_chat( session_client_chat: TestClient, session_chat: Session, user: User ): - response = session_client_chat.post( - "/v1/chat-stream", - headers={ - "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, - }, - json={"message": "Hello", "max_tokens": 10}, - ) + with patch("backend.services.deployment.get_deployment_by_name", return_value=CohereDeployment): + response = session_client_chat.post( + "/v1/chat-stream", + headers={ + "User-Id": user.id, + "Deployment-Name": MockCohereDeployment.name(), + }, + json={"message": "Hello", "max_tokens": 10}, + ) assert response.status_code == 200 validate_chat_streaming_response( @@ -55,15 +60,16 @@ def test_streaming_new_chat_with_agent( agent = get_factory("Agent", session_chat).create(user=user, tools=[], deployment_id=deployment.id, model_id=model.id) - response = session_client_chat.post( - "/v1/chat-stream", - headers={ - "User-Id": agent.user.id, - "Deployment-Name": agent.deployment, - }, - params={"agent_id": agent.id}, - json={"message": "Hello", "max_tokens": 10, "agent_id": agent.id}, - ) + with patch("backend.services.deployment.get_deployment_by_name", return_value=CohereDeployment): + response = session_client_chat.post( + "/v1/chat-stream", + headers={ + "User-Id": agent.user.id, + "Deployment-Name": agent.deployment, + }, + params={"agent_id": agent.id}, + json={"message": "Hello", "max_tokens": 10, "agent_id": agent.id}, + ) assert response.status_code == 200 validate_chat_streaming_response( response, agent.user, session_chat, session_client_chat, 2 @@ -105,15 +111,16 @@ def test_streaming_new_chat_with_agent_existing_conversation( session_chat.refresh(conversation) - response = session_client_chat.post( - "/v1/chat-stream", - headers={ - "User-Id": agent.user.id, - "Deployment-Name": agent.deployment, - }, - params={"agent_id": agent.id}, - json={"message": "Hello", "max_tokens": 10, "conversation_id": conversation.id, "agent_id": agent.id}, - ) + with patch("backend.services.deployment.get_deployment_by_name", return_value=CohereDeployment): + response = session_client_chat.post( + "/v1/chat-stream", + headers={ + "User-Id": agent.user.id, + "Deployment-Name": agent.deployment, + }, + params={"agent_id": agent.id}, + json={"message": "Hello", "max_tokens": 10, "conversation_id": conversation.id, "agent_id": agent.id}, + ) assert response.status_code == 200 validate_chat_streaming_response( @@ -154,7 +161,7 @@ def test_streaming_chat_with_existing_conversation_from_other_agent( "/v1/chat-stream", headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, params={"agent_id": agent.id}, json={"message": "Hello", "max_tokens": 10, "conversation_id": conversation.id, "agent_id": agent.id}, @@ -175,18 +182,19 @@ def test_streaming_chat_with_tools_not_in_agent_tools( agent = get_factory("Agent", session_chat).create(user=user, tools=["wikipedia"], deployment_id=deployment.id, model_id=model.id) - response = session_client_chat.post( - "/v1/chat-stream", - headers={ - "User-Id": agent.user.id, - "Deployment-Name": agent.deployment, - }, - json={ - "message": "Who is a tallest nba player", - "tools": [{"name": "tavily_web_search"}], - "agent_id": agent.id, - }, - ) + with patch("backend.services.deployment.get_deployment_by_name", return_value=CohereDeployment): + response = session_client_chat.post( + "/v1/chat-stream", + headers={ + "User-Id": agent.user.id, + "Deployment-Name": agent.deployment, + }, + json={ + "message": "Who is a tallest nba player", + "tools": [{"name": "tavily_web_search"}], + "agent_id": agent.id, + }, + ) assert response.status_code == 200 validate_chat_streaming_tool_cals_response(response, ["tavily_web_search"]) @@ -205,7 +213,8 @@ def test_streaming_chat_with_agent_tools_and_empty_request_tools( "/v1/chat-stream", headers={ "User-Id": agent.user.id, - "Deployment-Name": agent.deployment, + # "Deployment-Name": agent.deployment, + "Deployment-Name": CohereDeployment.name(), }, json={ "message": "Who is a tallest NBA player", @@ -248,7 +257,7 @@ def test_streaming_existing_chat( "/v1/chat-stream", headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, json={ "message": "How are you doing?", @@ -270,7 +279,7 @@ def test_fail_chat_missing_user_id( response = session_client_chat.post( "/v1/chat", json={"message": "Hello"}, - headers={"Deployment-Name": ModelDeploymentName.CoherePlatform}, + headers={"Deployment-Name": CohereDeployment.name()}, ) assert response.status_code == 401 @@ -298,7 +307,7 @@ def test_streaming_fail_chat_missing_message( "/v1/chat-stream", headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, json={}, ) @@ -330,7 +339,7 @@ def test_streaming_chat_with_managed_tools(session_client_chat, session_chat, us json={"message": "Hello", "tools": [{"name": tool}]}, headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, ) @@ -349,7 +358,7 @@ def test_streaming_chat_with_invalid_tool( json={"message": "Hello", "tools": [{"name": "invalid_tool"}]}, headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, ) @@ -381,7 +390,7 @@ def test_streaming_chat_with_managed_and_custom_tools( }, headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, ) @@ -401,7 +410,7 @@ def test_streaming_chat_with_search_queries_only( }, headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, ) @@ -432,7 +441,7 @@ def test_streaming_chat_with_chat_history( }, headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, ) @@ -459,7 +468,7 @@ def test_streaming_existing_chat_with_files_attaches_to_user_message( "/v1/chat-stream", headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, json={ "message": "How are you doing?", @@ -515,7 +524,7 @@ def test_streaming_existing_chat_with_attached_files_does_not_attach( "/v1/chat-stream", headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, json={ "message": "How are you doing?", @@ -550,7 +559,7 @@ def test_streaming_chat_private_agent( "/v1/chat-stream", headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, params={"agent_id": agent.id}, json={"message": "Hello", "max_tokens": 10, "agent_id": agent.id}, @@ -573,7 +582,7 @@ def test_streaming_chat_public_agent( "/v1/chat-stream", headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, params={"agent_id": agent.id}, json={"message": "Hello", "max_tokens": 10, "agent_id": agent.id}, @@ -596,7 +605,7 @@ def test_streaming_chat_private_agent_by_another_user( "/v1/chat-stream", headers={ "User-Id": other_user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, params={"agent_id": agent.id}, json={"message": "Hello", "max_tokens": 10, "agent_id": agent.id}, @@ -636,7 +645,7 @@ def test_stream_regenerate_existing_chat( "/v1/chat-stream/regenerate", headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, json={ "message": "", @@ -661,7 +670,7 @@ def test_stream_regenerate_not_existing_chat( "/v1/chat-stream/regenerate", headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, json={ "message": "", @@ -686,7 +695,7 @@ def test_stream_regenerate_existing_chat_not_existing_user_messages( "/v1/chat-stream/regenerate", headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, json={ "message": "", @@ -709,7 +718,7 @@ def test_non_streaming_chat( json={"message": "Hello", "max_tokens": 10}, headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, ) @@ -732,7 +741,7 @@ def test_non_streaming_chat_with_managed_tools(session_client_chat, session_chat json={"message": "Hello", "tools": [{"name": tool}]}, headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, ) @@ -766,13 +775,14 @@ def test_non_streaming_chat_with_managed_and_custom_tools( }, headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, ) assert response.status_code == 400 assert response.json() == {"detail": "Cannot mix both managed and custom tools"} + @pytest.mark.skipif(not is_cohere_env_set, reason="Cohere API key not set") def test_non_streaming_chat_with_search_queries_only( session_client_chat: TestClient, session_chat: Session, user: User @@ -785,7 +795,7 @@ def test_non_streaming_chat_with_search_queries_only( }, headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, ) @@ -811,7 +821,7 @@ def test_non_streaming_chat_with_chat_history( }, headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, ) @@ -834,7 +844,7 @@ def test_non_streaming_existing_chat_with_files_attaches_to_user_message( "/v1/chat", headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, json={ "message": "How are you doing?", @@ -881,7 +891,7 @@ def test_non_streaming_existing_chat_with_attached_files_does_not_attach( "/v1/chat", headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, json={ "message": "How are you doing?", @@ -983,7 +993,7 @@ def test_streaming_chat_with_files( }, headers={ "User-Id": user.id, - "Deployment-Name": ModelDeploymentName.CoherePlatform, + "Deployment-Name": CohereDeployment.name(), }, ) diff --git a/src/backend/tests/unit/routers/test_deployment.py b/src/backend/tests/unit/routers/test_deployment.py index 7d7888b0e3..92d3cdc6d8 100644 --- a/src/backend/tests/unit/routers/test_deployment.py +++ b/src/backend/tests/unit/routers/test_deployment.py @@ -4,8 +4,10 @@ from fastapi.testclient import TestClient from sqlalchemy.orm import Session -from backend.config.deployments import AVAILABLE_MODEL_DEPLOYMENTS, ModelDeploymentName +from backend.config.deployments import AVAILABLE_MODEL_DEPLOYMENTS from backend.database_models import Deployment +from backend.model_deployments.cohere_platform import CohereDeployment +from backend.tests.unit.model_deployments.mock_deployments import MockCohereDeployment def test_create_deployment(session_client: TestClient) -> None: @@ -22,13 +24,13 @@ def test_create_deployment(session_client: TestClient) -> None: assert response.status_code == 200 deployment = response.json() assert deployment["name"] == request_json["name"] - assert deployment["env_vars"] == ["COHERE_API_KEY"] + assert deployment["config"] == {"COHERE_API_KEY": 'test-api-key'} assert deployment["is_available"] def test_create_deployment_unique(session_client: TestClient) -> None: request_json = { - "name": ModelDeploymentName.CoherePlatform, + "name": CohereDeployment.name(), "default_deployment_config": {"COHERE_API_KEY": "test-api-key"}, "deployment_class_name": "CohereDeployment", } @@ -38,7 +40,7 @@ def test_create_deployment_unique(session_client: TestClient) -> None: ) assert response.status_code == 400 assert ( - f"Deployment {ModelDeploymentName.CoherePlatform} already exists." + f"Deployment {CohereDeployment.name()} already exists." in response.json()["detail"] ) @@ -67,21 +69,15 @@ def test_list_deployments_has_all_option( response = session_client.get("/v1/deployments?all=1") assert response.status_code == 200 deployments = response.json() - db_deployments = session.query(Deployment).all() - # If no deployments are found in the database, then all available deployments from settings should be returned - if not db_deployments or len(deployments) != len(db_deployments): - db_deployments = [ - deployment for _, deployment in AVAILABLE_MODEL_DEPLOYMENTS.items() - ] - assert len(deployments) == len(db_deployments) + assert len(deployments) == len(AVAILABLE_MODEL_DEPLOYMENTS) def test_list_deployments_no_available_models_404( session_client: TestClient, session: Session ) -> None: session.query(Deployment).delete() - AVAILABLE_MODEL_DEPLOYMENTS.clear() - response = session_client.get("/v1/deployments") + with patch("backend.services.deployment.AVAILABLE_MODEL_DEPLOYMENTS", []): + response = session_client.get("/v1/deployments") assert response.status_code == 404 assert response.json() == { "detail": [ @@ -112,7 +108,7 @@ def test_update_deployment(session_client: TestClient, session: Session) -> None assert response.status_code == 200 updated_deployment = response.json() assert updated_deployment["name"] == request_json["name"] - assert updated_deployment["env_vars"] == ["COHERE_API_KEY"] + assert updated_deployment["config"] == {"COHERE_API_KEY": 'test-api-key'} assert updated_deployment["is_available"] assert updated_deployment["description"] == request_json["description"] assert updated_deployment["is_community"] == request_json["is_community"] @@ -120,6 +116,7 @@ def test_update_deployment(session_client: TestClient, session: Session) -> None def test_delete_deployment(session_client: TestClient, session: Session) -> None: deployment = session.query(Deployment).first() + assert deployment is not None response = session_client.delete("/v1/deployments/" + deployment.id) deleted = session.query(Deployment).filter(Deployment.id == deployment.id).first() assert response.status_code == 200 @@ -132,10 +129,10 @@ def test_set_env_vars( ) -> None: with patch("backend.services.env.set_key") as mock_set_key: response = client.post( - "/v1/deployments/Cohere+Platform/set_env_vars", + "/v1/deployments/cohere_platform/update_config", json={ "env_vars": { - "COHERE_VAR_1": "TestCohereValue", + "COHERE_API_KEY": "TestCohereValue", }, }, ) @@ -147,7 +144,7 @@ def __eq__(self, other): mock_set_key.assert_called_with( EnvPathMatcher(), - "COHERE_VAR_1", + "COHERE_API_KEY", "TestCohereValue", ) @@ -155,7 +152,7 @@ def __eq__(self, other): def test_set_env_vars_with_invalid_deployment_name( client: TestClient, mock_available_model_deployments: Mock ): - response = client.post("/v1/deployments/unknown/set_env_vars", json={}) + response = client.post("/v1/deployments/unknown/update_config", json={}) assert response.status_code == 404 @@ -163,7 +160,7 @@ def test_set_env_vars_with_var_for_other_deployment( client: TestClient, mock_available_model_deployments: Mock ) -> None: response = client.post( - "/v1/deployments/Cohere+Platform/set_env_vars", + "/v1/deployments/cohere_platform/update_config", json={ "env_vars": { "SAGEMAKER_VAR_1": "TestSageMakerValue", @@ -180,7 +177,7 @@ def test_set_env_vars_with_invalid_var( client: TestClient, mock_available_model_deployments: Mock ) -> None: response = client.post( - "/v1/deployments/Cohere+Platform/set_env_vars", + "/v1/deployments/cohere_platform/update_config", json={ "env_vars": { "API_KEY": "12345", diff --git a/src/backend/tests/unit/config/test_deployments.py b/src/backend/tests/unit/services/test_deployment.py similarity index 100% rename from src/backend/tests/unit/config/test_deployments.py rename to src/backend/tests/unit/services/test_deployment.py diff --git a/src/backend/tests/unit/config/test_tools.py b/src/backend/tests/unit/services/test_tools.py similarity index 100% rename from src/backend/tests/unit/config/test_tools.py rename to src/backend/tests/unit/services/test_tools.py diff --git a/src/community/config/deployments.py b/src/community/config/deployments.py index 3d339b1d90..350208ec52 100644 --- a/src/community/config/deployments.py +++ b/src/community/config/deployments.py @@ -1,7 +1,10 @@ from enum import StrEnum -from backend.schemas.deployment import Deployment -from community.model_deployments import HuggingFaceDeployment +from community.model_deployments import ( + HuggingFaceDeployment, + # LocalModelDeployment, +) +from community.model_deployments.community_deployment import CommunityDeployment # Add the below for local model deployments # from community.model_deployments.local_model import LocalModelDeployment @@ -12,25 +15,4 @@ class ModelDeploymentName(StrEnum): LocalModel = "LocalModel" -AVAILABLE_MODEL_DEPLOYMENTS = { - ModelDeploymentName.HuggingFace: Deployment( - id="hugging_face", - name=ModelDeploymentName.HuggingFace, - deployment_class=HuggingFaceDeployment, - models=HuggingFaceDeployment.list_models(), - is_available=HuggingFaceDeployment.is_available(), - env_vars=[], - ), - # # Add the below for local model deployments - # ModelDeploymentName.LocalModel: Deployment( - # id = "local_model", - # name=ModelDeploymentName.LocalModel, - # deployment_class=LocalModelDeployment, - # models=LocalModelDeployment.list_models(), - # is_available=LocalModelDeployment.is_available(), - # env_vars=[], - # kwargs={ - # "model_path": "path/to/model", # Note that the model needs to be in the src directory - # }, - # ), -} +AVAILABLE_MODEL_DEPLOYMENTS = { d.name(): d for d in CommunityDeployment.__subclasses__() } diff --git a/src/community/model_deployments/__init__.py b/src/community/model_deployments/__init__.py index 093250a270..c892f78059 100644 --- a/src/community/model_deployments/__init__.py +++ b/src/community/model_deployments/__init__.py @@ -1,9 +1,5 @@ -from backend.model_deployments.base import BaseDeployment -from backend.schemas.deployment import Deployment from community.model_deployments.hugging_face import HuggingFaceDeployment __all__ = [ - "BaseDeployment", - "Deployment", "HuggingFaceDeployment", ] diff --git a/src/community/model_deployments/community_deployment.py b/src/community/model_deployments/community_deployment.py new file mode 100644 index 0000000000..b9b4a200ce --- /dev/null +++ b/src/community/model_deployments/community_deployment.py @@ -0,0 +1,7 @@ +from backend.model_deployments.base import BaseDeployment + + +class CommunityDeployment(BaseDeployment): + @classmethod + def is_community(cls): + return True diff --git a/src/community/model_deployments/hugging_face.py b/src/community/model_deployments/hugging_face.py index d625184564..052d7b511d 100644 --- a/src/community/model_deployments/hugging_face.py +++ b/src/community/model_deployments/hugging_face.py @@ -7,10 +7,10 @@ from backend.schemas.chat import ChatMessage from backend.schemas.cohere_chat import CohereChatRequest from backend.schemas.context import Context -from community.model_deployments import BaseDeployment +from community.model_deployments.community_deployment import CommunityDeployment -class HuggingFaceDeployment(BaseDeployment): +class HuggingFaceDeployment(CommunityDeployment): """ The first time you run this code, it will download all the shards of the model from the Hugging Face model hub. This usually takes a while, so you might want to run this code separately and not as part of the toolkit. @@ -26,7 +26,15 @@ class HuggingFaceDeployment(BaseDeployment): def __init__(self, **kwargs: Any): self.ctx = kwargs.get("ctx", None) - @property + @classmethod + def name(cls) -> str: + return "Hugging Face" + + @classmethod + def env_vars(cls) -> List[str]: + return [] + + @classmethod def rerank_enabled(self) -> bool: return False diff --git a/src/community/model_deployments/local_model.py b/src/community/model_deployments/local_model.py index 2f075d1290..165e532896 100644 --- a/src/community/model_deployments/local_model.py +++ b/src/community/model_deployments/local_model.py @@ -7,17 +7,25 @@ # To use local models install poetry with: poetry install --with setup,community,local-model --verbose from backend.schemas.context import Context -from community.model_deployments import BaseDeployment +from community.model_deployments.community_deployment import CommunityDeployment -class LocalModelDeployment(BaseDeployment): +class LocalModelDeployment(CommunityDeployment): def __init__(self, model_path: str, template: str = None): self.prompt_template = PromptTemplate() self.model_path = model_path self.template = template - @property - def rerank_enabled(self) -> bool: + @classmethod + def name(cls) -> str: + return "Local Model" + + @classmethod + def env_vars(cls) -> List[str]: + return [] + + @classmethod + def rerank_enabled(cls) -> bool: return False @classmethod diff --git a/src/interfaces/assistants_web/src/components/AgentSettingsForm/ConfigStep.tsx b/src/interfaces/assistants_web/src/components/AgentSettingsForm/ConfigStep.tsx index 8c5ca8ade9..9257388cdc 100644 --- a/src/interfaces/assistants_web/src/components/AgentSettingsForm/ConfigStep.tsx +++ b/src/interfaces/assistants_web/src/components/AgentSettingsForm/ConfigStep.tsx @@ -1,6 +1,6 @@ 'use client'; -import { useState } from 'react'; +import React, { useState } from 'react'; import { AgentSettingsFields } from '@/components/AgentSettingsForm'; import { Dropdown } from '@/components/UI'; diff --git a/src/interfaces/coral_web/next-env.d.ts b/src/interfaces/coral_web/next-env.d.ts index 4f11a03dc6..40c3d68096 100644 --- a/src/interfaces/coral_web/next-env.d.ts +++ b/src/interfaces/coral_web/next-env.d.ts @@ -2,4 +2,4 @@ /// // NOTE: This file should not be edited -// see https://nextjs.org/docs/basic-features/typescript for more information. +// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information. diff --git a/src/interfaces/coral_web/src/cohere-client/client.ts b/src/interfaces/coral_web/src/cohere-client/client.ts index d0be521b42..c56fc82e84 100644 --- a/src/interfaces/coral_web/src/cohere-client/client.ts +++ b/src/interfaces/coral_web/src/cohere-client/client.ts @@ -154,6 +154,13 @@ export class CohereClient { }); } + public updateDeploymentConfig(deploymentId: string, requestBody: UpdateDeploymentEnv) { + return this.cohereService.default.updateConfigV1DeploymentsDeploymentIdUpdateConfigPost({ + deploymentId: deploymentId, + requestBody, + }); + } + public getExperimentalFeatures() { return this.cohereService.default.listExperimentalFeaturesV1ExperimentalFeaturesGet() as CancelablePromise; } diff --git a/src/interfaces/coral_web/src/cohere-client/generated/CohereClientGenerated.ts b/src/interfaces/coral_web/src/cohere-client/generated/CohereClientGenerated.ts index 12629cfe05..5a2fbf5c03 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/CohereClientGenerated.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/CohereClientGenerated.ts @@ -1,36 +1,35 @@ import type { BaseHttpRequest } from './core/BaseHttpRequest'; -import { FetchHttpRequest } from './core/FetchHttpRequest'; import type { OpenAPIConfig } from './core/OpenAPI'; import { Interceptors } from './core/OpenAPI'; +import { FetchHttpRequest } from './core/FetchHttpRequest'; + import { DefaultService } from './services.gen'; type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest; export class CohereClientGenerated { - public readonly default: DefaultService; - public readonly request: BaseHttpRequest; + public readonly default: DefaultService; + + public readonly request: BaseHttpRequest; - constructor( - config?: Partial, - HttpRequest: HttpRequestConstructor = FetchHttpRequest - ) { - this.request = new HttpRequest({ - BASE: config?.BASE ?? '', - VERSION: config?.VERSION ?? '0.1.0', - WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false, - CREDENTIALS: config?.CREDENTIALS ?? 'include', - TOKEN: config?.TOKEN, - USERNAME: config?.USERNAME, - PASSWORD: config?.PASSWORD, - HEADERS: config?.HEADERS, - ENCODE_PATH: config?.ENCODE_PATH, - interceptors: { - request: config?.interceptors?.request ?? new Interceptors(), - response: config?.interceptors?.response ?? new Interceptors(), + constructor(config?: Partial, HttpRequest: HttpRequestConstructor = FetchHttpRequest) { + this.request = new HttpRequest({ + BASE: config?.BASE ?? '', + VERSION: config?.VERSION ?? '0.1.0', + WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false, + CREDENTIALS: config?.CREDENTIALS ?? 'include', + TOKEN: config?.TOKEN, + USERNAME: config?.USERNAME, + PASSWORD: config?.PASSWORD, + HEADERS: config?.HEADERS, + ENCODE_PATH: config?.ENCODE_PATH, + interceptors: { + request: config?.interceptors?.request ?? new Interceptors(), + response: config?.interceptors?.response ?? new Interceptors(), }, - }); + }); - this.default = new DefaultService(this.request); - } + this.default = new DefaultService(this.request); + } } diff --git a/src/interfaces/coral_web/src/cohere-client/generated/core/ApiError.ts b/src/interfaces/coral_web/src/cohere-client/generated/core/ApiError.ts index 23890cedf4..36675d288a 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/core/ApiError.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/core/ApiError.ts @@ -2,20 +2,20 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; export class ApiError extends Error { - public readonly url: string; - public readonly status: number; - public readonly statusText: string; - public readonly body: unknown; - public readonly request: ApiRequestOptions; + public readonly url: string; + public readonly status: number; + public readonly statusText: string; + public readonly body: unknown; + public readonly request: ApiRequestOptions; - constructor(request: ApiRequestOptions, response: ApiResult, message: string) { - super(message); + constructor(request: ApiRequestOptions, response: ApiResult, message: string) { + super(message); - this.name = 'ApiError'; - this.url = response.url; - this.status = response.status; - this.statusText = response.statusText; - this.body = response.body; - this.request = request; - } -} + this.name = 'ApiError'; + this.url = response.url; + this.status = response.status; + this.statusText = response.statusText; + this.body = response.body; + this.request = request; + } +} \ No newline at end of file diff --git a/src/interfaces/coral_web/src/cohere-client/generated/core/ApiRequestOptions.ts b/src/interfaces/coral_web/src/cohere-client/generated/core/ApiRequestOptions.ts index 3f932f702e..1758d98c4d 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/core/ApiRequestOptions.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/core/ApiRequestOptions.ts @@ -1,14 +1,14 @@ export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly url: string; - readonly path?: Record; - readonly cookies?: Record; - readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; - readonly mediaType?: string; - readonly responseHeader?: string; - readonly responseTransformer?: (data: unknown) => Promise; - readonly errors?: Record; -}; + readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; + readonly url: string; + readonly path?: Record; + readonly cookies?: Record; + readonly headers?: Record; + readonly query?: Record; + readonly formData?: Record; + readonly body?: any; + readonly mediaType?: string; + readonly responseHeader?: string; + readonly responseTransformer?: (data: unknown) => Promise; + readonly errors?: Record; +}; \ No newline at end of file diff --git a/src/interfaces/coral_web/src/cohere-client/generated/core/ApiResult.ts b/src/interfaces/coral_web/src/cohere-client/generated/core/ApiResult.ts index 05040ba816..4c58e39138 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/core/ApiResult.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/core/ApiResult.ts @@ -1,7 +1,7 @@ export type ApiResult = { - readonly body: TData; - readonly ok: boolean; - readonly status: number; - readonly statusText: string; - readonly url: string; -}; + readonly body: TData; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly url: string; +}; \ No newline at end of file diff --git a/src/interfaces/coral_web/src/cohere-client/generated/core/BaseHttpRequest.ts b/src/interfaces/coral_web/src/cohere-client/generated/core/BaseHttpRequest.ts index 8cee0b4a9e..ee28b81640 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/core/BaseHttpRequest.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/core/BaseHttpRequest.ts @@ -3,7 +3,8 @@ import type { CancelablePromise } from './CancelablePromise'; import type { OpenAPIConfig } from './OpenAPI'; export abstract class BaseHttpRequest { - constructor(public readonly config: OpenAPIConfig) {} - public abstract request(options: ApiRequestOptions): CancelablePromise; -} + constructor(public readonly config: OpenAPIConfig) {} + + public abstract request(options: ApiRequestOptions): CancelablePromise; +} \ No newline at end of file diff --git a/src/interfaces/coral_web/src/cohere-client/generated/core/CancelablePromise.ts b/src/interfaces/coral_web/src/cohere-client/generated/core/CancelablePromise.ts index 040e6efdab..ccc082e8f2 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/core/CancelablePromise.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/core/CancelablePromise.ts @@ -1,126 +1,126 @@ export class CancelError extends Error { - constructor(message: string) { - super(message); - this.name = 'CancelError'; - } - - public get isCancelled(): boolean { - return true; - } + constructor(message: string) { + super(message); + this.name = 'CancelError'; + } + + public get isCancelled(): boolean { + return true; + } } export interface OnCancel { - readonly isResolved: boolean; - readonly isRejected: boolean; - readonly isCancelled: boolean; + readonly isResolved: boolean; + readonly isRejected: boolean; + readonly isCancelled: boolean; - (cancelHandler: () => void): void; + (cancelHandler: () => void): void; } export class CancelablePromise implements Promise { - private _isResolved: boolean; - private _isRejected: boolean; - private _isCancelled: boolean; - readonly cancelHandlers: (() => void)[]; - readonly promise: Promise; - private _resolve?: (value: T | PromiseLike) => void; - private _reject?: (reason?: unknown) => void; - - constructor( - executor: ( - resolve: (value: T | PromiseLike) => void, - reject: (reason?: unknown) => void, - onCancel: OnCancel - ) => void - ) { - this._isResolved = false; - this._isRejected = false; - this._isCancelled = false; - this.cancelHandlers = []; - this.promise = new Promise((resolve, reject) => { - this._resolve = resolve; - this._reject = reject; - - const onResolve = (value: T | PromiseLike): void => { - if (this._isResolved || this._isRejected || this._isCancelled) { - return; - } - this._isResolved = true; - if (this._resolve) this._resolve(value); - }; - - const onReject = (reason?: unknown): void => { - if (this._isResolved || this._isRejected || this._isCancelled) { - return; - } - this._isRejected = true; - if (this._reject) this._reject(reason); - }; - - const onCancel = (cancelHandler: () => void): void => { - if (this._isResolved || this._isRejected || this._isCancelled) { - return; - } - this.cancelHandlers.push(cancelHandler); - }; - - Object.defineProperty(onCancel, 'isResolved', { - get: (): boolean => this._isResolved, - }); - - Object.defineProperty(onCancel, 'isRejected', { - get: (): boolean => this._isRejected, - }); - - Object.defineProperty(onCancel, 'isCancelled', { - get: (): boolean => this._isCancelled, - }); - - return executor(onResolve, onReject, onCancel as OnCancel); - }); - } - - get [Symbol.toStringTag]() { - return 'Cancellable Promise'; - } - - public then( - onFulfilled?: ((value: T) => TResult1 | PromiseLike) | null, - onRejected?: ((reason: unknown) => TResult2 | PromiseLike) | null - ): Promise { - return this.promise.then(onFulfilled, onRejected); - } - - public catch( - onRejected?: ((reason: unknown) => TResult | PromiseLike) | null - ): Promise { - return this.promise.catch(onRejected); - } - - public finally(onFinally?: (() => void) | null): Promise { - return this.promise.finally(onFinally); - } - - public cancel(): void { - if (this._isResolved || this._isRejected || this._isCancelled) { - return; - } - this._isCancelled = true; - if (this.cancelHandlers.length) { - try { - for (const cancelHandler of this.cancelHandlers) { - cancelHandler(); - } - } catch (error) { - console.warn('Cancellation threw an error', error); - return; - } - } - this.cancelHandlers.length = 0; - if (this._reject) this._reject(new CancelError('Request aborted')); - } - - public get isCancelled(): boolean { - return this._isCancelled; - } -} + private _isResolved: boolean; + private _isRejected: boolean; + private _isCancelled: boolean; + readonly cancelHandlers: (() => void)[]; + readonly promise: Promise; + private _resolve?: (value: T | PromiseLike) => void; + private _reject?: (reason?: unknown) => void; + + constructor( + executor: ( + resolve: (value: T | PromiseLike) => void, + reject: (reason?: unknown) => void, + onCancel: OnCancel + ) => void + ) { + this._isResolved = false; + this._isRejected = false; + this._isCancelled = false; + this.cancelHandlers = []; + this.promise = new Promise((resolve, reject) => { + this._resolve = resolve; + this._reject = reject; + + const onResolve = (value: T | PromiseLike): void => { + if (this._isResolved || this._isRejected || this._isCancelled) { + return; + } + this._isResolved = true; + if (this._resolve) this._resolve(value); + }; + + const onReject = (reason?: unknown): void => { + if (this._isResolved || this._isRejected || this._isCancelled) { + return; + } + this._isRejected = true; + if (this._reject) this._reject(reason); + }; + + const onCancel = (cancelHandler: () => void): void => { + if (this._isResolved || this._isRejected || this._isCancelled) { + return; + } + this.cancelHandlers.push(cancelHandler); + }; + + Object.defineProperty(onCancel, 'isResolved', { + get: (): boolean => this._isResolved, + }); + + Object.defineProperty(onCancel, 'isRejected', { + get: (): boolean => this._isRejected, + }); + + Object.defineProperty(onCancel, 'isCancelled', { + get: (): boolean => this._isCancelled, + }); + + return executor(onResolve, onReject, onCancel as OnCancel); + }); + } + + get [Symbol.toStringTag]() { + return "Cancellable Promise"; + } + + public then( + onFulfilled?: ((value: T) => TResult1 | PromiseLike) | null, + onRejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): Promise { + return this.promise.then(onFulfilled, onRejected); + } + + public catch( + onRejected?: ((reason: unknown) => TResult | PromiseLike) | null + ): Promise { + return this.promise.catch(onRejected); + } + + public finally(onFinally?: (() => void) | null): Promise { + return this.promise.finally(onFinally); + } + + public cancel(): void { + if (this._isResolved || this._isRejected || this._isCancelled) { + return; + } + this._isCancelled = true; + if (this.cancelHandlers.length) { + try { + for (const cancelHandler of this.cancelHandlers) { + cancelHandler(); + } + } catch (error) { + console.warn('Cancellation threw an error', error); + return; + } + } + this.cancelHandlers.length = 0; + if (this._reject) this._reject(new CancelError('Request aborted')); + } + + public get isCancelled(): boolean { + return this._isCancelled; + } +} \ No newline at end of file diff --git a/src/interfaces/coral_web/src/cohere-client/generated/core/FetchHttpRequest.ts b/src/interfaces/coral_web/src/cohere-client/generated/core/FetchHttpRequest.ts index 4552f7c0c3..e7c4bd5a9d 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/core/FetchHttpRequest.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/core/FetchHttpRequest.ts @@ -5,17 +5,18 @@ import type { OpenAPIConfig } from './OpenAPI'; import { request as __request } from './request'; export class FetchHttpRequest extends BaseHttpRequest { - constructor(config: OpenAPIConfig) { - super(config); - } - /** - * Request method - * @param options The request options from the service - * @returns CancelablePromise - * @throws ApiError - */ - public override request(options: ApiRequestOptions): CancelablePromise { - return __request(this.config, options); - } -} + constructor(config: OpenAPIConfig) { + super(config); + } + + /** + * Request method + * @param options The request options from the service + * @returns CancelablePromise + * @throws ApiError + */ + public override request(options: ApiRequestOptions): CancelablePromise { + return __request(this.config, options); + } +} \ No newline at end of file diff --git a/src/interfaces/coral_web/src/cohere-client/generated/core/OpenAPI.ts b/src/interfaces/coral_web/src/cohere-client/generated/core/OpenAPI.ts index be99f58378..a6c1a88da7 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/core/OpenAPI.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/core/OpenAPI.ts @@ -24,33 +24,33 @@ export class Interceptors { } export type OpenAPIConfig = { - BASE: string; - CREDENTIALS: 'include' | 'omit' | 'same-origin'; - ENCODE_PATH?: ((path: string) => string) | undefined; - HEADERS?: Headers | Resolver | undefined; - PASSWORD?: string | Resolver | undefined; - TOKEN?: string | Resolver | undefined; - USERNAME?: string | Resolver | undefined; - VERSION: string; - WITH_CREDENTIALS: boolean; - interceptors: { - request: Interceptors; - response: Interceptors; - }; + BASE: string; + CREDENTIALS: 'include' | 'omit' | 'same-origin'; + ENCODE_PATH?: ((path: string) => string) | undefined; + HEADERS?: Headers | Resolver | undefined; + PASSWORD?: string | Resolver | undefined; + TOKEN?: string | Resolver | undefined; + USERNAME?: string | Resolver | undefined; + VERSION: string; + WITH_CREDENTIALS: boolean; + interceptors: { + request: Interceptors; + response: Interceptors; + }; }; export const OpenAPI: OpenAPIConfig = { - BASE: '', - CREDENTIALS: 'include', - ENCODE_PATH: undefined, - HEADERS: undefined, - PASSWORD: undefined, - TOKEN: undefined, - USERNAME: undefined, - VERSION: '0.1.0', - WITH_CREDENTIALS: false, - interceptors: { - request: new Interceptors(), - response: new Interceptors(), - }, -}; + BASE: '', + CREDENTIALS: 'include', + ENCODE_PATH: undefined, + HEADERS: undefined, + PASSWORD: undefined, + TOKEN: undefined, + USERNAME: undefined, + VERSION: '0.1.0', + WITH_CREDENTIALS: false, + interceptors: { + request: new Interceptors(), + response: new Interceptors(), + }, +}; \ No newline at end of file diff --git a/src/interfaces/coral_web/src/cohere-client/generated/core/request.ts b/src/interfaces/coral_web/src/cohere-client/generated/core/request.ts index 592ee1ae1a..5458a2899d 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/core/request.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/core/request.ts @@ -6,320 +6,299 @@ import type { OnCancel } from './CancelablePromise'; import type { OpenAPIConfig } from './OpenAPI'; export const isString = (value: unknown): value is string => { - return typeof value === 'string'; + return typeof value === 'string'; }; export const isStringWithValue = (value: unknown): value is string => { - return isString(value) && value !== ''; + return isString(value) && value !== ''; }; export const isBlob = (value: any): value is Blob => { - return value instanceof Blob; + return value instanceof Blob; }; export const isFormData = (value: unknown): value is FormData => { - return value instanceof FormData; + return value instanceof FormData; }; export const base64 = (str: string): string => { - try { - return btoa(str); - } catch (err) { - // @ts-ignore - return Buffer.from(str).toString('base64'); - } + try { + return btoa(str); + } catch (err) { + // @ts-ignore + return Buffer.from(str).toString('base64'); + } }; export const getQueryString = (params: Record): string => { - const qs: string[] = []; - - const append = (key: string, value: unknown) => { - qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`); - }; - - const encodePair = (key: string, value: unknown) => { - if (value === undefined || value === null) { - return; - } - - if (value instanceof Date) { - append(key, value.toISOString()); - } else if (Array.isArray(value)) { - value.forEach((v) => encodePair(key, v)); - } else if (typeof value === 'object') { - Object.entries(value).forEach(([k, v]) => encodePair(`${key}[${k}]`, v)); - } else { - append(key, value); - } - }; - - Object.entries(params).forEach(([key, value]) => encodePair(key, value)); - - return qs.length ? `?${qs.join('&')}` : ''; + const qs: string[] = []; + + const append = (key: string, value: unknown) => { + qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`); + }; + + const encodePair = (key: string, value: unknown) => { + if (value === undefined || value === null) { + return; + } + + if (value instanceof Date) { + append(key, value.toISOString()); + } else if (Array.isArray(value)) { + value.forEach(v => encodePair(key, v)); + } else if (typeof value === 'object') { + Object.entries(value).forEach(([k, v]) => encodePair(`${key}[${k}]`, v)); + } else { + append(key, value); + } + }; + + Object.entries(params).forEach(([key, value]) => encodePair(key, value)); + + return qs.length ? `?${qs.join('&')}` : ''; }; const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => { - const encoder = config.ENCODE_PATH || encodeURI; - - const path = options.url - .replace('{api-version}', config.VERSION) - .replace(/{(.*?)}/g, (substring: string, group: string) => { - if (options.path?.hasOwnProperty(group)) { - return encoder(String(options.path[group])); - } - return substring; - }); - - const url = config.BASE + path; - return options.query ? url + getQueryString(options.query) : url; + const encoder = config.ENCODE_PATH || encodeURI; + + const path = options.url + .replace('{api-version}', config.VERSION) + .replace(/{(.*?)}/g, (substring: string, group: string) => { + if (options.path?.hasOwnProperty(group)) { + return encoder(String(options.path[group])); + } + return substring; + }); + + const url = config.BASE + path; + return options.query ? url + getQueryString(options.query) : url; }; export const getFormData = (options: ApiRequestOptions): FormData | undefined => { - if (options.formData) { - const formData = new FormData(); - - const process = (key: string, value: unknown) => { - if (isString(value) || isBlob(value)) { - formData.append(key, value); - } else { - formData.append(key, JSON.stringify(value)); - } - }; - - Object.entries(options.formData) - .filter(([, value]) => value !== undefined && value !== null) - .forEach(([key, value]) => { - if (Array.isArray(value)) { - value.forEach((v) => process(key, v)); - } else { - process(key, value); - } - }); - - return formData; - } - return undefined; + if (options.formData) { + const formData = new FormData(); + + const process = (key: string, value: unknown) => { + if (isString(value) || isBlob(value)) { + formData.append(key, value); + } else { + formData.append(key, JSON.stringify(value)); + } + }; + + Object.entries(options.formData) + .filter(([, value]) => value !== undefined && value !== null) + .forEach(([key, value]) => { + if (Array.isArray(value)) { + value.forEach(v => process(key, v)); + } else { + process(key, value); + } + }); + + return formData; + } + return undefined; }; type Resolver = (options: ApiRequestOptions) => Promise; -export const resolve = async ( - options: ApiRequestOptions, - resolver?: T | Resolver -): Promise => { - if (typeof resolver === 'function') { - return (resolver as Resolver)(options); - } - return resolver; +export const resolve = async (options: ApiRequestOptions, resolver?: T | Resolver): Promise => { + if (typeof resolver === 'function') { + return (resolver as Resolver)(options); + } + return resolver; }; -export const getHeaders = async ( - config: OpenAPIConfig, - options: ApiRequestOptions -): Promise => { - const [token, username, password, additionalHeaders] = await Promise.all([ - // @ts-ignore - resolve(options, config.TOKEN), - // @ts-ignore - resolve(options, config.USERNAME), - // @ts-ignore - resolve(options, config.PASSWORD), - // @ts-ignore - resolve(options, config.HEADERS), - ]); - - const headers = Object.entries({ - Accept: 'application/json', - ...additionalHeaders, - ...options.headers, - }) - .filter(([, value]) => value !== undefined && value !== null) - .reduce( - (headers, [key, value]) => ({ - ...headers, - [key]: String(value), - }), - {} as Record - ); - - if (isStringWithValue(token)) { - headers['Authorization'] = `Bearer ${token}`; - } - - if (isStringWithValue(username) && isStringWithValue(password)) { - const credentials = base64(`${username}:${password}`); - headers['Authorization'] = `Basic ${credentials}`; - } - - if (options.body !== undefined) { - if (options.mediaType) { - headers['Content-Type'] = options.mediaType; - } else if (isBlob(options.body)) { - headers['Content-Type'] = options.body.type || 'application/octet-stream'; - } else if (isString(options.body)) { - headers['Content-Type'] = 'text/plain'; - } else if (!isFormData(options.body)) { - headers['Content-Type'] = 'application/json'; - } - } - - return new Headers(headers); +export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Promise => { + const [token, username, password, additionalHeaders] = await Promise.all([ + // @ts-ignore + resolve(options, config.TOKEN), + // @ts-ignore + resolve(options, config.USERNAME), + // @ts-ignore + resolve(options, config.PASSWORD), + // @ts-ignore + resolve(options, config.HEADERS), + ]); + + const headers = Object.entries({ + Accept: 'application/json', + ...additionalHeaders, + ...options.headers, + }) + .filter(([, value]) => value !== undefined && value !== null) + .reduce((headers, [key, value]) => ({ + ...headers, + [key]: String(value), + }), {} as Record); + + if (isStringWithValue(token)) { + headers['Authorization'] = `Bearer ${token}`; + } + + if (isStringWithValue(username) && isStringWithValue(password)) { + const credentials = base64(`${username}:${password}`); + headers['Authorization'] = `Basic ${credentials}`; + } + + if (options.body !== undefined) { + if (options.mediaType) { + headers['Content-Type'] = options.mediaType; + } else if (isBlob(options.body)) { + headers['Content-Type'] = options.body.type || 'application/octet-stream'; + } else if (isString(options.body)) { + headers['Content-Type'] = 'text/plain'; + } else if (!isFormData(options.body)) { + headers['Content-Type'] = 'application/json'; + } + } + + return new Headers(headers); }; export const getRequestBody = (options: ApiRequestOptions): unknown => { - if (options.body !== undefined) { - if (options.mediaType?.includes('application/json') || options.mediaType?.includes('+json')) { - return JSON.stringify(options.body); - } else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) { - return options.body; - } else { - return JSON.stringify(options.body); - } - } - return undefined; + if (options.body !== undefined) { + if (options.mediaType?.includes('application/json') || options.mediaType?.includes('+json')) { + return JSON.stringify(options.body); + } else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) { + return options.body; + } else { + return JSON.stringify(options.body); + } + } + return undefined; }; export const sendRequest = async ( - config: OpenAPIConfig, - options: ApiRequestOptions, - url: string, - body: any, - formData: FormData | undefined, - headers: Headers, - onCancel: OnCancel + config: OpenAPIConfig, + options: ApiRequestOptions, + url: string, + body: any, + formData: FormData | undefined, + headers: Headers, + onCancel: OnCancel ): Promise => { - const controller = new AbortController(); + const controller = new AbortController(); - let request: RequestInit = { - headers, - body: body ?? formData, - method: options.method, - signal: controller.signal, - }; + let request: RequestInit = { + headers, + body: body ?? formData, + method: options.method, + signal: controller.signal, + }; - if (config.WITH_CREDENTIALS) { - request.credentials = config.CREDENTIALS; - } + if (config.WITH_CREDENTIALS) { + request.credentials = config.CREDENTIALS; + } - for (const fn of config.interceptors.request._fns) { - request = await fn(request); - } + for (const fn of config.interceptors.request._fns) { + request = await fn(request); + } - onCancel(() => controller.abort()); + onCancel(() => controller.abort()); - return await fetch(url, request); + return await fetch(url, request); }; -export const getResponseHeader = ( - response: Response, - responseHeader?: string -): string | undefined => { - if (responseHeader) { - const content = response.headers.get(responseHeader); - if (isString(content)) { - return content; - } - } - return undefined; +export const getResponseHeader = (response: Response, responseHeader?: string): string | undefined => { + if (responseHeader) { + const content = response.headers.get(responseHeader); + if (isString(content)) { + return content; + } + } + return undefined; }; export const getResponseBody = async (response: Response): Promise => { - if (response.status !== 204) { - try { - const contentType = response.headers.get('Content-Type'); - if (contentType) { - const binaryTypes = [ - 'application/octet-stream', - 'application/pdf', - 'application/zip', - 'audio/', - 'image/', - 'video/', - ]; - if (contentType.includes('application/json') || contentType.includes('+json')) { - return await response.json(); - } else if (binaryTypes.some((type) => contentType.includes(type))) { - return await response.blob(); - } else if (contentType.includes('multipart/form-data')) { - return await response.formData(); - } else if (contentType.includes('text/')) { - return await response.text(); - } - } - } catch (error) { - console.error(error); - } - } - return undefined; + if (response.status !== 204) { + try { + const contentType = response.headers.get('Content-Type'); + if (contentType) { + const binaryTypes = ['application/octet-stream', 'application/pdf', 'application/zip', 'audio/', 'image/', 'video/']; + if (contentType.includes('application/json') || contentType.includes('+json')) { + return await response.json(); + } else if (binaryTypes.some(type => contentType.includes(type))) { + return await response.blob(); + } else if (contentType.includes('multipart/form-data')) { + return await response.formData(); + } else if (contentType.includes('text/')) { + return await response.text(); + } + } + } catch (error) { + console.error(error); + } + } + return undefined; }; export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): void => { - const errors: Record = { - 400: 'Bad Request', - 401: 'Unauthorized', - 402: 'Payment Required', - 403: 'Forbidden', - 404: 'Not Found', - 405: 'Method Not Allowed', - 406: 'Not Acceptable', - 407: 'Proxy Authentication Required', - 408: 'Request Timeout', - 409: 'Conflict', - 410: 'Gone', - 411: 'Length Required', - 412: 'Precondition Failed', - 413: 'Payload Too Large', - 414: 'URI Too Long', - 415: 'Unsupported Media Type', - 416: 'Range Not Satisfiable', - 417: 'Expectation Failed', - 418: 'Im a teapot', - 421: 'Misdirected Request', - 422: 'Unprocessable Content', - 423: 'Locked', - 424: 'Failed Dependency', - 425: 'Too Early', - 426: 'Upgrade Required', - 428: 'Precondition Required', - 429: 'Too Many Requests', - 431: 'Request Header Fields Too Large', - 451: 'Unavailable For Legal Reasons', - 500: 'Internal Server Error', - 501: 'Not Implemented', - 502: 'Bad Gateway', - 503: 'Service Unavailable', - 504: 'Gateway Timeout', - 505: 'HTTP Version Not Supported', - 506: 'Variant Also Negotiates', - 507: 'Insufficient Storage', - 508: 'Loop Detected', - 510: 'Not Extended', - 511: 'Network Authentication Required', - ...options.errors, - }; - - const error = errors[result.status]; - if (error) { - throw new ApiError(options, result, error); - } - - if (!result.ok) { - const errorStatus = result.status ?? 'unknown'; - const errorStatusText = result.statusText ?? 'unknown'; - const errorBody = (() => { - try { - return JSON.stringify(result.body, null, 2); - } catch (e) { - return undefined; - } - })(); - - throw new ApiError( - options, - result, - `Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}` - ); - } + const errors: Record = { + 400: 'Bad Request', + 401: 'Unauthorized', + 402: 'Payment Required', + 403: 'Forbidden', + 404: 'Not Found', + 405: 'Method Not Allowed', + 406: 'Not Acceptable', + 407: 'Proxy Authentication Required', + 408: 'Request Timeout', + 409: 'Conflict', + 410: 'Gone', + 411: 'Length Required', + 412: 'Precondition Failed', + 413: 'Payload Too Large', + 414: 'URI Too Long', + 415: 'Unsupported Media Type', + 416: 'Range Not Satisfiable', + 417: 'Expectation Failed', + 418: 'Im a teapot', + 421: 'Misdirected Request', + 422: 'Unprocessable Content', + 423: 'Locked', + 424: 'Failed Dependency', + 425: 'Too Early', + 426: 'Upgrade Required', + 428: 'Precondition Required', + 429: 'Too Many Requests', + 431: 'Request Header Fields Too Large', + 451: 'Unavailable For Legal Reasons', + 500: 'Internal Server Error', + 501: 'Not Implemented', + 502: 'Bad Gateway', + 503: 'Service Unavailable', + 504: 'Gateway Timeout', + 505: 'HTTP Version Not Supported', + 506: 'Variant Also Negotiates', + 507: 'Insufficient Storage', + 508: 'Loop Detected', + 510: 'Not Extended', + 511: 'Network Authentication Required', + ...options.errors, + } + + const error = errors[result.status]; + if (error) { + throw new ApiError(options, result, error); + } + + if (!result.ok) { + const errorStatus = result.status ?? 'unknown'; + const errorStatusText = result.statusText ?? 'unknown'; + const errorBody = (() => { + try { + return JSON.stringify(result.body, null, 2); + } catch (e) { + return undefined; + } + })(); + + throw new ApiError(options, result, + `Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}` + ); + } }; /** @@ -329,46 +308,43 @@ export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): * @returns CancelablePromise * @throws ApiError */ -export const request = ( - config: OpenAPIConfig, - options: ApiRequestOptions -): CancelablePromise => { - return new CancelablePromise(async (resolve, reject, onCancel) => { - try { - const url = getUrl(config, options); - const formData = getFormData(options); - const body = getRequestBody(options); - const headers = await getHeaders(config, options); - - if (!onCancel.isCancelled) { - let response = await sendRequest(config, options, url, body, formData, headers, onCancel); - - for (const fn of config.interceptors.response._fns) { - response = await fn(response); - } - - const responseBody = await getResponseBody(response); - const responseHeader = getResponseHeader(response, options.responseHeader); - - let transformedBody = responseBody; - if (options.responseTransformer && response.ok) { - transformedBody = await options.responseTransformer(responseBody); - } - - const result: ApiResult = { - url, - ok: response.ok, - status: response.status, - statusText: response.statusText, - body: responseHeader ?? transformedBody, - }; - - catchErrorCodes(options, result); - - resolve(result.body); - } - } catch (error) { - reject(error); - } - }); -}; +export const request = (config: OpenAPIConfig, options: ApiRequestOptions): CancelablePromise => { + return new CancelablePromise(async (resolve, reject, onCancel) => { + try { + const url = getUrl(config, options); + const formData = getFormData(options); + const body = getRequestBody(options); + const headers = await getHeaders(config, options); + + if (!onCancel.isCancelled) { + let response = await sendRequest(config, options, url, body, formData, headers, onCancel); + + for (const fn of config.interceptors.response._fns) { + response = await fn(response); + } + + const responseBody = await getResponseBody(response); + const responseHeader = getResponseHeader(response, options.responseHeader); + + let transformedBody = responseBody; + if (options.responseTransformer && response.ok) { + transformedBody = await options.responseTransformer(responseBody) + } + + const result: ApiResult = { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: responseHeader ?? transformedBody, + }; + + catchErrorCodes(options, result); + + resolve(result.body); + } + } catch (error) { + reject(error); + } + }); +}; \ No newline at end of file diff --git a/src/interfaces/coral_web/src/cohere-client/generated/index.ts b/src/interfaces/coral_web/src/cohere-client/generated/index.ts index 6a47401334..591d691f54 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/index.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/index.ts @@ -6,4 +6,4 @@ export { CancelablePromise, CancelError } from './core/CancelablePromise'; export { OpenAPI, type OpenAPIConfig } from './core/OpenAPI'; export * from './schemas.gen'; export * from './services.gen'; -export * from './types.gen'; +export * from './types.gen'; \ No newline at end of file diff --git a/src/interfaces/coral_web/src/cohere-client/generated/schemas.gen.ts b/src/interfaces/coral_web/src/cohere-client/generated/schemas.gen.ts index 9d107ac38f..3b0e3d5f33 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/schemas.gen.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/schemas.gen.ts @@ -1,544 +1,464 @@ // This file is auto-generated by @hey-api/openapi-ts -export const $Agent = { - properties: { - user_id: { - type: 'string', - title: 'User Id', - }, - organization_id: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Organization Id', - }, - id: { - type: 'string', - title: 'Id', - }, - created_at: { - type: 'string', - format: 'date-time', - title: 'Created At', - }, - updated_at: { - type: 'string', - format: 'date-time', - title: 'Updated At', - }, - version: { - type: 'integer', - title: 'Version', - }, - name: { - type: 'string', - title: 'Name', - }, - description: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Description', - }, - preamble: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Preamble', - }, - temperature: { - type: 'number', - title: 'Temperature', - }, - tools: { - items: { - type: 'string', - }, - type: 'array', - title: 'Tools', - }, - tools_metadata: { - anyOf: [ - { - items: { - $ref: '#/components/schemas/AgentToolMetadataPublic', - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: 'Tools Metadata', - }, - model: { - type: 'string', - title: 'Model', - }, - deployment: { - type: 'string', - title: 'Deployment', - }, - }, - type: 'object', - required: [ - 'user_id', - 'id', - 'created_at', - 'updated_at', - 'version', - 'name', - 'description', - 'preamble', - 'temperature', - 'tools', - 'model', - 'deployment', - ], - title: 'Agent', -} as const; - export const $AgentPublic = { - properties: { - user_id: { - type: 'string', - title: 'User Id', - }, - id: { - type: 'string', - title: 'Id', - }, - created_at: { - type: 'string', - format: 'date-time', - title: 'Created At', - }, - updated_at: { - type: 'string', - format: 'date-time', - title: 'Updated At', - }, - version: { - type: 'integer', - title: 'Version', - }, - name: { - type: 'string', - title: 'Name', - }, - description: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Description', - }, - preamble: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Preamble', - }, - temperature: { - type: 'number', - title: 'Temperature', - }, - tools: { - items: { - type: 'string', - }, - type: 'array', - title: 'Tools', - }, - tools_metadata: { - anyOf: [ - { - items: { - $ref: '#/components/schemas/AgentToolMetadataPublic', - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: 'Tools Metadata', - }, - model: { - type: 'string', - title: 'Model', - }, - deployment: { - type: 'string', - title: 'Deployment', - }, - }, - type: 'object', - required: [ - 'user_id', - 'id', - 'created_at', - 'updated_at', - 'version', - 'name', - 'description', - 'preamble', - 'temperature', - 'tools', - 'model', - 'deployment', - ], - title: 'AgentPublic', + properties: { + user_id: { + type: 'string', + title: 'User Id' + }, + id: { + type: 'string', + title: 'Id' + }, + created_at: { + type: 'string', + format: 'date-time', + title: 'Created At' + }, + updated_at: { + type: 'string', + format: 'date-time', + title: 'Updated At' + }, + version: { + type: 'integer', + title: 'Version' + }, + name: { + type: 'string', + title: 'Name' + }, + description: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Description' + }, + preamble: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Preamble' + }, + temperature: { + type: 'number', + title: 'Temperature' + }, + tools: { + anyOf: [ + { + items: { + type: 'string' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'Tools' + }, + tools_metadata: { + anyOf: [ + { + items: { + '$ref': '#/components/schemas/AgentToolMetadataPublic' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'Tools Metadata' + }, + deployments: { + items: { + '$ref': '#/components/schemas/DeploymentWithModels' + }, + type: 'array', + title: 'Deployments' + }, + deployment: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Deployment' + }, + model: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Model' + }, + is_private: { + anyOf: [ + { + type: 'boolean' + }, + { + type: 'null' + } + ], + title: 'Is Private' + } + }, + type: 'object', + required: ['user_id', 'id', 'created_at', 'updated_at', 'version', 'name', 'description', 'preamble', 'temperature', 'tools', 'deployments', 'deployment', 'model', 'is_private'], + title: 'AgentPublic' } as const; export const $AgentToolMetadata = { - properties: { - user_id: { - type: 'string', - title: 'User Id', - }, - organization_id: { - anyOf: [ - { - type: 'string', + properties: { + id: { + type: 'string', + title: 'Id' }, - { - type: 'null', + created_at: { + type: 'string', + format: 'date-time', + title: 'Created At' }, - ], - title: 'Organization Id', - }, - id: { - type: 'string', - title: 'Id', - }, - tool_name: { - type: 'string', - title: 'Tool Name', - }, - artifacts: { - items: { - type: 'object', - }, - type: 'array', - title: 'Artifacts', + updated_at: { + type: 'string', + format: 'date-time', + title: 'Updated At' + }, + user_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'User Id' + }, + agent_id: { + type: 'string', + title: 'Agent Id' + }, + tool_name: { + type: 'string', + title: 'Tool Name' + }, + artifacts: { + items: { + type: 'object' + }, + type: 'array', + title: 'Artifacts' + } }, - }, - type: 'object', - required: ['user_id', 'id', 'tool_name', 'artifacts'], - title: 'AgentToolMetadata', + type: 'object', + required: ['id', 'created_at', 'updated_at', 'user_id', 'agent_id', 'tool_name', 'artifacts'], + title: 'AgentToolMetadata' } as const; export const $AgentToolMetadataPublic = { - properties: { - organization_id: { - anyOf: [ - { - type: 'string', + properties: { + id: { + type: 'string', + title: 'Id' + }, + created_at: { + type: 'string', + format: 'date-time', + title: 'Created At' }, - { - type: 'null', + updated_at: { + type: 'string', + format: 'date-time', + title: 'Updated At' }, - ], - title: 'Organization Id', - }, - id: { - type: 'string', - title: 'Id', - }, - tool_name: { - type: 'string', - title: 'Tool Name', + agent_id: { + type: 'string', + title: 'Agent Id' + }, + tool_name: { + type: 'string', + title: 'Tool Name' + }, + artifacts: { + items: { + type: 'object' + }, + type: 'array', + title: 'Artifacts' + } }, - artifacts: { - items: { - type: 'object', - }, - type: 'array', - title: 'Artifacts', + type: 'object', + required: ['id', 'created_at', 'updated_at', 'agent_id', 'tool_name', 'artifacts'], + title: 'AgentToolMetadataPublic' +} as const; + +export const $AgentVisibility = { + type: 'string', + enum: ['private', 'public', 'all'], + title: 'AgentVisibility' +} as const; + +export const $Body_batch_upload_file_v1_agents_batch_upload_file_post = { + properties: { + files: { + items: { + type: 'string', + format: 'binary' + }, + type: 'array', + title: 'Files' + } }, - }, - type: 'object', - required: ['id', 'tool_name', 'artifacts'], - title: 'AgentToolMetadataPublic', + type: 'object', + required: ['files'], + title: 'Body_batch_upload_file_v1_agents_batch_upload_file_post' } as const; export const $Body_batch_upload_file_v1_conversations_batch_upload_file_post = { - properties: { - conversation_id: { - type: 'string', - title: 'Conversation Id', - }, - files: { - items: { - type: 'string', - format: 'binary', - }, - type: 'array', - title: 'Files', - }, - }, - type: 'object', - required: ['files'], - title: 'Body_batch_upload_file_v1_conversations_batch_upload_file_post', -} as const; - -export const $Body_upload_file_v1_conversations_upload_file_post = { - properties: { - conversation_id: { - type: 'string', - title: 'Conversation Id', - }, - file: { - type: 'string', - format: 'binary', - title: 'File', - }, - }, - type: 'object', - required: ['file'], - title: 'Body_upload_file_v1_conversations_upload_file_post', + properties: { + conversation_id: { + type: 'string', + title: 'Conversation Id' + }, + files: { + items: { + type: 'string', + format: 'binary' + }, + type: 'array', + title: 'Files' + } + }, + type: 'object', + required: ['files'], + title: 'Body_batch_upload_file_v1_conversations_batch_upload_file_post' } as const; export const $Category = { - type: 'string', - enum: ['File loader', 'Data loader', 'Function'], - title: 'Category', + type: 'string', + enum: ['Data loader', 'File loader', 'Function', 'Web search'], + title: 'Category' } as const; export const $ChatMessage = { - properties: { - role: { - allOf: [ - { - $ref: '#/components/schemas/ChatRole', - }, - ], - title: 'One of CHATBOT|USER|SYSTEM to identify who the message is coming from.', - }, - message: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Contents of the chat message.', - }, - tool_plan: { - anyOf: [ - { - type: 'string', + properties: { + role: { + '$ref': '#/components/schemas/ChatRole', + title: 'One of CHATBOT|USER|SYSTEM to identify who the message is coming from.' }, - { - type: 'null', - }, - ], - title: 'Contents of the tool plan.', - }, - tool_results: { - anyOf: [ - { - items: { - type: 'object', - }, - type: 'array', - }, - { - type: 'null', + message: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Contents of the chat message.' }, - ], - title: 'Results from the tool call.', - }, - tool_calls: { - anyOf: [ - { - items: { - type: 'object', - }, - type: 'array', + tool_plan: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Contents of the tool plan.' }, - { - type: 'null', + tool_results: { + anyOf: [ + { + items: { + type: 'object' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'Results from the tool call.' }, - ], - title: 'List of tool calls generated for custom tools', + tool_calls: { + anyOf: [ + { + items: { + type: 'object' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'List of tool calls generated for custom tools' + } }, - }, - type: 'object', - required: ['role'], - title: 'ChatMessage', - description: - "A list of previous messages between the user and the model, meant to give the model conversational context for responding to the user's message.", + type: 'object', + required: ['role'], + title: 'ChatMessage', + description: "A list of previous messages between the user and the model, meant to give the model conversational context for responding to the user's message." } as const; export const $ChatResponseEvent = { - properties: { - event: { - allOf: [ - { - $ref: '#/components/schemas/StreamEvent', - }, - ], - title: 'type of stream event', - }, - data: { - anyOf: [ - { - $ref: '#/components/schemas/StreamStart', + properties: { + event: { + '$ref': '#/components/schemas/StreamEvent', + title: 'type of stream event' }, - { - $ref: '#/components/schemas/StreamTextGeneration', - }, - { - $ref: '#/components/schemas/StreamCitationGeneration', - }, - { - $ref: '#/components/schemas/StreamQueryGeneration', - }, - { - $ref: '#/components/schemas/StreamSearchResults', - }, - { - $ref: '#/components/schemas/StreamEnd', - }, - { - $ref: '#/components/schemas/StreamToolInput', - }, - { - $ref: '#/components/schemas/StreamToolResult', - }, - { - $ref: '#/components/schemas/StreamSearchQueriesGeneration', - }, - { - $ref: '#/components/schemas/StreamToolCallsGeneration', - }, - { - $ref: '#/components/schemas/StreamToolCallsChunk', - }, - { - $ref: '#/components/schemas/NonStreamedChatResponse', - }, - ], - title: 'Data returned from chat response of a given event type', + data: { + anyOf: [ + { + '$ref': '#/components/schemas/StreamStart' + }, + { + '$ref': '#/components/schemas/StreamTextGeneration' + }, + { + '$ref': '#/components/schemas/StreamCitationGeneration' + }, + { + '$ref': '#/components/schemas/StreamQueryGeneration' + }, + { + '$ref': '#/components/schemas/StreamSearchResults' + }, + { + '$ref': '#/components/schemas/StreamEnd' + }, + { + '$ref': '#/components/schemas/StreamToolInput' + }, + { + '$ref': '#/components/schemas/StreamToolResult' + }, + { + '$ref': '#/components/schemas/StreamSearchQueriesGeneration' + }, + { + '$ref': '#/components/schemas/StreamToolCallsGeneration' + }, + { + '$ref': '#/components/schemas/StreamToolCallsChunk' + }, + { + '$ref': '#/components/schemas/NonStreamedChatResponse' + } + ], + title: 'Data returned from chat response of a given event type' + } }, - }, - type: 'object', - required: ['event', 'data'], - title: 'ChatResponseEvent', + type: 'object', + required: ['event', 'data'], + title: 'ChatResponseEvent' } as const; export const $ChatRole = { - type: 'string', - enum: ['CHATBOT', 'USER', 'SYSTEM', 'TOOL'], - title: 'ChatRole', - description: 'One of CHATBOT|USER|SYSTEM to identify who the message is coming from.', + type: 'string', + enum: ['CHATBOT', 'USER', 'SYSTEM', 'TOOL'], + title: 'ChatRole', + description: 'One of CHATBOT|USER|SYSTEM to identify who the message is coming from.' } as const; export const $Citation = { - properties: { - text: { - type: 'string', - title: 'Text', - }, - start: { - type: 'integer', - title: 'Start', - }, - end: { - type: 'integer', - title: 'End', - }, - document_ids: { - items: { - type: 'string', - }, - type: 'array', - title: 'Document Ids', + properties: { + text: { + type: 'string', + title: 'Text' + }, + start: { + type: 'integer', + title: 'Start' + }, + end: { + type: 'integer', + title: 'End' + }, + document_ids: { + items: { + type: 'string' + }, + type: 'array', + title: 'Document Ids' + } }, - }, - type: 'object', - required: ['text', 'start', 'end', 'document_ids'], - title: 'Citation', + type: 'object', + required: ['text', 'start', 'end', 'document_ids'], + title: 'Citation' } as const; export const $CohereChatPromptTruncation = { - type: 'string', - enum: ['OFF', 'AUTO_PRESERVE_ORDER'], - title: 'CohereChatPromptTruncation', - description: 'Dictates how the prompt will be constructed. Defaults to "AUTO_PRESERVE_ORDER".', + type: 'string', + enum: ['OFF', 'AUTO_PRESERVE_ORDER'], + title: 'CohereChatPromptTruncation', + description: 'Dictates how the prompt will be constructed. Defaults to "AUTO_PRESERVE_ORDER".' } as const; export const $CohereChatRequest = { - properties: { - message: { - type: 'string', - title: 'The message to send to the chatbot.', - }, - chat_history: { - anyOf: [ - { - items: { - $ref: '#/components/schemas/ChatMessage', - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: - 'A list of entries used to construct the conversation. If provided, these messages will be used to build the prompt and the conversation_id will be ignored so no data will be stored to maintain state.', - }, - conversation_id: { - type: 'string', - title: - 'To store a conversation then create a conversation id and use it for every related request', - }, - tools: { - anyOf: [ - { - items: { - $ref: '#/components/schemas/Tool', - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: ` + properties: { + message: { + type: 'string', + title: 'The message to send to the chatbot.' + }, + chat_history: { + anyOf: [ + { + items: { + '$ref': '#/components/schemas/ChatMessage' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'A list of entries used to construct the conversation. If provided, these messages will be used to build the prompt and the conversation_id will be ignored so no data will be stored to maintain state.' + }, + conversation_id: { + type: 'string', + title: 'To store a conversation then create a conversation id and use it for every related request' + }, + tools: { + anyOf: [ + { + items: { + '$ref': '#/components/schemas/Tool' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: ` List of custom or managed tools to use for the response. If passing in managed tools, you only need to provide the name of the tool. If passing in custom tools, you need to provide the name, description, and optionally parameter defintions of the tool. - Passing a mix of custom and managed tools is not supported. + Passing a mix of custom and managed tools is not supported. Managed Tools Examples: tools=[ @@ -577,21 +497,21 @@ export const $CohereChatRequest = { "type": "int", "required": true } - } + } }, { "name": "joke_generator", "description": "tool to generate a random joke", } ] - `, - }, - documents: { - items: { - type: 'object', - }, - type: 'array', - title: `Documents to use to generate grounded response with citations. Example: + ` + }, + documents: { + items: { + type: 'object' + }, + type: 'array', + title: `Documents to use to generate grounded response with citations. Example: documents=[ { "id": "national_geographic_everest", @@ -606,2531 +526,3249 @@ export const $CohereChatRequest = { "url": "https://www.nationalgeographic.org/activity/mariana-trench-deepest-place-earth", }, ] - `, - }, - model: { - anyOf: [ - { - type: 'string', + ` }, - { - type: 'null', - }, - ], - title: 'The model to use for generating the response.', - default: 'command-r', - }, - temperature: { - anyOf: [ - { - type: 'number', - minimum: 0, - }, - { - type: 'null', + model: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'The model to use for generating the response.', + default: 'command-r-plus' }, - ], - title: - 'A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations, and higher temperatures mean more random generations.', - }, - k: { - anyOf: [ - { - type: 'integer', - maximum: 500, - minimum: 0, + temperature: { + anyOf: [ + { + type: 'number', + minimum: 0 + }, + { + type: 'null' + } + ], + title: 'A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations, and higher temperatures mean more random generations.' }, - { - type: 'null', - }, - ], - title: - 'Ensures only the top k most likely tokens are considered for generation at each step.', - }, - p: { - anyOf: [ - { - type: 'number', - maximum: 0.99, - minimum: 0, - }, - { - type: 'null', - }, - ], - title: - 'Ensures that only the most likely tokens, with total probability mass of p, are considered for generation at each step. If both k and p are enabled, p acts after k.', - }, - preamble: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'A string to override the preamble.', - }, - file_ids: { - anyOf: [ - { - items: { - type: 'string', - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: 'List of File IDs for PDFs used in RAG for the response.', - }, - search_queries_only: { - anyOf: [ - { - type: 'boolean', - }, - { - type: 'null', - }, - ], - title: - "When set to true a list of search queries are generated. No search will occur nor replies to the user's message.", - default: false, - }, - max_tokens: { - anyOf: [ - { - type: 'integer', - minimum: 1, - }, - { - type: 'null', - }, - ], - title: - 'The maximum number of tokens the model will generate as part of the response. Note: Setting a low value may result in incomplete generations.', - }, - seed: { - anyOf: [ - { - type: 'number', - }, - { - type: 'null', - }, - ], - title: - 'If specified, the backend will make a best effort to sample tokens deterministically, such that repeated requests with the same seed and parameters should return the same result. However, determinism cannot be totally guaranteed.', - }, - stop_sequences: { - anyOf: [ - { - items: { - type: 'string', - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: - 'A list of up to 5 strings that the model will use to stop generation. If the model generates a string that matches any of the strings in the list, it will stop generating tokens and return the generated text up to that point not including the stop sequence.', - }, - presence_penalty: { - anyOf: [ - { - type: 'number', - maximum: 1, - minimum: 0, - }, - { - type: 'null', - }, - ], - title: - 'Used to reduce repetitiveness of generated tokens. Similar to frequency_penalty, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies.', - }, - frequency_penalty: { - anyOf: [ - { - type: 'number', - maximum: 1, - minimum: 0, - }, - { - type: 'null', - }, - ], - title: - 'Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.', - }, - prompt_truncation: { - allOf: [ - { - $ref: '#/components/schemas/CohereChatPromptTruncation', - }, - ], - title: "Dictates how the prompt will be constructed. Defaults to 'AUTO_PRESERVE_ORDER'.", - default: 'AUTO_PRESERVE_ORDER', - }, - tool_results: { - anyOf: [ - { - items: { - type: 'object', - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: - 'A list of results from invoking tools recommended by the model in the previous chat turn. Results are used to produce a text response and will be referenced in citations.', - }, - force_single_step: { - anyOf: [ - { - type: 'boolean', - }, - { - type: 'null', - }, - ], - title: - 'If set to true, the model will generate a single response in a single step. This is useful for generating a response to a single message.', - }, - agent_id: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'The agent ID to use for the chat.', - }, - }, - type: 'object', - required: ['message'], - title: 'CohereChatRequest', - description: `Request shape for Cohere Python SDK Streamed Chat. -See: https://github.com/cohere-ai/cohere-python/blob/main/src/cohere/base_client.py#L1629`, -} as const; - -export const $Conversation = { - properties: { - user_id: { - type: 'string', - title: 'User Id', - }, - organization_id: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Organization Id', - }, - id: { - type: 'string', - title: 'Id', - }, - created_at: { - type: 'string', - format: 'date-time', - title: 'Created At', - }, - updated_at: { - type: 'string', - format: 'date-time', - title: 'Updated At', - }, - title: { - type: 'string', - title: 'Title', - }, - messages: { - items: { - $ref: '#/components/schemas/Message', - }, - type: 'array', - title: 'Messages', - }, - files: { - items: { - $ref: '#/components/schemas/File', - }, - type: 'array', - title: 'Files', - }, - description: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Description', - }, - agent_id: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Agent Id', - }, - total_file_size: { - type: 'integer', - title: 'Total File Size', - readOnly: true, - }, - }, - type: 'object', - required: [ - 'user_id', - 'id', - 'created_at', - 'updated_at', - 'title', - 'messages', - 'files', - 'description', - 'agent_id', - 'total_file_size', - ], - title: 'Conversation', -} as const; - -export const $ConversationWithoutMessages = { - properties: { - user_id: { - type: 'string', - title: 'User Id', - }, - organization_id: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Organization Id', - }, - id: { - type: 'string', - title: 'Id', - }, - created_at: { - type: 'string', - format: 'date-time', - title: 'Created At', - }, - updated_at: { - type: 'string', - format: 'date-time', - title: 'Updated At', - }, - title: { - type: 'string', - title: 'Title', - }, - files: { - items: { - $ref: '#/components/schemas/File', - }, - type: 'array', - title: 'Files', - }, - description: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Description', - }, - agent_id: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Agent Id', - }, - total_file_size: { - type: 'integer', - title: 'Total File Size', - readOnly: true, - }, - }, - type: 'object', - required: [ - 'user_id', - 'id', - 'created_at', - 'updated_at', - 'title', - 'files', - 'description', - 'agent_id', - 'total_file_size', - ], - title: 'ConversationWithoutMessages', -} as const; - -export const $CreateAgent = { - properties: { - name: { - type: 'string', - title: 'Name', - }, - version: { - anyOf: [ - { - type: 'integer', - }, - { - type: 'null', - }, - ], - title: 'Version', - }, - description: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Description', - }, - preamble: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Preamble', - }, - temperature: { - anyOf: [ - { - type: 'number', - }, - { - type: 'null', - }, - ], - title: 'Temperature', - }, - model: { - type: 'string', - title: 'Model', - }, - deployment: { - type: 'string', - title: 'Deployment', - }, - tools: { - anyOf: [ - { - items: { - type: 'string', - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: 'Tools', - }, - tools_metadata: { - anyOf: [ - { - items: { - $ref: '#/components/schemas/CreateAgentToolMetadata', - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: 'Tools Metadata', - }, - }, - type: 'object', - required: ['name', 'model', 'deployment'], - title: 'CreateAgent', -} as const; - -export const $CreateAgentToolMetadata = { - properties: { - id: { - anyOf: [ - { - type: 'string', + k: { + anyOf: [ + { + type: 'integer', + maximum: 500, + minimum: 0 + }, + { + type: 'null' + } + ], + title: 'Ensures only the top k most likely tokens are considered for generation at each step.' }, - { - type: 'null', + p: { + anyOf: [ + { + type: 'number', + maximum: 0.99, + minimum: 0 + }, + { + type: 'null' + } + ], + title: 'Ensures that only the most likely tokens, with total probability mass of p, are considered for generation at each step. If both k and p are enabled, p acts after k.' }, - ], - title: 'Id', - }, - tool_name: { - type: 'string', - title: 'Tool Name', - }, - artifacts: { - items: { - type: 'object', - }, - type: 'array', - title: 'Artifacts', - }, - }, - type: 'object', - required: ['tool_name', 'artifacts'], - title: 'CreateAgentToolMetadata', -} as const; - -export const $CreateSnapshot = { - properties: { - conversation_id: { - type: 'string', - title: 'Conversation Id', - }, - }, - type: 'object', - required: ['conversation_id'], - title: 'CreateSnapshot', -} as const; - -export const $CreateSnapshotResponse = { - properties: { - snapshot_id: { - type: 'string', - title: 'Snapshot Id', - }, - user_id: { - type: 'string', - title: 'User Id', - }, - link_id: { - type: 'string', - title: 'Link Id', - }, - messages: { - items: { - $ref: '#/components/schemas/Message', - }, - type: 'array', - title: 'Messages', - }, - }, - type: 'object', - required: ['snapshot_id', 'user_id', 'link_id', 'messages'], - title: 'CreateSnapshotResponse', -} as const; - -export const $CreateUser = { - properties: { - password: { - anyOf: [ - { - type: 'string', + preamble: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'A string to override the preamble.' }, - { - type: 'null', + file_ids: { + anyOf: [ + { + items: { + type: 'string' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'List of File IDs for PDFs used in RAG for the response.' }, - ], - title: 'Password', - }, - hashed_password: { - anyOf: [ - { - type: 'string', - format: 'binary', + search_queries_only: { + anyOf: [ + { + type: 'boolean' + }, + { + type: 'null' + } + ], + title: "When set to true a list of search queries are generated. No search will occur nor replies to the user's message.", + default: false }, - { - type: 'null', + max_tokens: { + anyOf: [ + { + type: 'integer', + minimum: 1 + }, + { + type: 'null' + } + ], + title: 'The maximum number of tokens the model will generate as part of the response. Note: Setting a low value may result in incomplete generations.' }, - ], - title: 'Hashed Password', - }, - fullname: { - type: 'string', - title: 'Fullname', - }, - email: { - anyOf: [ - { - type: 'string', + seed: { + anyOf: [ + { + type: 'number' + }, + { + type: 'null' + } + ], + title: 'If specified, the backend will make a best effort to sample tokens deterministically, such that repeated requests with the same seed and parameters should return the same result. However, determinism cannot be totally guaranteed.' }, - { - type: 'null', + stop_sequences: { + anyOf: [ + { + items: { + type: 'string' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'A list of up to 5 strings that the model will use to stop generation. If the model generates a string that matches any of the strings in the list, it will stop generating tokens and return the generated text up to that point not including the stop sequence.' }, - ], - title: 'Email', - }, - }, - type: 'object', - required: ['fullname'], - title: 'CreateUser', -} as const; - -export const $DeleteAgent = { - properties: {}, - type: 'object', - title: 'DeleteAgent', -} as const; - -export const $DeleteAgentToolMetadata = { - properties: {}, - type: 'object', - title: 'DeleteAgentToolMetadata', -} as const; - -export const $DeleteConversation = { - properties: {}, - type: 'object', - title: 'DeleteConversation', -} as const; - -export const $DeleteFile = { - properties: {}, - type: 'object', - title: 'DeleteFile', -} as const; - -export const $DeleteUser = { - properties: {}, - type: 'object', - title: 'DeleteUser', -} as const; - -export const $Deployment = { - properties: { - name: { - type: 'string', - title: 'Name', - }, - models: { - items: { - type: 'string', - }, - type: 'array', - title: 'Models', - }, - is_available: { - type: 'boolean', - title: 'Is Available', + presence_penalty: { + anyOf: [ + { + type: 'number', + maximum: 1, + minimum: 0 + }, + { + type: 'null' + } + ], + title: 'Used to reduce repetitiveness of generated tokens. Similar to frequency_penalty, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies.' + }, + frequency_penalty: { + anyOf: [ + { + type: 'number', + maximum: 1, + minimum: 0 + }, + { + type: 'null' + } + ], + title: 'Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.' + }, + prompt_truncation: { + '$ref': '#/components/schemas/CohereChatPromptTruncation', + title: "Dictates how the prompt will be constructed. Defaults to 'AUTO_PRESERVE_ORDER'.", + default: 'AUTO_PRESERVE_ORDER' + }, + tool_results: { + anyOf: [ + { + items: { + type: 'object' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'A list of results from invoking tools recommended by the model in the previous chat turn. Results are used to produce a text response and will be referenced in citations.' + }, + force_single_step: { + anyOf: [ + { + type: 'boolean' + }, + { + type: 'null' + } + ], + title: 'If set to true, the model will generate a single response in a single step. This is useful for generating a response to a single message.' + }, + agent_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'The agent ID to use for the chat.' + } + }, + type: 'object', + required: ['message'], + title: 'CohereChatRequest', + description: `Request shape for Cohere Python SDK Streamed Chat. +See: https://github.com/cohere-ai/cohere-python/blob/main/src/cohere/base_client.py#L1629` +} as const; + +export const $ConversationFilePublic = { + properties: { + id: { + type: 'string', + title: 'Id' + }, + user_id: { + type: 'string', + title: 'User Id' + }, + created_at: { + type: 'string', + format: 'date-time', + title: 'Created At' + }, + updated_at: { + type: 'string', + format: 'date-time', + title: 'Updated At' + }, + conversation_id: { + type: 'string', + title: 'Conversation Id' + }, + file_name: { + type: 'string', + title: 'File Name' + }, + file_size: { + type: 'integer', + minimum: 0, + title: 'File Size', + default: 0 + } + }, + type: 'object', + required: ['id', 'user_id', 'created_at', 'updated_at', 'conversation_id', 'file_name'], + title: 'ConversationFilePublic' +} as const; + +export const $ConversationPublic = { + properties: { + id: { + type: 'string', + title: 'Id' + }, + created_at: { + type: 'string', + format: 'date-time', + title: 'Created At' + }, + updated_at: { + type: 'string', + format: 'date-time', + title: 'Updated At' + }, + title: { + type: 'string', + title: 'Title' + }, + messages: { + items: { + '$ref': '#/components/schemas/Message' + }, + type: 'array', + title: 'Messages' + }, + files: { + items: { + '$ref': '#/components/schemas/ConversationFilePublic' + }, + type: 'array', + title: 'Files' + }, + description: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Description' + }, + agent_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Agent Id' + }, + is_pinned: { + type: 'boolean', + title: 'Is Pinned' + }, + total_file_size: { + type: 'integer', + title: 'Total File Size', + readOnly: true + } + }, + type: 'object', + required: ['id', 'created_at', 'updated_at', 'title', 'messages', 'files', 'description', 'agent_id', 'is_pinned', 'total_file_size'], + title: 'ConversationPublic' +} as const; + +export const $ConversationWithoutMessages = { + properties: { + id: { + type: 'string', + title: 'Id' + }, + created_at: { + type: 'string', + format: 'date-time', + title: 'Created At' + }, + updated_at: { + type: 'string', + format: 'date-time', + title: 'Updated At' + }, + title: { + type: 'string', + title: 'Title' + }, + files: { + items: { + '$ref': '#/components/schemas/ConversationFilePublic' + }, + type: 'array', + title: 'Files' + }, + description: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Description' + }, + agent_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Agent Id' + }, + is_pinned: { + type: 'boolean', + title: 'Is Pinned' + }, + total_file_size: { + type: 'integer', + title: 'Total File Size', + readOnly: true + } + }, + type: 'object', + required: ['id', 'created_at', 'updated_at', 'title', 'files', 'description', 'agent_id', 'is_pinned', 'total_file_size'], + title: 'ConversationWithoutMessages' +} as const; + +export const $CreateAgentRequest = { + properties: { + name: { + type: 'string', + title: 'Name' + }, + version: { + anyOf: [ + { + type: 'integer' + }, + { + type: 'null' + } + ], + title: 'Version' + }, + description: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Description' + }, + preamble: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Preamble' + }, + temperature: { + anyOf: [ + { + type: 'number' + }, + { + type: 'null' + } + ], + title: 'Temperature' + }, + tools: { + anyOf: [ + { + items: { + type: 'string' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'Tools' + }, + tools_metadata: { + anyOf: [ + { + items: { + '$ref': '#/components/schemas/CreateAgentToolMetadataRequest' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'Tools Metadata' + }, + deployment_config: { + anyOf: [ + { + additionalProperties: { + type: 'string' + }, + type: 'object' + }, + { + type: 'null' + } + ], + title: 'Deployment Config' + }, + is_default_deployment: { + anyOf: [ + { + type: 'boolean' + }, + { + type: 'null' + } + ], + title: 'Is Default Deployment', + default: false + }, + model: { + type: 'string', + title: 'Model' + }, + deployment: { + type: 'string', + title: 'Deployment' + }, + organization_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Organization Id' + }, + is_private: { + anyOf: [ + { + type: 'boolean' + }, + { + type: 'null' + } + ], + title: 'Is Private', + default: false + } + }, + type: 'object', + required: ['name', 'model', 'deployment'], + title: 'CreateAgentRequest' +} as const; + +export const $CreateAgentToolMetadataRequest = { + properties: { + id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Id' + }, + tool_name: { + type: 'string', + title: 'Tool Name' + }, + artifacts: { + items: { + type: 'object' + }, + type: 'array', + title: 'Artifacts' + } + }, + type: 'object', + required: ['tool_name', 'artifacts'], + title: 'CreateAgentToolMetadataRequest' +} as const; + +export const $CreateGroup = { + properties: { + schemas: { + items: { + type: 'string' + }, + type: 'array', + title: 'Schemas' + }, + members: { + items: { + '$ref': '#/components/schemas/GroupMember' + }, + type: 'array', + title: 'Members' + }, + displayName: { + type: 'string', + title: 'Displayname' + } + }, + type: 'object', + required: ['schemas', 'members', 'displayName'], + title: 'CreateGroup' +} as const; + +export const $CreateOrganization = { + properties: { + name: { + type: 'string', + title: 'Name' + } + }, + type: 'object', + required: ['name'], + title: 'CreateOrganization' +} as const; + +export const $CreateSnapshotRequest = { + properties: { + conversation_id: { + type: 'string', + title: 'Conversation Id' + } + }, + type: 'object', + required: ['conversation_id'], + title: 'CreateSnapshotRequest' +} as const; + +export const $CreateSnapshotResponse = { + properties: { + snapshot_id: { + type: 'string', + title: 'Snapshot Id' + }, + link_id: { + type: 'string', + title: 'Link Id' + }, + messages: { + items: { + '$ref': '#/components/schemas/Message' + }, + type: 'array', + title: 'Messages' + } + }, + type: 'object', + required: ['snapshot_id', 'link_id', 'messages'], + title: 'CreateSnapshotResponse' +} as const; + +export const $DeleteAgent = { + properties: {}, + type: 'object', + title: 'DeleteAgent' +} as const; + +export const $DeleteAgentFileResponse = { + properties: {}, + type: 'object', + title: 'DeleteAgentFileResponse' +} as const; + +export const $DeleteAgentToolMetadata = { + properties: {}, + type: 'object', + title: 'DeleteAgentToolMetadata' +} as const; + +export const $DeleteConversationFileResponse = { + properties: {}, + type: 'object', + title: 'DeleteConversationFileResponse' +} as const; + +export const $DeleteConversationResponse = { + properties: {}, + type: 'object', + title: 'DeleteConversationResponse' +} as const; + +export const $DeleteDeployment = { + properties: {}, + type: 'object', + title: 'DeleteDeployment' +} as const; + +export const $DeleteModel = { + properties: {}, + type: 'object', + title: 'DeleteModel' +} as const; + +export const $DeleteOrganization = { + properties: {}, + type: 'object', + title: 'DeleteOrganization' +} as const; + +export const $DeleteSnapshotLinkResponse = { + properties: {}, + type: 'object', + title: 'DeleteSnapshotLinkResponse' +} as const; + +export const $DeleteSnapshotResponse = { + properties: {}, + type: 'object', + title: 'DeleteSnapshotResponse' +} as const; + +export const $DeleteToolAuth = { + properties: {}, + type: 'object', + title: 'DeleteToolAuth' +} as const; + +export const $DeleteUser = { + properties: {}, + type: 'object', + title: 'DeleteUser' +} as const; + +export const $DeploymentCreate = { + properties: { + id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Id' + }, + name: { + type: 'string', + title: 'Name' + }, + description: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Description' + }, + deployment_class_name: { + type: 'string', + title: 'Deployment Class Name' + }, + is_community: { + type: 'boolean', + title: 'Is Community', + default: false + }, + default_deployment_config: { + additionalProperties: { + type: 'string' + }, + type: 'object', + title: 'Default Deployment Config' + } + }, + type: 'object', + required: ['name', 'deployment_class_name', 'default_deployment_config'], + title: 'DeploymentCreate' +} as const; + +export const $DeploymentDefinition = { + properties: { + id: { + type: 'string', + title: 'Id' + }, + name: { + type: 'string', + title: 'Name' + }, + description: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Description' + }, + config: { + additionalProperties: { + type: 'string' + }, + type: 'object', + title: 'Config', + default: {} + }, + is_available: { + type: 'boolean', + title: 'Is Available', + default: false + }, + is_community: { + type: 'boolean', + title: 'Is Community', + default: false + }, + models: { + items: { + type: 'string' + }, + type: 'array', + title: 'Models' + } + }, + type: 'object', + required: ['id', 'name', 'models'], + title: 'DeploymentDefinition' +} as const; + +export const $DeploymentUpdate = { + properties: { + name: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Name' + }, + description: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Description' + }, + deployment_class_name: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Deployment Class Name' + }, + is_community: { + anyOf: [ + { + type: 'boolean' + }, + { + type: 'null' + } + ], + title: 'Is Community' + }, + default_deployment_config: { + anyOf: [ + { + additionalProperties: { + type: 'string' + }, + type: 'object' + }, + { + type: 'null' + } + ], + title: 'Default Deployment Config' + } + }, + type: 'object', + title: 'DeploymentUpdate' +} as const; + +export const $DeploymentWithModels = { + properties: { + id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Id' + }, + name: { + type: 'string', + title: 'Name' + }, + description: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Description' + }, + env_vars: { + anyOf: [ + { + items: { + type: 'string' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'Env Vars' + }, + is_available: { + type: 'boolean', + title: 'Is Available', + default: false + }, + is_community: { + anyOf: [ + { + type: 'boolean' + }, + { + type: 'null' + } + ], + title: 'Is Community', + default: false + }, + models: { + items: { + '$ref': '#/components/schemas/ModelSimple' + }, + type: 'array', + title: 'Models' + } + }, + type: 'object', + required: ['name', 'env_vars', 'models'], + title: 'DeploymentWithModels' +} as const; + +export const $Document = { + properties: { + text: { + type: 'string', + title: 'Text' + }, + document_id: { + type: 'string', + title: 'Document Id' + }, + title: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Title' + }, + url: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Url' + }, + fields: { + anyOf: [ + { + type: 'object' + }, + { + type: 'null' + } + ], + title: 'Fields' + }, + tool_name: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Tool Name' + } + }, + type: 'object', + required: ['text', 'document_id', 'title', 'url', 'fields', 'tool_name'], + title: 'Document' +} as const; + +export const $Email = { + properties: { + primary: { + type: 'boolean', + title: 'Primary' + }, + value: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Value' + }, + type: { + type: 'string', + title: 'Type' + } }, - env_vars: { - items: { - type: 'string', - }, - type: 'array', - title: 'Env Vars', + type: 'object', + required: ['primary', 'type'], + title: 'Email' +} as const; + +export const $GenerateTitleResponse = { + properties: { + title: { + type: 'string', + title: 'Title' + }, + error: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Error' + } + }, + type: 'object', + required: ['title'], + title: 'GenerateTitleResponse' +} as const; + +export const $Group = { + properties: { + schemas: { + items: { + type: 'string' + }, + type: 'array', + title: 'Schemas' + }, + members: { + items: { + '$ref': '#/components/schemas/GroupMember' + }, + type: 'array', + title: 'Members' + }, + displayName: { + type: 'string', + title: 'Displayname' + }, + id: { + type: 'string', + title: 'Id' + }, + meta: { + '$ref': '#/components/schemas/Meta' + } }, - }, - type: 'object', - required: ['name', 'models', 'is_available', 'env_vars'], - title: 'Deployment', + type: 'object', + required: ['schemas', 'members', 'displayName', 'id', 'meta'], + title: 'Group' } as const; -export const $Document = { - properties: { - text: { - type: 'string', - title: 'Text', - }, - document_id: { - type: 'string', - title: 'Document Id', - }, - title: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Title', - }, - url: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Url', - }, - fields: { - anyOf: [ - { - type: 'object', - }, - { - type: 'null', - }, - ], - title: 'Fields', - }, - tool_name: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Tool Name', - }, - }, - type: 'object', - required: ['text', 'document_id', 'title', 'url', 'fields', 'tool_name'], - title: 'Document', -} as const; - -export const $File = { - properties: { - id: { - type: 'string', - title: 'Id', - }, - created_at: { - type: 'string', - format: 'date-time', - title: 'Created At', - }, - updated_at: { - type: 'string', - format: 'date-time', - title: 'Updated At', - }, - user_id: { - type: 'string', - title: 'User Id', - }, - conversation_id: { - type: 'string', - title: 'Conversation Id', - }, - file_name: { - type: 'string', - title: 'File Name', - }, - file_path: { - type: 'string', - title: 'File Path', - }, - file_size: { - type: 'integer', - minimum: 0, - title: 'File Size', - default: 0, - }, - }, - type: 'object', - required: [ - 'id', - 'created_at', - 'updated_at', - 'user_id', - 'conversation_id', - 'file_name', - 'file_path', - ], - title: 'File', -} as const; - -export const $GenerateTitle = { - properties: { - title: { - type: 'string', - title: 'Title', +export const $GroupMember = { + properties: { + value: { + type: 'string', + title: 'Value' + }, + display: { + type: 'string', + title: 'Display' + } + }, + type: 'object', + required: ['value', 'display'], + title: 'GroupMember' +} as const; + +export const $GroupOperation = { + properties: { + op: { + type: 'string', + title: 'Op' + }, + path: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Path' + }, + value: { + anyOf: [ + { + additionalProperties: { + type: 'string' + }, + type: 'object' + }, + { + items: { + additionalProperties: { + type: 'string' + }, + type: 'object' + }, + type: 'array' + } + ], + title: 'Value' + } }, - }, - type: 'object', - required: ['title'], - title: 'GenerateTitle', -} as const; - -export const $GenericResponseMessage = { - properties: { - message: { - type: 'string', - title: 'Message', - }, - }, - type: 'object', - required: ['message'], - title: 'GenericResponseMessage', + type: 'object', + required: ['op', 'value'], + title: 'GroupOperation' } as const; export const $HTTPValidationError = { - properties: { - detail: { - items: { - $ref: '#/components/schemas/ValidationError', - }, - type: 'array', - title: 'Detail', + properties: { + detail: { + items: { + '$ref': '#/components/schemas/ValidationError' + }, + type: 'array', + title: 'Detail' + } + }, + type: 'object', + title: 'HTTPValidationError' +} as const; + +export const $JWTResponse = { + properties: { + token: { + type: 'string', + title: 'Token' + } + }, + type: 'object', + required: ['token'], + title: 'JWTResponse' +} as const; + +export const $ListAuthStrategy = { + properties: { + strategy: { + type: 'string', + title: 'Strategy' + }, + client_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Client Id' + }, + authorization_endpoint: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Authorization Endpoint' + }, + pkce_enabled: { + type: 'boolean', + title: 'Pkce Enabled' + } + }, + type: 'object', + required: ['strategy', 'client_id', 'authorization_endpoint', 'pkce_enabled'], + title: 'ListAuthStrategy' +} as const; + +export const $ListConversationFile = { + properties: { + id: { + type: 'string', + title: 'Id' + }, + user_id: { + type: 'string', + title: 'User Id' + }, + created_at: { + type: 'string', + format: 'date-time', + title: 'Created At' + }, + updated_at: { + type: 'string', + format: 'date-time', + title: 'Updated At' + }, + conversation_id: { + type: 'string', + title: 'Conversation Id' + }, + file_name: { + type: 'string', + title: 'File Name' + }, + file_size: { + type: 'integer', + minimum: 0, + title: 'File Size', + default: 0 + } + }, + type: 'object', + required: ['id', 'user_id', 'created_at', 'updated_at', 'conversation_id', 'file_name'], + title: 'ListConversationFile' +} as const; + +export const $ListGroupResponse = { + properties: { + totalResults: { + type: 'integer', + title: 'Totalresults' + }, + startIndex: { + type: 'integer', + title: 'Startindex' + }, + itemsPerPage: { + type: 'integer', + title: 'Itemsperpage' + }, + Resources: { + items: { + '$ref': '#/components/schemas/Group' + }, + type: 'array', + title: 'Resources' + } + }, + type: 'object', + required: ['totalResults', 'startIndex', 'itemsPerPage', 'Resources'], + title: 'ListGroupResponse' +} as const; + +export const $ListUserResponse = { + properties: { + totalResults: { + type: 'integer', + title: 'Totalresults' + }, + startIndex: { + type: 'integer', + title: 'Startindex' + }, + itemsPerPage: { + type: 'integer', + title: 'Itemsperpage' + }, + Resources: { + items: { + '$ref': '#/components/schemas/backend__schemas__scim__User' + }, + type: 'array', + title: 'Resources' + } + }, + type: 'object', + required: ['totalResults', 'startIndex', 'itemsPerPage', 'Resources'], + title: 'ListUserResponse' +} as const; + +export const $Login = { + properties: { + strategy: { + type: 'string', + title: 'Strategy' + }, + payload: { + anyOf: [ + { + additionalProperties: { + type: 'string' + }, + type: 'object' + }, + { + type: 'null' + } + ], + title: 'Payload' + } + }, + type: 'object', + required: ['strategy'], + title: 'Login' +} as const; + +export const $Logout = { + properties: {}, + type: 'object', + title: 'Logout' +} as const; + +export const $ManagedTool = { + properties: { + name: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Name', + default: '' + }, + display_name: { + type: 'string', + title: 'Display Name', + default: '' + }, + description: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Description', + default: '' + }, + parameter_definitions: { + anyOf: [ + { + type: 'object' + }, + { + type: 'null' + } + ], + title: 'Parameter Definitions', + default: {} + }, + kwargs: { + type: 'object', + title: 'Kwargs', + default: {} + }, + is_visible: { + type: 'boolean', + title: 'Is Visible', + default: false + }, + is_available: { + type: 'boolean', + title: 'Is Available', + default: false + }, + error_message: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Error Message', + default: '' + }, + category: { + '$ref': '#/components/schemas/Category', + default: 'Data loader' + }, + is_auth_required: { + type: 'boolean', + title: 'Is Auth Required', + default: false + }, + auth_url: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Auth Url', + default: '' + }, + token: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Token', + default: '' + } + }, + type: 'object', + title: 'ManagedTool' +} as const; + +export const $Message = { + properties: { + text: { + type: 'string', + title: 'Text' + }, + id: { + type: 'string', + title: 'Id' + }, + created_at: { + type: 'string', + format: 'date-time', + title: 'Created At' + }, + updated_at: { + type: 'string', + format: 'date-time', + title: 'Updated At' + }, + generation_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Generation Id' + }, + position: { + type: 'integer', + title: 'Position' + }, + is_active: { + type: 'boolean', + title: 'Is Active' + }, + documents: { + items: { + '$ref': '#/components/schemas/Document' + }, + type: 'array', + title: 'Documents' + }, + citations: { + items: { + '$ref': '#/components/schemas/Citation' + }, + type: 'array', + title: 'Citations' + }, + files: { + items: { + '$ref': '#/components/schemas/ConversationFilePublic' + }, + type: 'array', + title: 'Files' + }, + tool_calls: { + items: { + '$ref': '#/components/schemas/ToolCall' + }, + type: 'array', + title: 'Tool Calls' + }, + tool_plan: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Tool Plan' + }, + agent: { + '$ref': '#/components/schemas/MessageAgent' + } + }, + type: 'object', + required: ['text', 'id', 'created_at', 'updated_at', 'generation_id', 'position', 'is_active', 'documents', 'citations', 'files', 'tool_calls', 'tool_plan', 'agent'], + title: 'Message' +} as const; + +export const $MessageAgent = { + type: 'string', + enum: ['USER', 'CHATBOT'], + title: 'MessageAgent' +} as const; + +export const $Meta = { + properties: { + resourceType: { + type: 'string', + title: 'Resourcetype' + }, + created: { + type: 'string', + title: 'Created' + }, + lastModified: { + type: 'string', + title: 'Lastmodified' + } + }, + type: 'object', + required: ['resourceType', 'created', 'lastModified'], + title: 'Meta' +} as const; + +export const $Model = { + properties: { + id: { + type: 'string', + title: 'Id' + }, + name: { + type: 'string', + title: 'Name' + }, + deployment_id: { + type: 'string', + title: 'Deployment Id' + }, + cohere_name: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Cohere Name' + }, + description: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Description' + } + }, + type: 'object', + required: ['id', 'name', 'deployment_id', 'cohere_name', 'description'], + title: 'Model' +} as const; + +export const $ModelCreate = { + properties: { + name: { + type: 'string', + title: 'Name' + }, + cohere_name: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Cohere Name' + }, + description: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Description' + }, + deployment_id: { + type: 'string', + title: 'Deployment Id' + } + }, + type: 'object', + required: ['name', 'cohere_name', 'description', 'deployment_id'], + title: 'ModelCreate' +} as const; + +export const $ModelSimple = { + properties: { + id: { + type: 'string', + title: 'Id' + }, + name: { + type: 'string', + title: 'Name' + }, + cohere_name: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Cohere Name' + }, + description: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Description' + } }, - }, - type: 'object', - title: 'HTTPValidationError', + type: 'object', + required: ['id', 'name', 'cohere_name', 'description'], + title: 'ModelSimple' } as const; -export const $JWTResponse = { - properties: { - token: { - type: 'string', - title: 'Token', - }, - }, - type: 'object', - required: ['token'], - title: 'JWTResponse', -} as const; - -export const $LangchainChatRequest = { - properties: { - message: { - type: 'string', - title: 'The message to send to the chatbot.', - }, - chat_history: { - anyOf: [ - { - items: { - $ref: '#/components/schemas/ChatMessage', - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: - 'A list of entries used to construct the conversation. If provided, these messages will be used to build the prompt and the conversation_id will be ignored so no data will be stored to maintain state.', - }, - conversation_id: { - type: 'string', - title: - 'To store a conversation then create a conversation id and use it for every related request', - }, - tools: { - anyOf: [ - { - items: { - $ref: '#/components/schemas/Tool', - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: ` - List of custom or managed tools to use for the response. - If passing in managed tools, you only need to provide the name of the tool. - If passing in custom tools, you need to provide the name, description, and optionally parameter defintions of the tool. - Passing a mix of custom and managed tools is not supported. - - Managed Tools Examples: - tools=[ +export const $ModelUpdate = { + properties: { + name: { + anyOf: [ { - "name": "Wiki Retriever - LangChain", + type: 'string' }, { - "name": "Calculator", + type: 'null' } - ] - - Custom Tools Examples: - tools=[ + ], + title: 'Name' + }, + cohere_name: { + anyOf: [ { - "name": "movie_title_generator", - "description": "tool to generate a cool movie title", - "parameter_definitions": { - "synopsis": { - "description": "short synopsis of the movie", - "type": "str", - "required": true - } - } + type: 'string' }, { - "name": "random_number_generator", - "description": "tool to generate a random number between min and max", - "parameter_definitions": { - "min": { - "description": "minimum number", - "type": "int", - "required": true - }, - "max": { - "description": "maximum number", - "type": "int", - "required": true - } - } + type: 'null' + } + ], + title: 'Cohere Name' + }, + description: { + anyOf: [ + { + type: 'string' }, { - "name": "joke_generator", - "description": "tool to generate a random joke", + type: 'null' } - ] - `, + ], + title: 'Description' + }, + deployment_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Deployment Id' + } }, - }, - type: 'object', - required: ['message'], - title: 'LangchainChatRequest', - description: 'Request shape for Langchain Streamed Chat.', + type: 'object', + title: 'ModelUpdate' } as const; -export const $ListAuthStrategy = { - properties: { - strategy: { - type: 'string', - title: 'Strategy', - }, - client_id: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Client Id', - }, - authorization_endpoint: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Authorization Endpoint', - }, - pkce_enabled: { - type: 'boolean', - title: 'Pkce Enabled', - }, - }, - type: 'object', - required: ['strategy', 'client_id', 'authorization_endpoint', 'pkce_enabled'], - title: 'ListAuthStrategy', -} as const; - -export const $ListFile = { - properties: { - id: { - type: 'string', - title: 'Id', - }, - created_at: { - type: 'string', - format: 'date-time', - title: 'Created At', - }, - updated_at: { - type: 'string', - format: 'date-time', - title: 'Updated At', - }, - user_id: { - type: 'string', - title: 'User Id', - }, - conversation_id: { - type: 'string', - title: 'Conversation Id', - }, - file_name: { - type: 'string', - title: 'File Name', - }, - file_path: { - type: 'string', - title: 'File Path', - }, - file_size: { - type: 'integer', - minimum: 0, - title: 'File Size', - default: 0, - }, - }, - type: 'object', - required: [ - 'id', - 'created_at', - 'updated_at', - 'user_id', - 'conversation_id', - 'file_name', - 'file_path', - ], - title: 'ListFile', -} as const; - -export const $Login = { - properties: { - strategy: { - type: 'string', - title: 'Strategy', - }, - payload: { - anyOf: [ - { - additionalProperties: { +export const $Name = { + properties: { + givenName: { type: 'string', - }, - type: 'object', - }, - { - type: 'null', + title: 'Givenname' }, - ], - title: 'Payload', + familyName: { + type: 'string', + title: 'Familyname' + } }, - }, - type: 'object', - required: ['strategy'], - title: 'Login', -} as const; - -export const $Logout = { - properties: {}, - type: 'object', - title: 'Logout', + type: 'object', + required: ['givenName', 'familyName'], + title: 'Name' } as const; -export const $ManagedTool = { - properties: { - name: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Name', - default: '', - }, - display_name: { - type: 'string', - title: 'Display Name', - default: '', - }, - description: { - anyOf: [ - { - type: 'string', +export const $NonStreamedChatResponse = { + properties: { + response_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Unique identifier for the response.' }, - { - type: 'null', + generation_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Unique identifier for the generation.' }, - ], - title: 'Description', - default: '', - }, - parameter_definitions: { - anyOf: [ - { - type: 'object', + chat_history: { + anyOf: [ + { + items: { + '$ref': '#/components/schemas/ChatMessage' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: "A list of previous messages between the user and the model, meant to give the model conversational context for responding to the user's message." }, - { - type: 'null', + finish_reason: { + type: 'string', + title: 'Reason the chat stream ended.' }, - ], - title: 'Parameter Definitions', - default: {}, - }, - kwargs: { - type: 'object', - title: 'Kwargs', - default: {}, - }, - is_visible: { - type: 'boolean', - title: 'Is Visible', - default: false, - }, - is_available: { - type: 'boolean', - title: 'Is Available', - default: false, - }, - error_message: { - anyOf: [ - { - type: 'string', + text: { + type: 'string', + title: 'Contents of the chat message.' }, - { - type: 'null', + citations: { + anyOf: [ + { + items: { + '$ref': '#/components/schemas/Citation' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'Citations for the chat message.', + default: [] }, - ], - title: 'Error Message', - default: '', - }, - category: { - allOf: [ - { - $ref: '#/components/schemas/Category', + documents: { + anyOf: [ + { + items: { + '$ref': '#/components/schemas/Document' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'Documents used to generate grounded response with citations.', + default: [] }, - ], - default: 'Data loader', - }, - is_auth_required: { - type: 'boolean', - title: 'Is Auth Required', - default: false, - }, - auth_url: { - anyOf: [ - { - type: 'string', + search_results: { + anyOf: [ + { + items: { + type: 'object' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'Search results used to generate grounded response with citations.', + default: [] }, - { - type: 'null', + search_queries: { + anyOf: [ + { + items: { + '$ref': '#/components/schemas/SearchQuery' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'List of generated search queries.', + default: [] }, - ], - title: 'Auth Url', - default: '', - }, - token: { - anyOf: [ - { - type: 'string', + conversation_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'To store a conversation then create a conversation id and use it for every related request.' }, - { - type: 'null', + tool_calls: { + anyOf: [ + { + items: { + '$ref': '#/components/schemas/ToolCall' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'List of tool calls generated for custom tools', + default: [] }, - ], - title: 'Token', - default: '', + error: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Error message if the response is an error.' + } }, - }, - type: 'object', - title: 'ManagedTool', -} as const; - -export const $Message = { - properties: { - text: { - type: 'string', - title: 'Text', - }, - id: { - type: 'string', - title: 'Id', - }, - created_at: { - type: 'string', - format: 'date-time', - title: 'Created At', - }, - updated_at: { - type: 'string', - format: 'date-time', - title: 'Updated At', - }, - generation_id: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Generation Id', - }, - position: { - type: 'integer', - title: 'Position', - }, - is_active: { - type: 'boolean', - title: 'Is Active', - }, - documents: { - items: { - $ref: '#/components/schemas/Document', - }, - type: 'array', - title: 'Documents', - }, - citations: { - items: { - $ref: '#/components/schemas/Citation', - }, - type: 'array', - title: 'Citations', - }, - files: { - items: { - $ref: '#/components/schemas/File', - }, - type: 'array', - title: 'Files', - }, - tool_calls: { - items: { - $ref: '#/components/schemas/ToolCall', - }, - type: 'array', - title: 'Tool Calls', - }, - tool_plan: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Tool Plan', - }, - agent: { - $ref: '#/components/schemas/MessageAgent', - }, - }, - type: 'object', - required: [ - 'text', - 'id', - 'created_at', - 'updated_at', - 'generation_id', - 'position', - 'is_active', - 'documents', - 'citations', - 'files', - 'tool_calls', - 'tool_plan', - 'agent', - ], - title: 'Message', + type: 'object', + required: ['response_id', 'generation_id', 'chat_history', 'finish_reason', 'text', 'conversation_id'], + title: 'NonStreamedChatResponse' } as const; -export const $MessageAgent = { - type: 'string', - enum: ['USER', 'CHATBOT'], - title: 'MessageAgent', +export const $Operation = { + properties: { + op: { + type: 'string', + title: 'Op' + }, + value: { + additionalProperties: { + type: 'boolean' + }, + type: 'object', + title: 'Value' + } + }, + type: 'object', + required: ['op', 'value'], + title: 'Operation' } as const; -export const $NonStreamedChatResponse = { - properties: { - response_id: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Unique identifier for the response.', - }, - generation_id: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Unique identifier for the generation.', - }, - chat_history: { - anyOf: [ - { - items: { - $ref: '#/components/schemas/ChatMessage', - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: - "A list of previous messages between the user and the model, meant to give the model conversational context for responding to the user's message.", - }, - finish_reason: { - type: 'string', - title: 'Reason the chat stream ended.', - }, - text: { - type: 'string', - title: 'Contents of the chat message.', - }, - citations: { - anyOf: [ - { - items: { - $ref: '#/components/schemas/Citation', - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: 'Citations for the chat message.', - default: [], - }, - documents: { - anyOf: [ - { - items: { - $ref: '#/components/schemas/Document', - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: 'Documents used to generate grounded response with citations.', - default: [], - }, - search_results: { - anyOf: [ - { - items: { - type: 'object', - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: 'Search results used to generate grounded response with citations.', - default: [], - }, - search_queries: { - anyOf: [ - { - items: { - $ref: '#/components/schemas/SearchQuery', - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: 'List of generated search queries.', - default: [], - }, - conversation_id: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: - 'To store a conversation then create a conversation id and use it for every related request.', - }, - tool_calls: { - anyOf: [ - { - items: { - $ref: '#/components/schemas/ToolCall', - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: 'List of tool calls generated for custom tools', - default: [], - }, - }, - type: 'object', - required: [ - 'response_id', - 'generation_id', - 'chat_history', - 'finish_reason', - 'text', - 'conversation_id', - ], - title: 'NonStreamedChatResponse', +export const $Organization = { + properties: { + name: { + type: 'string', + title: 'Name' + }, + id: { + type: 'string', + title: 'Id' + }, + created_at: { + type: 'string', + format: 'date-time', + title: 'Created At' + }, + updated_at: { + type: 'string', + format: 'date-time', + title: 'Updated At' + } + }, + type: 'object', + required: ['name', 'id', 'created_at', 'updated_at'], + title: 'Organization' +} as const; + +export const $PatchGroup = { + properties: { + schemas: { + items: { + type: 'string' + }, + type: 'array', + title: 'Schemas' + }, + operations: { + items: { + '$ref': '#/components/schemas/GroupOperation' + }, + type: 'array', + title: 'Operations' + } + }, + type: 'object', + required: ['schemas', 'operations'], + title: 'PatchGroup' +} as const; + +export const $PatchUser = { + properties: { + schemas: { + items: { + type: 'string' + }, + type: 'array', + title: 'Schemas' + }, + operations: { + items: { + '$ref': '#/components/schemas/Operation' + }, + type: 'array', + title: 'Operations' + } + }, + type: 'object', + required: ['schemas', 'operations'], + title: 'PatchUser' } as const; export const $SearchQuery = { - properties: { - text: { - type: 'string', - title: 'Text', - }, - generation_id: { - type: 'string', - title: 'Generation Id', - }, - }, - type: 'object', - required: ['text', 'generation_id'], - title: 'SearchQuery', -} as const; - -export const $Snapshot = { - properties: { - conversation_id: { - type: 'string', - title: 'Conversation Id', - }, - id: { - type: 'string', - title: 'Id', - }, - last_message_id: { - type: 'string', - title: 'Last Message Id', - }, - user_id: { - type: 'string', - title: 'User Id', - }, - organization_id: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Organization Id', - }, - version: { - type: 'integer', - title: 'Version', - }, - created_at: { - type: 'string', - format: 'date-time', - title: 'Created At', - }, - updated_at: { - type: 'string', - format: 'date-time', - title: 'Updated At', - }, - snapshot: { - $ref: '#/components/schemas/SnapshotData', - }, - }, - type: 'object', - required: [ - 'conversation_id', - 'id', - 'last_message_id', - 'user_id', - 'organization_id', - 'version', - 'created_at', - 'updated_at', - 'snapshot', - ], - title: 'Snapshot', -} as const; - -export const $SnapshotAgent = { - properties: { - id: { - type: 'string', - title: 'Id', - }, - name: { - type: 'string', - title: 'Name', - }, - description: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Description', - }, - preamble: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Preamble', - }, - tools_metadata: { - anyOf: [ - { - items: { - $ref: '#/components/schemas/AgentToolMetadata', - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: 'Tools Metadata', - }, - }, - type: 'object', - required: ['id', 'name', 'description', 'preamble', 'tools_metadata'], - title: 'SnapshotAgent', + properties: { + text: { + type: 'string', + title: 'Text' + }, + generation_id: { + type: 'string', + title: 'Generation Id' + } + }, + type: 'object', + required: ['text', 'generation_id'], + title: 'SearchQuery' } as const; export const $SnapshotData = { - properties: { - title: { - type: 'string', - title: 'Title', - }, - description: { - type: 'string', - title: 'Description', - }, - messages: { - items: { - $ref: '#/components/schemas/Message', - }, - type: 'array', - title: 'Messages', + properties: { + title: { + type: 'string', + title: 'Title' + }, + description: { + type: 'string', + title: 'Description' + }, + messages: { + items: { + '$ref': '#/components/schemas/Message' + }, + type: 'array', + title: 'Messages' + } }, - agent: { - anyOf: [ - { - $ref: '#/components/schemas/SnapshotAgent', + type: 'object', + required: ['title', 'description', 'messages'], + title: 'SnapshotData' +} as const; + +export const $SnapshotPublic = { + properties: { + conversation_id: { + type: 'string', + title: 'Conversation Id' + }, + id: { + type: 'string', + title: 'Id' + }, + last_message_id: { + type: 'string', + title: 'Last Message Id' + }, + version: { + type: 'integer', + title: 'Version' + }, + created_at: { + type: 'string', + format: 'date-time', + title: 'Created At' }, - { - type: 'null', + updated_at: { + type: 'string', + format: 'date-time', + title: 'Updated At' }, - ], + snapshot: { + '$ref': '#/components/schemas/SnapshotData' + } }, - }, - type: 'object', - required: ['title', 'description', 'messages', 'agent'], - title: 'SnapshotData', + type: 'object', + required: ['conversation_id', 'id', 'last_message_id', 'version', 'created_at', 'updated_at', 'snapshot'], + title: 'SnapshotPublic' } as const; export const $SnapshotWithLinks = { - properties: { - conversation_id: { - type: 'string', - title: 'Conversation Id', - }, - id: { - type: 'string', - title: 'Id', - }, - last_message_id: { - type: 'string', - title: 'Last Message Id', - }, - user_id: { - type: 'string', - title: 'User Id', - }, - organization_id: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Organization Id', - }, - version: { - type: 'integer', - title: 'Version', - }, - created_at: { - type: 'string', - format: 'date-time', - title: 'Created At', - }, - updated_at: { - type: 'string', - format: 'date-time', - title: 'Updated At', - }, - snapshot: { - $ref: '#/components/schemas/SnapshotData', - }, - links: { - items: { - type: 'string', - }, - type: 'array', - title: 'Links', - }, - }, - type: 'object', - required: [ - 'conversation_id', - 'id', - 'last_message_id', - 'user_id', - 'organization_id', - 'version', - 'created_at', - 'updated_at', - 'snapshot', - 'links', - ], - title: 'SnapshotWithLinks', + properties: { + conversation_id: { + type: 'string', + title: 'Conversation Id' + }, + id: { + type: 'string', + title: 'Id' + }, + last_message_id: { + type: 'string', + title: 'Last Message Id' + }, + version: { + type: 'integer', + title: 'Version' + }, + created_at: { + type: 'string', + format: 'date-time', + title: 'Created At' + }, + updated_at: { + type: 'string', + format: 'date-time', + title: 'Updated At' + }, + snapshot: { + '$ref': '#/components/schemas/SnapshotData' + }, + links: { + items: { + type: 'string' + }, + type: 'array', + title: 'Links' + } + }, + type: 'object', + required: ['conversation_id', 'id', 'last_message_id', 'version', 'created_at', 'updated_at', 'snapshot', 'links'], + title: 'SnapshotWithLinks' } as const; export const $StreamCitationGeneration = { - properties: { - citations: { - items: { - $ref: '#/components/schemas/Citation', - }, - type: 'array', - title: 'Citations for the chat message.', - default: [], + properties: { + citations: { + items: { + '$ref': '#/components/schemas/Citation' + }, + type: 'array', + title: 'Citations for the chat message.', + default: [] + } }, - }, - type: 'object', - title: 'StreamCitationGeneration', - description: 'Stream citation generation event.', + type: 'object', + title: 'StreamCitationGeneration', + description: 'Stream citation generation event.' } as const; export const $StreamEnd = { - properties: { - response_id: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Response Id', - }, - generation_id: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Generation Id', - }, - conversation_id: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Conversation Id', - }, - text: { - type: 'string', - title: 'Contents of the chat message.', - }, - citations: { - items: { - $ref: '#/components/schemas/Citation', - }, - type: 'array', - title: 'Citations for the chat message.', - default: [], - }, - documents: { - items: { - $ref: '#/components/schemas/Document', - }, - type: 'array', - title: 'Documents used to generate grounded response with citations.', - default: [], - }, - search_results: { - items: { - type: 'object', - }, - type: 'array', - title: 'Search results used to generate grounded response with citations.', - default: [], - }, - search_queries: { - items: { - $ref: '#/components/schemas/SearchQuery', - }, - type: 'array', - title: 'List of generated search queries.', - default: [], - }, - tool_calls: { - items: { - $ref: '#/components/schemas/ToolCall', - }, - type: 'array', - title: 'List of tool calls generated for custom tools', - default: [], - }, - finish_reason: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Finish Reason', - }, - chat_history: { - anyOf: [ - { - items: { - $ref: '#/components/schemas/ChatMessage', - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: - 'A list of entries used to construct the conversation. If provided, these messages will be used to build the prompt and the conversation_id will be ignored so no data will be stored to maintain state.', - }, - error: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Error message if the response is an error.', - }, - }, - type: 'object', - required: ['text'], - title: 'StreamEnd', + properties: { + message_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Message Id' + }, + response_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Response Id' + }, + generation_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Generation Id' + }, + conversation_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Conversation Id' + }, + text: { + type: 'string', + title: 'Contents of the chat message.' + }, + citations: { + items: { + '$ref': '#/components/schemas/Citation' + }, + type: 'array', + title: 'Citations for the chat message.', + default: [] + }, + documents: { + items: { + '$ref': '#/components/schemas/Document' + }, + type: 'array', + title: 'Documents used to generate grounded response with citations.', + default: [] + }, + search_results: { + items: { + type: 'object' + }, + type: 'array', + title: 'Search results used to generate grounded response with citations.', + default: [] + }, + search_queries: { + items: { + '$ref': '#/components/schemas/SearchQuery' + }, + type: 'array', + title: 'List of generated search queries.', + default: [] + }, + tool_calls: { + items: { + '$ref': '#/components/schemas/ToolCall' + }, + type: 'array', + title: 'List of tool calls generated for custom tools', + default: [] + }, + finish_reason: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Finish Reason' + }, + chat_history: { + anyOf: [ + { + items: { + '$ref': '#/components/schemas/ChatMessage' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'A list of entries used to construct the conversation. If provided, these messages will be used to build the prompt and the conversation_id will be ignored so no data will be stored to maintain state.' + }, + error: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Error message if the response is an error.' + } + }, + type: 'object', + required: ['text'], + title: 'StreamEnd' } as const; export const $StreamEvent = { - type: 'string', - enum: [ - 'stream-start', - 'search-queries-generation', - 'search-results', - 'tool-input', - 'tool-result', - 'text-generation', - 'citation-generation', - 'stream-end', - 'non-streamed-chat-response', - 'tool-calls-generation', - 'tool-calls-chunk', - ], - title: 'StreamEvent', - description: "Stream Events returned by Cohere's chat stream response.", + type: 'string', + enum: ['stream-start', 'search-queries-generation', 'search-results', 'tool-input', 'tool-result', 'text-generation', 'citation-generation', 'stream-end', 'non-streamed-chat-response', 'tool-calls-generation', 'tool-calls-chunk'], + title: 'StreamEvent', + description: "Stream Events returned by Cohere's chat stream response." } as const; export const $StreamQueryGeneration = { - properties: { - query: { - type: 'string', - title: 'Search query used to generate grounded response with citations.', + properties: { + query: { + type: 'string', + title: 'Search query used to generate grounded response with citations.' + } }, - }, - type: 'object', - required: ['query'], - title: 'StreamQueryGeneration', - description: 'Stream query generation event.', + type: 'object', + required: ['query'], + title: 'StreamQueryGeneration', + description: 'Stream query generation event.' } as const; export const $StreamSearchQueriesGeneration = { - properties: { - search_queries: { - items: { - $ref: '#/components/schemas/SearchQuery', - }, - type: 'array', - title: 'Search query used to generate grounded response with citations.', - default: [], + properties: { + search_queries: { + items: { + '$ref': '#/components/schemas/SearchQuery' + }, + type: 'array', + title: 'Search query used to generate grounded response with citations.', + default: [] + } }, - }, - type: 'object', - title: 'StreamSearchQueriesGeneration', - description: 'Stream queries generation event.', + type: 'object', + title: 'StreamSearchQueriesGeneration', + description: 'Stream queries generation event.' } as const; export const $StreamSearchResults = { - properties: { - search_results: { - items: { - type: 'object', - }, - type: 'array', - title: 'Search results used to generate grounded response with citations.', - default: [], - }, - documents: { - items: { - $ref: '#/components/schemas/Document', - }, - type: 'array', - title: 'Documents used to generate grounded response with citations.', - default: [], - }, - }, - type: 'object', - title: 'StreamSearchResults', + properties: { + search_results: { + items: { + type: 'object' + }, + type: 'array', + title: 'Search results used to generate grounded response with citations.', + default: [] + }, + documents: { + items: { + '$ref': '#/components/schemas/Document' + }, + type: 'array', + title: 'Documents used to generate grounded response with citations.', + default: [] + } + }, + type: 'object', + title: 'StreamSearchResults' } as const; export const $StreamStart = { - properties: { - generation_id: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Generation Id', - }, - conversation_id: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', + properties: { + generation_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Generation Id' }, - ], - title: 'Conversation Id', + conversation_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Conversation Id' + } }, - }, - type: 'object', - title: 'StreamStart', - description: 'Stream start event.', + type: 'object', + title: 'StreamStart', + description: 'Stream start event.' } as const; export const $StreamTextGeneration = { - properties: { - text: { - type: 'string', - title: 'Contents of the chat message.', + properties: { + text: { + type: 'string', + title: 'Contents of the chat message.' + } }, - }, - type: 'object', - required: ['text'], - title: 'StreamTextGeneration', - description: 'Stream text generation event.', + type: 'object', + required: ['text'], + title: 'StreamTextGeneration', + description: 'Stream text generation event.' } as const; export const $StreamToolCallsChunk = { - properties: { - tool_call_delta: { - anyOf: [ - { - $ref: '#/components/schemas/ToolCallDelta', - }, - { - type: 'null', - }, - ], - title: 'Partial tool call', - default: {}, - }, - text: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', + properties: { + tool_call_delta: { + anyOf: [ + { + '$ref': '#/components/schemas/ToolCallDelta' + }, + { + type: 'null' + } + ], + title: 'Partial tool call', + default: {} }, - ], - title: 'Contents of the chat message.', + text: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Contents of the chat message.' + } }, - }, - type: 'object', - required: ['text'], - title: 'StreamToolCallsChunk', + type: 'object', + required: ['text'], + title: 'StreamToolCallsChunk' } as const; export const $StreamToolCallsGeneration = { - properties: { - stream_search_results: { - anyOf: [ - { - $ref: '#/components/schemas/StreamSearchResults', + properties: { + stream_search_results: { + anyOf: [ + { + '$ref': '#/components/schemas/StreamSearchResults' + }, + { + type: 'null' + } + ], + title: 'List of search results used to generate grounded response with citations', + default: [] }, - { - type: 'null', + tool_calls: { + anyOf: [ + { + items: { + '$ref': '#/components/schemas/ToolCall' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'List of tool calls generated for custom tools', + default: [] }, - ], - title: 'List of search results used to generate grounded response with citations', - default: [], + text: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Contents of the chat message.' + } }, - tool_calls: { - anyOf: [ - { - items: { - $ref: '#/components/schemas/ToolCall', - }, - type: 'array', - }, - { - type: 'null', + type: 'object', + required: ['text'], + title: 'StreamToolCallsGeneration', + description: 'Stream tool calls generation event.' +} as const; + +export const $StreamToolInput = { + properties: { + input_type: { + '$ref': '#/components/schemas/ToolInputType' }, - ], - title: 'List of tool calls generated for custom tools', - default: [], - }, - text: { - anyOf: [ - { - type: 'string', + tool_name: { + type: 'string', + title: 'Tool Name' }, - { - type: 'null', + input: { + type: 'string', + title: 'Input' }, - ], - title: 'Contents of the chat message.', + text: { + type: 'string', + title: 'Text' + } }, - }, - type: 'object', - required: ['text'], - title: 'StreamToolCallsGeneration', - description: 'Stream tool calls generation event.', + type: 'object', + required: ['input_type', 'tool_name', 'input', 'text'], + title: 'StreamToolInput' } as const; -export const $StreamToolInput = { - properties: { - input_type: { - $ref: '#/components/schemas/ToolInputType', - }, - tool_name: { - type: 'string', - title: 'Tool Name', - }, - input: { - type: 'string', - title: 'Input', - }, - text: { - type: 'string', - title: 'Text', +export const $StreamToolResult = { + properties: { + result: { + title: 'Result' + }, + tool_name: { + type: 'string', + title: 'Tool Name' + }, + documents: { + items: { + '$ref': '#/components/schemas/Document' + }, + type: 'array', + title: 'Documents used to generate grounded response with citations.', + default: [] + } }, - }, - type: 'object', - required: ['input_type', 'tool_name', 'input', 'text'], - title: 'StreamToolInput', + type: 'object', + required: ['result', 'tool_name'], + title: 'StreamToolResult' } as const; -export const $StreamToolResult = { - properties: { - result: { - title: 'Result', - }, - tool_name: { - type: 'string', - title: 'Tool Name', +export const $ToggleConversationPinRequest = { + properties: { + is_pinned: { + type: 'boolean', + title: 'Is Pinned' + } }, - documents: { - items: { - $ref: '#/components/schemas/Document', - }, - type: 'array', - title: 'Documents used to generate grounded response with citations.', - default: [], - }, - }, - type: 'object', - required: ['result', 'tool_name'], - title: 'StreamToolResult', + type: 'object', + required: ['is_pinned'], + title: 'ToggleConversationPinRequest' } as const; export const $Tool = { - properties: { - name: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Name', - default: '', - }, - display_name: { - type: 'string', - title: 'Display Name', - default: '', - }, - description: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', + properties: { + name: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Name', + default: '' }, - ], - title: 'Description', - default: '', - }, - parameter_definitions: { - anyOf: [ - { - type: 'object', + display_name: { + type: 'string', + title: 'Display Name', + default: '' }, - { - type: 'null', + description: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Description', + default: '' }, - ], - title: 'Parameter Definitions', - default: {}, + parameter_definitions: { + anyOf: [ + { + type: 'object' + }, + { + type: 'null' + } + ], + title: 'Parameter Definitions', + default: {} + } }, - }, - type: 'object', - title: 'Tool', + type: 'object', + title: 'Tool' } as const; export const $ToolCall = { - properties: { - name: { - type: 'string', - title: 'Name', - }, - parameters: { - type: 'object', - title: 'Parameters', - default: {}, + properties: { + name: { + type: 'string', + title: 'Name' + }, + parameters: { + type: 'object', + title: 'Parameters', + default: {} + } }, - }, - type: 'object', - required: ['name'], - title: 'ToolCall', + type: 'object', + required: ['name'], + title: 'ToolCall' } as const; export const $ToolCallDelta = { - properties: { - name: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Name', - }, - index: { - anyOf: [ - { - type: 'integer', - }, - { - type: 'null', - }, - ], - title: 'Index', - }, - parameters: { - anyOf: [ - { - type: 'string', + properties: { + name: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Name' }, - { - type: 'null', + index: { + anyOf: [ + { + type: 'integer' + }, + { + type: 'null' + } + ], + title: 'Index' }, - ], - title: 'Parameters', + parameters: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Parameters' + } }, - }, - type: 'object', - required: ['name', 'index', 'parameters'], - title: 'ToolCallDelta', + type: 'object', + required: ['name', 'index', 'parameters'], + title: 'ToolCallDelta' } as const; export const $ToolInputType = { - type: 'string', - enum: ['QUERY', 'CODE'], - title: 'ToolInputType', - description: 'Type of input passed to the tool', + type: 'string', + enum: ['QUERY', 'CODE'], + title: 'ToolInputType', + description: 'Type of input passed to the tool' } as const; -export const $UpdateAgent = { - properties: { - name: { - anyOf: [ - { - type: 'string', +export const $UpdateAgentRequest = { + properties: { + name: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Name' }, - { - type: 'null', + version: { + anyOf: [ + { + type: 'integer' + }, + { + type: 'null' + } + ], + title: 'Version' }, - ], - title: 'Name', - }, - version: { - anyOf: [ - { - type: 'integer', + description: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Description' }, - { - type: 'null', + preamble: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Preamble' }, - ], - title: 'Version', - }, - description: { - anyOf: [ - { - type: 'string', + temperature: { + anyOf: [ + { + type: 'number' + }, + { + type: 'null' + } + ], + title: 'Temperature' }, - { - type: 'null', + model: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Model' }, - ], - title: 'Description', - }, - preamble: { - anyOf: [ - { - type: 'string', + deployment: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Deployment' }, - { - type: 'null', + deployment_config: { + anyOf: [ + { + additionalProperties: { + type: 'string' + }, + type: 'object' + }, + { + type: 'null' + } + ], + title: 'Deployment Config' }, - ], - title: 'Preamble', - }, - temperature: { - anyOf: [ - { - type: 'number', + is_default_deployment: { + anyOf: [ + { + type: 'boolean' + }, + { + type: 'null' + } + ], + title: 'Is Default Deployment', + default: false + }, + is_default_model: { + anyOf: [ + { + type: 'boolean' + }, + { + type: 'null' + } + ], + title: 'Is Default Model', + default: false }, - { - type: 'null', + organization_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Organization Id' }, - ], - title: 'Temperature', - }, - model: { - anyOf: [ - { - type: 'string', + tools: { + anyOf: [ + { + items: { + type: 'string' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'Tools' }, - { - type: 'null', + tools_metadata: { + anyOf: [ + { + items: { + '$ref': '#/components/schemas/CreateAgentToolMetadataRequest' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'Tools Metadata' }, - ], - title: 'Model', + is_private: { + anyOf: [ + { + type: 'boolean' + }, + { + type: 'null' + } + ], + title: 'Is Private' + } }, - deployment: { - anyOf: [ - { - type: 'string', + type: 'object', + title: 'UpdateAgentRequest' +} as const; + +export const $UpdateAgentToolMetadataRequest = { + properties: { + id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Id' }, - { - type: 'null', + tool_name: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Tool Name' + }, + artifacts: { + anyOf: [ + { + items: { + type: 'object' + }, + type: 'array' + }, + { + type: 'null' + } + ], + title: 'Artifacts' + } + }, + type: 'object', + title: 'UpdateAgentToolMetadataRequest' +} as const; + +export const $UpdateConversationRequest = { + properties: { + title: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Title' }, - ], - title: 'Deployment', + description: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Description' + } + }, + type: 'object', + title: 'UpdateConversationRequest' +} as const; + +export const $UpdateDeploymentEnv = { + properties: { + env_vars: { + additionalProperties: { + type: 'string' + }, + type: 'object', + title: 'Env Vars' + } + }, + type: 'object', + required: ['env_vars'], + title: 'UpdateDeploymentEnv' +} as const; + +export const $UpdateOrganization = { + properties: { + name: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Name' + } }, - tools: { - anyOf: [ - { - items: { + type: 'object', + required: ['name'], + title: 'UpdateOrganization' +} as const; + +export const $UploadAgentFileResponse = { + properties: { + id: { type: 'string', - }, - type: 'array', + title: 'Id' }, - { - type: 'null', + created_at: { + type: 'string', + format: 'date-time', + title: 'Created At' }, - ], - title: 'Tools', - }, - tools_metadata: { - anyOf: [ - { - items: { - $ref: '#/components/schemas/CreateAgentToolMetadata', - }, - type: 'array', + updated_at: { + type: 'string', + format: 'date-time', + title: 'Updated At' }, - { - type: 'null', + file_name: { + type: 'string', + title: 'File Name' }, - ], - title: 'Tools Metadata', + file_size: { + type: 'integer', + minimum: 0, + title: 'File Size', + default: 0 + } }, - }, - type: 'object', - title: 'UpdateAgent', + type: 'object', + required: ['id', 'created_at', 'updated_at', 'file_name'], + title: 'UploadAgentFileResponse' } as const; -export const $UpdateAgentToolMetadata = { - properties: { - id: { - anyOf: [ - { - type: 'string', +export const $UploadConversationFileResponse = { + properties: { + id: { + type: 'string', + title: 'Id' }, - { - type: 'null', + user_id: { + type: 'string', + title: 'User Id' }, - ], - title: 'Id', - }, - tool_name: { - anyOf: [ - { - type: 'string', + created_at: { + type: 'string', + format: 'date-time', + title: 'Created At' }, - { - type: 'null', + updated_at: { + type: 'string', + format: 'date-time', + title: 'Updated At' }, - ], - title: 'Tool Name', - }, - artifacts: { - anyOf: [ - { - items: { - type: 'object', - }, - type: 'array', + conversation_id: { + type: 'string', + title: 'Conversation Id' }, - { - type: 'null', + file_name: { + type: 'string', + title: 'File Name' }, - ], - title: 'Artifacts', + file_size: { + type: 'integer', + minimum: 0, + title: 'File Size', + default: 0 + } }, - }, - type: 'object', - title: 'UpdateAgentToolMetadata', + type: 'object', + required: ['id', 'user_id', 'created_at', 'updated_at', 'conversation_id', 'file_name'], + title: 'UploadConversationFileResponse' } as const; -export const $UpdateConversation = { - properties: { - title: { - anyOf: [ - { - type: 'string', +export const $ValidationError = { + properties: { + loc: { + items: { + anyOf: [ + { + type: 'string' + }, + { + type: 'integer' + } + ] + }, + type: 'array', + title: 'Location' }, - { - type: 'null', + msg: { + type: 'string', + title: 'Message' }, - ], - title: 'Title', + type: { + type: 'string', + title: 'Error Type' + } }, - description: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', + type: 'object', + required: ['loc', 'msg', 'type'], + title: 'ValidationError' +} as const; + +export const $backend__schemas__scim__CreateUser = { + properties: { + userName: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Username' }, - ], - title: 'Description', + active: { + anyOf: [ + { + type: 'boolean' + }, + { + type: 'null' + } + ], + title: 'Active' + }, + schemas: { + items: { + type: 'string' + }, + type: 'array', + title: 'Schemas' + }, + name: { + '$ref': '#/components/schemas/Name' + }, + emails: { + items: { + '$ref': '#/components/schemas/Email' + }, + type: 'array', + title: 'Emails' + }, + externalId: { + type: 'string', + title: 'Externalid' + } }, - }, - type: 'object', - title: 'UpdateConversation', + type: 'object', + required: ['userName', 'active', 'schemas', 'name', 'emails', 'externalId'], + title: 'CreateUser' } as const; -export const $UpdateDeploymentEnv = { - properties: { - env_vars: { - additionalProperties: { - type: 'string', - }, - type: 'object', - title: 'Env Vars', +export const $backend__schemas__scim__UpdateUser = { + properties: { + userName: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Username' + }, + active: { + anyOf: [ + { + type: 'boolean' + }, + { + type: 'null' + } + ], + title: 'Active' + }, + schemas: { + items: { + type: 'string' + }, + type: 'array', + title: 'Schemas' + }, + emails: { + items: { + '$ref': '#/components/schemas/Email' + }, + type: 'array', + title: 'Emails' + }, + name: { + '$ref': '#/components/schemas/Name' + } + }, + type: 'object', + required: ['userName', 'active', 'schemas', 'emails', 'name'], + title: 'UpdateUser' +} as const; + +export const $backend__schemas__scim__User = { + properties: { + userName: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Username' + }, + active: { + anyOf: [ + { + type: 'boolean' + }, + { + type: 'null' + } + ], + title: 'Active' + }, + schemas: { + items: { + type: 'string' + }, + type: 'array', + title: 'Schemas' + }, + id: { + type: 'string', + title: 'Id' + }, + externalId: { + type: 'string', + title: 'Externalid' + }, + meta: { + '$ref': '#/components/schemas/Meta' + } }, - }, - type: 'object', - required: ['env_vars'], - title: 'UpdateDeploymentEnv', + type: 'object', + required: ['userName', 'active', 'schemas', 'id', 'externalId', 'meta'], + title: 'User' } as const; -export const $UpdateFile = { - properties: { - file_name: { - anyOf: [ - { - type: 'string', +export const $backend__schemas__user__CreateUser = { + properties: { + password: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Password' }, - { - type: 'null', + hashed_password: { + anyOf: [ + { + type: 'string', + format: 'binary' + }, + { + type: 'null' + } + ], + title: 'Hashed Password' }, - ], - title: 'File Name', - }, - message_id: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', + fullname: { + type: 'string', + title: 'Fullname' }, - ], - title: 'Message Id', - }, - }, - type: 'object', - title: 'UpdateFile', -} as const; - -export const $UpdateUser = { - properties: { - password: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Password', - }, - hashed_password: { - anyOf: [ - { - type: 'string', - format: 'binary', - }, - { - type: 'null', - }, - ], - title: 'Hashed Password', - }, - fullname: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Fullname', - }, - email: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Email', - }, - }, - type: 'object', - title: 'UpdateUser', -} as const; - -export const $UploadFile = { - properties: { - id: { - type: 'string', - title: 'Id', - }, - created_at: { - type: 'string', - format: 'date-time', - title: 'Created At', - }, - updated_at: { - type: 'string', - format: 'date-time', - title: 'Updated At', - }, - user_id: { - type: 'string', - title: 'User Id', - }, - conversation_id: { - type: 'string', - title: 'Conversation Id', - }, - file_name: { - type: 'string', - title: 'File Name', - }, - file_path: { - type: 'string', - title: 'File Path', + email: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Email' + } }, - file_size: { - type: 'integer', - minimum: 0, - title: 'File Size', - default: 0, - }, - }, - type: 'object', - required: [ - 'id', - 'created_at', - 'updated_at', - 'user_id', - 'conversation_id', - 'file_name', - 'file_path', - ], - title: 'UploadFile', -} as const; - -export const $User = { - properties: { - fullname: { - type: 'string', - title: 'Fullname', - }, - email: { - anyOf: [ - { - type: 'string', - }, - { - type: 'null', - }, - ], - title: 'Email', - }, - id: { - type: 'string', - title: 'Id', - }, - created_at: { - type: 'string', - format: 'date-time', - title: 'Created At', - }, - updated_at: { - type: 'string', - format: 'date-time', - title: 'Updated At', - }, - }, - type: 'object', - required: ['fullname', 'id', 'created_at', 'updated_at'], - title: 'User', + type: 'object', + required: ['fullname'], + title: 'CreateUser' } as const; -export const $ValidationError = { - properties: { - loc: { - items: { - anyOf: [ - { - type: 'string', - }, - { - type: 'integer', - }, - ], - }, - type: 'array', - title: 'Location', - }, - msg: { - type: 'string', - title: 'Message', - }, - type: { - type: 'string', - title: 'Error Type', +export const $backend__schemas__user__UpdateUser = { + properties: { + password: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Password' + }, + hashed_password: { + anyOf: [ + { + type: 'string', + format: 'binary' + }, + { + type: 'null' + } + ], + title: 'Hashed Password' + }, + fullname: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Fullname' + }, + email: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Email' + } }, - }, - type: 'object', - required: ['loc', 'msg', 'type'], - title: 'ValidationError', + type: 'object', + title: 'UpdateUser' } as const; + +export const $backend__schemas__user__User = { + properties: { + fullname: { + type: 'string', + title: 'Fullname' + }, + email: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Email' + }, + id: { + type: 'string', + title: 'Id' + }, + created_at: { + type: 'string', + format: 'date-time', + title: 'Created At' + }, + updated_at: { + type: 'string', + format: 'date-time', + title: 'Updated At' + } + }, + type: 'object', + required: ['fullname', 'id', 'created_at', 'updated_at'], + title: 'User' +} as const; \ No newline at end of file diff --git a/src/interfaces/coral_web/src/cohere-client/generated/services.gen.ts b/src/interfaces/coral_web/src/cohere-client/generated/services.gen.ts index 327547d147..85a2d0ebf9 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/services.gen.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/services.gen.ts @@ -1,1444 +1,2103 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { BaseHttpRequest } from './core/BaseHttpRequest'; + import type { CancelablePromise } from './core/CancelablePromise'; -import type { - ApplyMigrationsMigratePostResponse, - AuthorizeV1StrategyAuthPostData, - AuthorizeV1StrategyAuthPostResponse, - BatchUploadFileV1ConversationsBatchUploadFilePostData, - BatchUploadFileV1ConversationsBatchUploadFilePostResponse, - ChatStreamV1ChatStreamPostData, - ChatStreamV1ChatStreamPostResponse, - ChatV1ChatPostData, - ChatV1ChatPostResponse, - CreateAgentToolMetadataV1AgentsAgentIdToolMetadataPostData, - CreateAgentToolMetadataV1AgentsAgentIdToolMetadataPostResponse, - CreateAgentV1AgentsPostData, - CreateAgentV1AgentsPostResponse, - CreateSnapshotV1SnapshotsPostData, - CreateSnapshotV1SnapshotsPostResponse, - CreateUserV1UsersPostData, - CreateUserV1UsersPostResponse, - DeleteAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdDeleteData, - DeleteAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdDeleteResponse, - DeleteAgentV1AgentsAgentIdDeleteData, - DeleteAgentV1AgentsAgentIdDeleteResponse, - DeleteConversationV1ConversationsConversationIdDeleteData, - DeleteConversationV1ConversationsConversationIdDeleteResponse, - DeleteFileV1ConversationsConversationIdFilesFileIdDeleteData, - DeleteFileV1ConversationsConversationIdFilesFileIdDeleteResponse, - DeleteSnapshotLinkV1SnapshotsLinkLinkIdDeleteData, - DeleteSnapshotLinkV1SnapshotsLinkLinkIdDeleteResponse, - DeleteSnapshotV1SnapshotsSnapshotIdDeleteData, - DeleteSnapshotV1SnapshotsSnapshotIdDeleteResponse, - DeleteUserV1UsersUserIdDeleteData, - DeleteUserV1UsersUserIdDeleteResponse, - GenerateTitleV1ConversationsConversationIdGenerateTitlePostData, - GenerateTitleV1ConversationsConversationIdGenerateTitlePostResponse, - GetAgentByIdV1AgentsAgentIdGetData, - GetAgentByIdV1AgentsAgentIdGetResponse, - GetConversationV1ConversationsConversationIdGetData, - GetConversationV1ConversationsConversationIdGetResponse, - GetSnapshotV1SnapshotsLinkLinkIdGetData, - GetSnapshotV1SnapshotsLinkLinkIdGetResponse, - GetStrategiesV1AuthStrategiesGetResponse, - GetUserV1UsersUserIdGetData, - GetUserV1UsersUserIdGetResponse, - HealthHealthGetResponse, - LangchainChatStreamV1LangchainChatPostData, - LangchainChatStreamV1LangchainChatPostResponse, - ListAgentToolMetadataV1AgentsAgentIdToolMetadataGetData, - ListAgentToolMetadataV1AgentsAgentIdToolMetadataGetResponse, - ListAgentsV1AgentsGetData, - ListAgentsV1AgentsGetResponse, - ListConversationsV1ConversationsGetData, - ListConversationsV1ConversationsGetResponse, - ListDeploymentsV1DeploymentsGetData, - ListDeploymentsV1DeploymentsGetResponse, - ListExperimentalFeaturesV1ExperimentalFeaturesGetResponse, - ListFilesV1ConversationsConversationIdFilesGetData, - ListFilesV1ConversationsConversationIdFilesGetResponse, - ListSnapshotsV1SnapshotsGetResponse, - ListToolsV1ToolsGetData, - ListToolsV1ToolsGetResponse, - ListUsersV1UsersGetData, - ListUsersV1UsersGetResponse, - LoginV1LoginPostData, - LoginV1LoginPostResponse, - LoginV1ToolAuthGetResponse, - LogoutV1LogoutGetResponse, - SearchConversationsV1ConversationsSearchGetData, - SearchConversationsV1ConversationsSearchGetResponse, - SetEnvVarsV1DeploymentsNameSetEnvVarsPostData, - SetEnvVarsV1DeploymentsNameSetEnvVarsPostResponse, - UpdateAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdPutData, - UpdateAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdPutResponse, - UpdateAgentV1AgentsAgentIdPutData, - UpdateAgentV1AgentsAgentIdPutResponse, - UpdateConversationV1ConversationsConversationIdPutData, - UpdateConversationV1ConversationsConversationIdPutResponse, - UpdateFileV1ConversationsConversationIdFilesFileIdPutData, - UpdateFileV1ConversationsConversationIdFilesFileIdPutResponse, - UpdateUserV1UsersUserIdPutData, - UpdateUserV1UsersUserIdPutResponse, - UploadFileV1ConversationsUploadFilePostData, - UploadFileV1ConversationsUploadFilePostResponse, -} from './types.gen'; +import type { BaseHttpRequest } from './core/BaseHttpRequest'; +import type { GetStrategiesV1AuthStrategiesGetResponse, LoginV1LoginPostData, LoginV1LoginPostResponse, AuthorizeV1StrategyAuthPostData, AuthorizeV1StrategyAuthPostResponse, LogoutV1LogoutGetResponse, ToolAuthV1ToolAuthGetResponse, DeleteToolAuthV1ToolAuthToolIdDeleteData, DeleteToolAuthV1ToolAuthToolIdDeleteResponse, ChatStreamV1ChatStreamPostData, ChatStreamV1ChatStreamPostResponse, RegenerateChatStreamV1ChatStreamRegeneratePostData, RegenerateChatStreamV1ChatStreamRegeneratePostResponse, ChatV1ChatPostData, ChatV1ChatPostResponse, CreateUserV1UsersPostData, CreateUserV1UsersPostResponse, ListUsersV1UsersGetData, ListUsersV1UsersGetResponse, GetUserV1UsersUserIdGetData, GetUserV1UsersUserIdGetResponse, UpdateUserV1UsersUserIdPutData, UpdateUserV1UsersUserIdPutResponse, DeleteUserV1UsersUserIdDeleteData, DeleteUserV1UsersUserIdDeleteResponse, GetConversationV1ConversationsConversationIdGetData, GetConversationV1ConversationsConversationIdGetResponse, UpdateConversationV1ConversationsConversationIdPutData, UpdateConversationV1ConversationsConversationIdPutResponse, DeleteConversationV1ConversationsConversationIdDeleteData, DeleteConversationV1ConversationsConversationIdDeleteResponse, ListConversationsV1ConversationsGetData, ListConversationsV1ConversationsGetResponse, ToggleConversationPinV1ConversationsConversationIdTogglePinPutData, ToggleConversationPinV1ConversationsConversationIdTogglePinPutResponse, SearchConversationsV1ConversationsSearchGetData, SearchConversationsV1ConversationsSearchGetResponse, BatchUploadFileV1ConversationsBatchUploadFilePostData, BatchUploadFileV1ConversationsBatchUploadFilePostResponse, ListFilesV1ConversationsConversationIdFilesGetData, ListFilesV1ConversationsConversationIdFilesGetResponse, DeleteFileV1ConversationsConversationIdFilesFileIdDeleteData, DeleteFileV1ConversationsConversationIdFilesFileIdDeleteResponse, GenerateTitleV1ConversationsConversationIdGenerateTitlePostData, GenerateTitleV1ConversationsConversationIdGenerateTitlePostResponse, SynthesizeMessageV1ConversationsConversationIdSynthesizeMessageIdGetData, SynthesizeMessageV1ConversationsConversationIdSynthesizeMessageIdGetResponse, ListToolsV1ToolsGetData, ListToolsV1ToolsGetResponse, CreateDeploymentV1DeploymentsPostData, CreateDeploymentV1DeploymentsPostResponse, ListDeploymentsV1DeploymentsGetData, ListDeploymentsV1DeploymentsGetResponse, UpdateDeploymentV1DeploymentsDeploymentIdPutData, UpdateDeploymentV1DeploymentsDeploymentIdPutResponse, GetDeploymentV1DeploymentsDeploymentIdGetData, GetDeploymentV1DeploymentsDeploymentIdGetResponse, DeleteDeploymentV1DeploymentsDeploymentIdDeleteData, DeleteDeploymentV1DeploymentsDeploymentIdDeleteResponse, UpdateConfigV1DeploymentsDeploymentIdUpdateConfigPostData, UpdateConfigV1DeploymentsDeploymentIdUpdateConfigPostResponse, ListExperimentalFeaturesV1ExperimentalFeaturesGetResponse, CreateAgentV1AgentsPostData, CreateAgentV1AgentsPostResponse, ListAgentsV1AgentsGetData, ListAgentsV1AgentsGetResponse, GetAgentByIdV1AgentsAgentIdGetData, GetAgentByIdV1AgentsAgentIdGetResponse, UpdateAgentV1AgentsAgentIdPutData, UpdateAgentV1AgentsAgentIdPutResponse, DeleteAgentV1AgentsAgentIdDeleteData, DeleteAgentV1AgentsAgentIdDeleteResponse, GetAgentDeploymentsV1AgentsAgentIdDeploymentsGetData, GetAgentDeploymentsV1AgentsAgentIdDeploymentsGetResponse, ListAgentToolMetadataV1AgentsAgentIdToolMetadataGetData, ListAgentToolMetadataV1AgentsAgentIdToolMetadataGetResponse, CreateAgentToolMetadataV1AgentsAgentIdToolMetadataPostData, CreateAgentToolMetadataV1AgentsAgentIdToolMetadataPostResponse, UpdateAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdPutData, UpdateAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdPutResponse, DeleteAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdDeleteData, DeleteAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdDeleteResponse, BatchUploadFileV1AgentsBatchUploadFilePostData, BatchUploadFileV1AgentsBatchUploadFilePostResponse, DeleteAgentFileV1AgentsAgentIdFilesFileIdDeleteData, DeleteAgentFileV1AgentsAgentIdFilesFileIdDeleteResponse, ListSnapshotsV1SnapshotsGetResponse, CreateSnapshotV1SnapshotsPostData, CreateSnapshotV1SnapshotsPostResponse, GetSnapshotV1SnapshotsLinkLinkIdGetData, GetSnapshotV1SnapshotsLinkLinkIdGetResponse, DeleteSnapshotLinkV1SnapshotsLinkLinkIdDeleteData, DeleteSnapshotLinkV1SnapshotsLinkLinkIdDeleteResponse, DeleteSnapshotV1SnapshotsSnapshotIdDeleteData, DeleteSnapshotV1SnapshotsSnapshotIdDeleteResponse, ListOrganizationsV1OrganizationsGetResponse, CreateOrganizationV1OrganizationsPostData, CreateOrganizationV1OrganizationsPostResponse, UpdateOrganizationV1OrganizationsOrganizationIdPutData, UpdateOrganizationV1OrganizationsOrganizationIdPutResponse, GetOrganizationV1OrganizationsOrganizationIdGetData, GetOrganizationV1OrganizationsOrganizationIdGetResponse, DeleteOrganizationV1OrganizationsOrganizationIdDeleteData, DeleteOrganizationV1OrganizationsOrganizationIdDeleteResponse, GetOrganizationUsersV1OrganizationsOrganizationIdUsersGetData, GetOrganizationUsersV1OrganizationsOrganizationIdUsersGetResponse, CreateModelV1ModelsPostData, CreateModelV1ModelsPostResponse, ListModelsV1ModelsGetData, ListModelsV1ModelsGetResponse, UpdateModelV1ModelsModelIdPutData, UpdateModelV1ModelsModelIdPutResponse, GetModelV1ModelsModelIdGetData, GetModelV1ModelsModelIdGetResponse, DeleteModelV1ModelsModelIdDeleteData, DeleteModelV1ModelsModelIdDeleteResponse, GetUsersScimV2UsersGetData, GetUsersScimV2UsersGetResponse, CreateUserScimV2UsersPostData, CreateUserScimV2UsersPostResponse, GetUserScimV2UsersUserIdGetData, GetUserScimV2UsersUserIdGetResponse, UpdateUserScimV2UsersUserIdPutData, UpdateUserScimV2UsersUserIdPutResponse, PatchUserScimV2UsersUserIdPatchData, PatchUserScimV2UsersUserIdPatchResponse, GetGroupsScimV2GroupsGetData, GetGroupsScimV2GroupsGetResponse, CreateGroupScimV2GroupsPostData, CreateGroupScimV2GroupsPostResponse, GetGroupScimV2GroupsGroupIdGetData, GetGroupScimV2GroupsGroupIdGetResponse, PatchGroupScimV2GroupsGroupIdPatchData, PatchGroupScimV2GroupsGroupIdPatchResponse, DeleteGroupScimV2GroupsGroupIdDeleteData, DeleteGroupScimV2GroupsGroupIdDeleteResponse, HealthHealthGetResponse, ApplyMigrationsMigratePostResponse } from './types.gen'; export class DefaultService { - constructor(public readonly httpRequest: BaseHttpRequest) {} - - /** - * Get Strategies - * Retrieves the currently enabled list of Authentication strategies. - * - * - * Returns: - * List[dict]: List of dictionaries containing the enabled auth strategy names. - * @returns ListAuthStrategy Successful Response - * @throws ApiError - */ - public getStrategiesV1AuthStrategiesGet(): CancelablePromise { - return this.httpRequest.request({ - method: 'GET', - url: '/v1/auth_strategies', - }); - } - - /** - * Login - * Logs user in, performing basic email/password auth. - * Verifies their credentials, retrieves the user and returns a JWT token. - * - * Args: - * request (Request): current Request object. - * login (Login): Login payload. - * session (DBSessionDep): Database session. - * - * Returns: - * dict: JWT token on Basic auth success - * - * Raises: - * HTTPException: If the strategy or payload are invalid, or if the login fails. - * @param data The data for the request. - * @param data.requestBody - * @returns unknown Successful Response - * @throws ApiError - */ - public loginV1LoginPost(data: LoginV1LoginPostData): CancelablePromise { - return this.httpRequest.request({ - method: 'POST', - url: '/v1/login', - body: data.requestBody, - mediaType: 'application/json', - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Authorize - * Callback authorization endpoint used for OAuth providers after authenticating on the provider's login screen. - * - * Args: - * strategy (str): Current strategy name. - * request (Request): Current Request object. - * session (Session): DB session. - * - * Returns: - * dict: Containing "token" key, on success. - * - * Raises: - * HTTPException: If authentication fails, or strategy is invalid. - * @param data The data for the request. - * @param data.strategy - * @param data.code - * @returns JWTResponse Successful Response - * @throws ApiError - */ - public authorizeV1StrategyAuthPost( - data: AuthorizeV1StrategyAuthPostData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'POST', - url: '/v1/{strategy}/auth', - path: { - strategy: data.strategy, - }, - query: { - code: data.code, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Logout - * Logs out the current user, adding the given JWT token to the blacklist. - * - * Args: - * request (Request): current Request object. - * - * Returns: - * dict: Empty on success - * @returns Logout Successful Response - * @throws ApiError - */ - public logoutV1LogoutGet(): CancelablePromise { - return this.httpRequest.request({ - method: 'GET', - url: '/v1/logout', - }); - } - - /** - * Login - * Logs user in, performing basic email/password auth. - * Verifies their credentials, retrieves the user and returns a JWT token. - * - * Args: - * request (Request): current Request object. - * login (Login): Login payload. - * session (DBSessionDep): Database session. - * - * Returns: - * dict: JWT token on Basic auth success - * - * Raises: - * HTTPException: If the strategy or payload are invalid, or if the login fails. - * @returns unknown Successful Response - * @throws ApiError - */ - public loginV1ToolAuthGet(): CancelablePromise { - return this.httpRequest.request({ - method: 'GET', - url: '/v1/tool/auth', - }); - } - - /** - * Chat Stream - * Stream chat endpoint to handle user messages and return chatbot responses. - * - * Args: - * session (DBSessionDep): Database session. - * chat_request (CohereChatRequest): Chat request data. - * request (Request): Request object. - * - * Returns: - * EventSourceResponse: Server-sent event response with chatbot responses. - * @param data The data for the request. - * @param data.requestBody - * @returns ChatResponseEvent Successful Response - * @throws ApiError - */ - public chatStreamV1ChatStreamPost( - data: ChatStreamV1ChatStreamPostData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'POST', - url: '/v1/chat-stream', - body: data.requestBody, - mediaType: 'application/json', - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Chat - * Chat endpoint to handle user messages and return chatbot responses. - * - * Args: - * chat_request (CohereChatRequest): Chat request data. - * session (DBSessionDep): Database session. - * request (Request): Request object. - * - * Returns: - * NonStreamedChatResponse: Chatbot response. - * @param data The data for the request. - * @param data.requestBody - * @returns NonStreamedChatResponse Successful Response - * @throws ApiError - */ - public chatV1ChatPost(data: ChatV1ChatPostData): CancelablePromise { - return this.httpRequest.request({ - method: 'POST', - url: '/v1/chat', - body: data.requestBody, - mediaType: 'application/json', - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Langchain Chat Stream - * @param data The data for the request. - * @param data.requestBody - * @returns unknown Successful Response - * @throws ApiError - */ - public langchainChatStreamV1LangchainChatPost( - data: LangchainChatStreamV1LangchainChatPostData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'POST', - url: '/v1/langchain-chat', - body: data.requestBody, - mediaType: 'application/json', - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Create User - * Create a new user. - * - * Args: - * user (CreateUser): User data to be created. - * session (DBSessionDep): Database session. - * - * Returns: - * User: Created user. - * @param data The data for the request. - * @param data.requestBody - * @returns User Successful Response - * @throws ApiError - */ - public createUserV1UsersPost( - data: CreateUserV1UsersPostData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'POST', - url: '/v1/users', - body: data.requestBody, - mediaType: 'application/json', - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * List Users - * List all users. - * - * Args: - * offset (int): Offset to start the list. - * limit (int): Limit of users to be listed. - * session (DBSessionDep): Database session. - * - * Returns: - * list[User]: List of users. - * @param data The data for the request. - * @param data.offset - * @param data.limit - * @returns User Successful Response - * @throws ApiError - */ - public listUsersV1UsersGet( - data: ListUsersV1UsersGetData = {} - ): CancelablePromise { - return this.httpRequest.request({ - method: 'GET', - url: '/v1/users', - query: { - offset: data.offset, - limit: data.limit, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Get User - * Get a user by ID. - * - * Args: - * user_id (str): User ID. - * session (DBSessionDep): Database session. - * - * Returns: - * User: User with the given ID. - * - * Raises: - * HTTPException: If the user with the given ID is not found. - * @param data The data for the request. - * @param data.userId - * @returns User Successful Response - * @throws ApiError - */ - public getUserV1UsersUserIdGet( - data: GetUserV1UsersUserIdGetData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'GET', - url: '/v1/users/{user_id}', - path: { - user_id: data.userId, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Update User - * Update a user by ID. - * - * Args: - * user_id (str): User ID. - * new_user (UpdateUser): New user data. - * session (DBSessionDep): Database session. - * - * Returns: - * User: Updated user. - * - * Raises: - * HTTPException: If the user with the given ID is not found. - * @param data The data for the request. - * @param data.userId - * @param data.requestBody - * @returns User Successful Response - * @throws ApiError - */ - public updateUserV1UsersUserIdPut( - data: UpdateUserV1UsersUserIdPutData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'PUT', - url: '/v1/users/{user_id}', - path: { - user_id: data.userId, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Delete User - * " - * Delete a user by ID. - * - * Args: - * user_id (str): User ID. - * session (DBSessionDep): Database session. - * - * Returns: - * DeleteUser: Empty response. - * - * Raises: - * HTTPException: If the user with the given ID is not found. - * @param data The data for the request. - * @param data.userId - * @returns DeleteUser Successful Response - * @throws ApiError - */ - public deleteUserV1UsersUserIdDelete( - data: DeleteUserV1UsersUserIdDeleteData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'DELETE', - url: '/v1/users/{user_id}', - path: { - user_id: data.userId, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Get Conversation - * " - * Get a conversation by ID. - * - * Args: - * conversation_id (str): Conversation ID. - * session (DBSessionDep): Database session. - * request (Request): Request object. - * - * Returns: - * Conversation: Conversation with the given ID. - * - * Raises: - * HTTPException: If the conversation with the given ID is not found. - * @param data The data for the request. - * @param data.conversationId - * @returns Conversation Successful Response - * @throws ApiError - */ - public getConversationV1ConversationsConversationIdGet( - data: GetConversationV1ConversationsConversationIdGetData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'GET', - url: '/v1/conversations/{conversation_id}', - path: { - conversation_id: data.conversationId, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Update Conversation - * Update a conversation by ID. - * - * Args: - * conversation_id (str): Conversation ID. - * new_conversation (UpdateConversation): New conversation data. - * session (DBSessionDep): Database session. - * request (Request): Request object. - * - * Returns: - * Conversation: Updated conversation. - * - * Raises: - * HTTPException: If the conversation with the given ID is not found. - * @param data The data for the request. - * @param data.conversationId - * @param data.requestBody - * @returns Conversation Successful Response - * @throws ApiError - */ - public updateConversationV1ConversationsConversationIdPut( - data: UpdateConversationV1ConversationsConversationIdPutData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'PUT', - url: '/v1/conversations/{conversation_id}', - path: { - conversation_id: data.conversationId, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Delete Conversation - * Delete a conversation by ID. - * - * Args: - * conversation_id (str): Conversation ID. - * session (DBSessionDep): Database session. - * request (Request): Request object. - * - * Returns: - * DeleteConversation: Empty response. - * - * Raises: - * HTTPException: If the conversation with the given ID is not found. - * @param data The data for the request. - * @param data.conversationId - * @returns DeleteConversation Successful Response - * @throws ApiError - */ - public deleteConversationV1ConversationsConversationIdDelete( - data: DeleteConversationV1ConversationsConversationIdDeleteData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'DELETE', - url: '/v1/conversations/{conversation_id}', - path: { - conversation_id: data.conversationId, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * List Conversations - * List all conversations. - * - * Args: - * offset (int): Offset to start the list. - * limit (int): Limit of conversations to be listed. - * agent_id (str): Query parameter for agent ID to optionally filter conversations by agent. - * session (DBSessionDep): Database session. - * request (Request): Request object. - * - * Returns: - * list[ConversationWithoutMessages]: List of conversations. - * @param data The data for the request. - * @param data.offset - * @param data.limit - * @param data.agentId - * @returns ConversationWithoutMessages Successful Response - * @throws ApiError - */ - public listConversationsV1ConversationsGet( - data: ListConversationsV1ConversationsGetData = {} - ): CancelablePromise { - return this.httpRequest.request({ - method: 'GET', - url: '/v1/conversations', - query: { - offset: data.offset, - limit: data.limit, - agent_id: data.agentId, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Search Conversations - * Search conversations by title. - * - * Args: - * query (str): Query string to search for in conversation titles. - * session (DBSessionDep): Database session. - * request (Request): Request object. - * - * Returns: - * list[ConversationWithoutMessages]: List of conversations that match the query. - * @param data The data for the request. - * @param data.query - * @param data.offset - * @param data.limit - * @param data.agentId - * @returns ConversationWithoutMessages Successful Response - * @throws ApiError - */ - public searchConversationsV1ConversationsSearchGet( - data: SearchConversationsV1ConversationsSearchGetData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'GET', - url: '/v1/conversations:search', - query: { - query: data.query, - offset: data.offset, - limit: data.limit, - agent_id: data.agentId, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Upload File - * Uploads and creates a File object. - * If no conversation_id is provided, a new Conversation is created as well. - * - * Args: - * session (DBSessionDep): Database session. - * file (FastAPIUploadFile): File to be uploaded. - * conversation_id (Optional[str]): Conversation ID passed from request query parameter. - * - * Returns: - * UploadFile: Uploaded file. - * - * Raises: - * HTTPException: If the conversation with the given ID is not found. Status code 404. - * HTTPException: If the file wasn't uploaded correctly. Status code 500. - * @param data The data for the request. - * @param data.formData - * @returns UploadFile Successful Response - * @throws ApiError - */ - public uploadFileV1ConversationsUploadFilePost( - data: UploadFileV1ConversationsUploadFilePostData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'POST', - url: '/v1/conversations/upload_file', - formData: data.formData, - mediaType: 'multipart/form-data', - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Batch Upload File - * Uploads and creates a batch of File object. - * If no conversation_id is provided, a new Conversation is created as well. - * - * Args: - * session (DBSessionDep): Database session. - * file (list[FastAPIUploadFile]): List of files to be uploaded. - * conversation_id (Optional[str]): Conversation ID passed from request query parameter. - * - * Returns: - * list[UploadFile]: List of uploaded files. - * - * Raises: - * HTTPException: If the conversation with the given ID is not found. Status code 404. - * HTTPException: If the file wasn't uploaded correctly. Status code 500. - * @param data The data for the request. - * @param data.formData - * @returns UploadFile Successful Response - * @throws ApiError - */ - public batchUploadFileV1ConversationsBatchUploadFilePost( - data: BatchUploadFileV1ConversationsBatchUploadFilePostData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'POST', - url: '/v1/conversations/batch_upload_file', - formData: data.formData, - mediaType: 'multipart/form-data', - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * List Files - * List all files from a conversation. Important - no pagination support yet. - * - * Args: - * conversation_id (str): Conversation ID. - * session (DBSessionDep): Database session. - * - * Returns: - * list[ListFile]: List of files from the conversation. - * - * Raises: - * HTTPException: If the conversation with the given ID is not found. - * @param data The data for the request. - * @param data.conversationId - * @returns ListFile Successful Response - * @throws ApiError - */ - public listFilesV1ConversationsConversationIdFilesGet( - data: ListFilesV1ConversationsConversationIdFilesGetData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'GET', - url: '/v1/conversations/{conversation_id}/files', - path: { - conversation_id: data.conversationId, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Update File - * Update a file by ID. - * - * Args: - * conversation_id (str): Conversation ID. - * file_id (str): File ID. - * new_file (UpdateFile): New file data. - * session (DBSessionDep): Database session. - * - * Returns: - * File: Updated file. - * - * Raises: - * HTTPException: If the conversation with the given ID is not found. - * @param data The data for the request. - * @param data.conversationId - * @param data.fileId - * @param data.requestBody - * @returns File Successful Response - * @throws ApiError - */ - public updateFileV1ConversationsConversationIdFilesFileIdPut( - data: UpdateFileV1ConversationsConversationIdFilesFileIdPutData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'PUT', - url: '/v1/conversations/{conversation_id}/files/{file_id}', - path: { - conversation_id: data.conversationId, - file_id: data.fileId, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Delete File - * Delete a file by ID. - * - * Args: - * conversation_id (str): Conversation ID. - * file_id (str): File ID. - * session (DBSessionDep): Database session. - * - * Returns: - * DeleteFile: Empty response. - * - * Raises: - * HTTPException: If the conversation with the given ID is not found. - * @param data The data for the request. - * @param data.conversationId - * @param data.fileId - * @returns DeleteFile Successful Response - * @throws ApiError - */ - public deleteFileV1ConversationsConversationIdFilesFileIdDelete( - data: DeleteFileV1ConversationsConversationIdFilesFileIdDeleteData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'DELETE', - url: '/v1/conversations/{conversation_id}/files/{file_id}', - path: { - conversation_id: data.conversationId, - file_id: data.fileId, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Generate Title - * Generate a title for a conversation and update the conversation with the generated title. - * - * Args: - * conversation_id (str): Conversation ID. - * session (DBSessionDep): Database session. - * - * Returns: - * str: Generated title for the conversation. - * - * Raises: - * HTTPException: If the conversation with the given ID is not found. - * @param data The data for the request. - * @param data.conversationId - * @returns GenerateTitle Successful Response - * @throws ApiError - */ - public generateTitleV1ConversationsConversationIdGenerateTitlePost( - data: GenerateTitleV1ConversationsConversationIdGenerateTitlePostData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'POST', - url: '/v1/conversations/{conversation_id}/generate-title', - path: { - conversation_id: data.conversationId, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * List Tools - * List all available tools. - * - * Returns: - * list[ManagedTool]: List of available tools. - * @param data The data for the request. - * @param data.agentId - * @returns ManagedTool Successful Response - * @throws ApiError - */ - public listToolsV1ToolsGet( - data: ListToolsV1ToolsGetData = {} - ): CancelablePromise { - return this.httpRequest.request({ - method: 'GET', - url: '/v1/tools', - query: { - agent_id: data.agentId, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * List Deployments - * List all available deployments and their models. - * - * Returns: - * list[Deployment]: List of available deployment options. - * @param data The data for the request. - * @param data.all - * @returns Deployment Successful Response - * @throws ApiError - */ - public listDeploymentsV1DeploymentsGet( - data: ListDeploymentsV1DeploymentsGetData = {} - ): CancelablePromise { - return this.httpRequest.request({ - method: 'GET', - url: '/v1/deployments', - query: { - all: data.all, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Set Env Vars - * Set environment variables for the deployment. - * - * Returns: - * str: Empty string. - * @param data The data for the request. - * @param data.name - * @param data.requestBody - * @returns unknown Successful Response - * @throws ApiError - */ - public setEnvVarsV1DeploymentsNameSetEnvVarsPost( - data: SetEnvVarsV1DeploymentsNameSetEnvVarsPostData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'POST', - url: '/v1/deployments/{name}/set_env_vars', - path: { - name: data.name, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * List Experimental Features - * List all experimental features and if they are enabled - * - * Returns: - * Dict[str, bool]: Experimental feature and their isEnabled state - * @returns unknown Successful Response - * @throws ApiError - */ - public listExperimentalFeaturesV1ExperimentalFeaturesGet(): CancelablePromise { - return this.httpRequest.request({ - method: 'GET', - url: '/v1/experimental_features/', - }); - } - - /** - * Create Agent - * Create an agent. - * Args: - * session (DBSessionDep): Database session. - * agent (CreateAgent): Agent data. - * request (Request): Request object. - * Returns: - * AgentPublic: Created agent with no user ID or organization ID. - * Raises: - * HTTPException: If the agent creation fails. - * @param data The data for the request. - * @param data.requestBody - * @returns AgentPublic Successful Response - * @throws ApiError - */ - public createAgentV1AgentsPost( - data: CreateAgentV1AgentsPostData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'POST', - url: '/v1/agents', - body: data.requestBody, - mediaType: 'application/json', - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * List Agents - * List all agents. - * - * Args: - * offset (int): Offset to start the list. - * limit (int): Limit of agents to be listed. - * session (DBSessionDep): Database session. - * request (Request): Request object. - * - * Returns: - * list[AgentPublic]: List of agents with no user ID or organization ID. - * @param data The data for the request. - * @param data.offset - * @param data.limit - * @returns AgentPublic Successful Response - * @throws ApiError - */ - public listAgentsV1AgentsGet( - data: ListAgentsV1AgentsGetData = {} - ): CancelablePromise { - return this.httpRequest.request({ - method: 'GET', - url: '/v1/agents', - query: { - offset: data.offset, - limit: data.limit, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Get Agent By Id - * Args: - * agent_id (str): Agent ID. - * session (DBSessionDep): Database session. - * - * Returns: - * Agent: Agent. - * - * Raises: - * HTTPException: If the agent with the given ID is not found. - * @param data The data for the request. - * @param data.agentId - * @returns Agent Successful Response - * @throws ApiError - */ - public getAgentByIdV1AgentsAgentIdGet( - data: GetAgentByIdV1AgentsAgentIdGetData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'GET', - url: '/v1/agents/{agent_id}', - path: { - agent_id: data.agentId, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Update Agent - * Update an agent by ID. - * - * Args: - * agent_id (str): Agent ID. - * new_agent (UpdateAgent): New agent data. - * session (DBSessionDep): Database session. - * request (Request): Request object. - * - * Returns: - * AgentPublic: Updated agent with no user ID or organization ID. - * - * Raises: - * HTTPException: If the agent with the given ID is not found. - * @param data The data for the request. - * @param data.agentId - * @param data.requestBody - * @returns AgentPublic Successful Response - * @throws ApiError - */ - public updateAgentV1AgentsAgentIdPut( - data: UpdateAgentV1AgentsAgentIdPutData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'PUT', - url: '/v1/agents/{agent_id}', - path: { - agent_id: data.agentId, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Delete Agent - * Delete an agent by ID. - * - * Args: - * agent_id (str): Agent ID. - * session (DBSessionDep): Database session. - * request (Request): Request object. - * - * Returns: - * DeleteAgent: Empty response. - * - * Raises: - * HTTPException: If the agent with the given ID is not found. - * @param data The data for the request. - * @param data.agentId - * @returns DeleteAgent Successful Response - * @throws ApiError - */ - public deleteAgentV1AgentsAgentIdDelete( - data: DeleteAgentV1AgentsAgentIdDeleteData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'DELETE', - url: '/v1/agents/{agent_id}', - path: { - agent_id: data.agentId, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * List Agent Tool Metadata - * List all agent tool metadata by agent ID. - * - * Args: - * agent_id (str): Agent ID. - * session (DBSessionDep): Database session. - * request (Request): Request object. - * - * Returns: - * list[AgentToolMetadataPublic]: List of agent tool metadata with no user ID or organization ID. - * - * Raises: - * HTTPException: If the agent tool metadata retrieval fails. - * @param data The data for the request. - * @param data.agentId - * @returns AgentToolMetadataPublic Successful Response - * @throws ApiError - */ - public listAgentToolMetadataV1AgentsAgentIdToolMetadataGet( - data: ListAgentToolMetadataV1AgentsAgentIdToolMetadataGetData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'GET', - url: '/v1/agents/{agent_id}/tool-metadata', - path: { - agent_id: data.agentId, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Create Agent Tool Metadata - * Create an agent tool metadata. - * - * Args: - * session (DBSessionDep): Database session. - * agent_id (str): Agent ID. - * agent_tool_metadata (CreateAgentToolMetadata): Agent tool metadata data. - * request (Request): Request object. - * - * Returns: - * AgentToolMetadata: Created agent tool metadata. - * - * Raises: - * HTTPException: If the agent tool metadata creation fails. - * @param data The data for the request. - * @param data.agentId - * @param data.requestBody - * @returns AgentToolMetadataPublic Successful Response - * @throws ApiError - */ - public createAgentToolMetadataV1AgentsAgentIdToolMetadataPost( - data: CreateAgentToolMetadataV1AgentsAgentIdToolMetadataPostData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'POST', - url: '/v1/agents/{agent_id}/tool-metadata', - path: { - agent_id: data.agentId, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Update Agent Tool Metadata - * Update an agent tool metadata by ID. - * - * Args: - * agent_id (str): Agent ID. - * agent_tool_metadata_id (str): Agent tool metadata ID. - * session (DBSessionDep): Database session. - * new_agent_tool_metadata (UpdateAgentToolMetadata): New agent tool metadata data. - * request (Request): Request object. - * - * Returns: - * AgentToolMetadata: Updated agent tool metadata. - * - * Raises: - * HTTPException: If the agent tool metadata with the given ID is not found. - * HTTPException: If the agent tool metadata update fails. - * @param data The data for the request. - * @param data.agentId - * @param data.agentToolMetadataId - * @param data.requestBody - * @returns AgentToolMetadata Successful Response - * @throws ApiError - */ - public updateAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdPut( - data: UpdateAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdPutData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'PUT', - url: '/v1/agents/{agent_id}/tool-metadata/{agent_tool_metadata_id}', - path: { - agent_id: data.agentId, - agent_tool_metadata_id: data.agentToolMetadataId, - }, - body: data.requestBody, - mediaType: 'application/json', - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Delete Agent Tool Metadata - * Delete an agent tool metadata by ID. - * - * Args: - * agent_id (str): Agent ID. - * agent_tool_metadata_id (str): Agent tool metadata ID. - * session (DBSessionDep): Database session. - * request (Request): Request object. - * - * Returns: - * DeleteAgentToolMetadata: Empty response. - * - * Raises: - * HTTPException: If the agent tool metadata with the given ID is not found. - * HTTPException: If the agent tool metadata deletion fails. - * @param data The data for the request. - * @param data.agentId - * @param data.agentToolMetadataId - * @returns DeleteAgentToolMetadata Successful Response - * @throws ApiError - */ - public deleteAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdDelete( - data: DeleteAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdDeleteData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'DELETE', - url: '/v1/agents/{agent_id}/tool-metadata/{agent_tool_metadata_id}', - path: { - agent_id: data.agentId, - agent_tool_metadata_id: data.agentToolMetadataId, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * List Snapshots - * List all snapshots. - * - * Args: - * session (DBSessionDep): Database session. - * request (Request): HTTP request object. - * - * Returns: - * list[Snapshot]: List of all snapshots. - * @returns SnapshotWithLinks Successful Response - * @throws ApiError - */ - public listSnapshotsV1SnapshotsGet(): CancelablePromise { - return this.httpRequest.request({ - method: 'GET', - url: '/v1/snapshots', - }); - } - - /** - * Create Snapshot - * Create a new snapshot and snapshot link to share the conversation. - * - * Args: - * snapshot_request (CreateSnapshot): Snapshot creation request. - * session (DBSessionDep): Database session. - * request (Request): HTTP request object. - * - * Returns: - * CreateSnapshotResponse: Snapshot creation response. - * @param data The data for the request. - * @param data.requestBody - * @returns CreateSnapshotResponse Successful Response - * @throws ApiError - */ - public createSnapshotV1SnapshotsPost( - data: CreateSnapshotV1SnapshotsPostData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'POST', - url: '/v1/snapshots', - body: data.requestBody, - mediaType: 'application/json', - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Get Snapshot - * Get a snapshot by link ID. - * - * Args: - * link_id (str): Snapshot link ID. - * session (DBSessionDep): Database session. - * request (Request): HTTP request object. - * - * Returns: - * Snapshot: Snapshot with the given link ID. - * @param data The data for the request. - * @param data.linkId - * @returns Snapshot Successful Response - * @throws ApiError - */ - public getSnapshotV1SnapshotsLinkLinkIdGet( - data: GetSnapshotV1SnapshotsLinkLinkIdGetData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'GET', - url: '/v1/snapshots/link/{link_id}', - path: { - link_id: data.linkId, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Delete Snapshot Link - * Delete a snapshot link by ID. - * - * Args: - * link_id (str): Snapshot link ID. - * session (DBSessionDep): Database session. - * request (Request): HTTP request object. - * - * Returns: - * Any: Empty response. - * @param data The data for the request. - * @param data.linkId - * @returns unknown Successful Response - * @throws ApiError - */ - public deleteSnapshotLinkV1SnapshotsLinkLinkIdDelete( - data: DeleteSnapshotLinkV1SnapshotsLinkLinkIdDeleteData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'DELETE', - url: '/v1/snapshots/link/{link_id}', - path: { - link_id: data.linkId, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Delete Snapshot - * Delete a snapshot by ID. - * - * Args: - * snapshot_id (str): Snapshot ID. - * session (DBSessionDep): Database session. - * request (Request): HTTP request object. - * - * Returns: - * Any: Empty response. - * @param data The data for the request. - * @param data.snapshotId - * @returns unknown Successful Response - * @throws ApiError - */ - public deleteSnapshotV1SnapshotsSnapshotIdDelete( - data: DeleteSnapshotV1SnapshotsSnapshotIdDeleteData - ): CancelablePromise { - return this.httpRequest.request({ - method: 'DELETE', - url: '/v1/snapshots/{snapshot_id}', - path: { - snapshot_id: data.snapshotId, - }, - errors: { - 422: 'Validation Error', - }, - }); - } - - /** - * Health - * Health check for backend APIs - * @returns unknown Successful Response - * @throws ApiError - */ - public healthHealthGet(): CancelablePromise { - return this.httpRequest.request({ - method: 'GET', - url: '/health', - }); - } - - /** - * Apply Migrations - * Applies Alembic migrations - useful for serverless applications - * @returns unknown Successful Response - * @throws ApiError - */ - public applyMigrationsMigratePost(): CancelablePromise { - return this.httpRequest.request({ - method: 'POST', - url: '/migrate', - }); - } -} + constructor(public readonly httpRequest: BaseHttpRequest) { } + + /** + * Get Strategies + * Retrieves the currently enabled list of Authentication strategies. + * + * Args: + * ctx (Context): Context object. + * Returns: + * List[dict]: List of dictionaries containing the enabled auth strategy names. + * @returns ListAuthStrategy Successful Response + * @throws ApiError + */ + public getStrategiesV1AuthStrategiesGet(): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/auth_strategies' + }); + } + + /** + * Login + * Logs user in, performing basic email/password auth. + * Verifies their credentials, retrieves the user and returns a JWT token. + * + * Args: + * login (Login): Login payload. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * dict: JWT token on Basic auth success + * + * Raises: + * HTTPException: If the strategy or payload are invalid, or if the login fails. + * @param data The data for the request. + * @param data.requestBody + * @returns unknown Successful Response + * @throws ApiError + */ + public loginV1LoginPost(data: LoginV1LoginPostData): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/v1/login', + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Authorize + * Callback authorization endpoint used for OAuth providers after authenticating on the provider's login screen. + * + * Args: + * strategy (str): Current strategy name. + * request (Request): Current Request object. + * session (Session): DB session. + * code (str): OAuth code. + * ctx (Context): Context object. + * + * Returns: + * dict: Containing "token" key, on success. + * + * Raises: + * HTTPException: If authentication fails, or strategy is invalid. + * @param data The data for the request. + * @param data.strategy + * @param data.code + * @returns JWTResponse Successful Response + * @throws ApiError + */ + public authorizeV1StrategyAuthPost(data: AuthorizeV1StrategyAuthPostData): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/v1/{strategy}/auth', + path: { + strategy: data.strategy + }, + query: { + code: data.code + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Logout + * Logs out the current user, adding the given JWT token to the blacklist. + * + * Args: + * request (Request): current Request object. + * session (DBSessionDep): Database session. + * token (dict): JWT token payload. + * ctx (Context): Context object. + * + * Returns: + * dict: Empty on success + * @returns Logout Successful Response + * @throws ApiError + */ + public logoutV1LogoutGet(): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/logout' + }); + } + + /** + * Tool Auth + * Endpoint for Tool Authentication. Note: The flow is different from + * the regular login OAuth flow, the backend initiates it and redirects to the frontend + * after completion. + * + * If completed, a ToolAuth is stored in the DB containing the access token for the tool. + * + * Args: + * request (Request): current Request object. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * RedirectResponse: A redirect pointing to the frontend, contains an error query parameter if + * an unexpected error happens during the authentication. + * + * Raises: + * HTTPException: If no redirect_uri set. + * @returns unknown Successful Response + * @throws ApiError + */ + public toolAuthV1ToolAuthGet(): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/tool/auth' + }); + } + + /** + * Delete Tool Auth + * Endpoint to delete Tool Authentication. + * + * If completed, the corresponding ToolAuth for the requesting user is removed from the DB. + * + * Args: + * tool_id (str): Tool ID to be deleted for the user. (eg. google_drive) Should be one of the values listed in the ToolName string enum class. + * request (Request): current Request object. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * DeleteToolAuth: Empty response. + * + * Raises: + * HTTPException: If there was an error deleting the tool auth. + * @param data The data for the request. + * @param data.toolId + * @returns DeleteToolAuth Successful Response + * @throws ApiError + */ + public deleteToolAuthV1ToolAuthToolIdDelete(data: DeleteToolAuthV1ToolAuthToolIdDeleteData): CancelablePromise { + return this.httpRequest.request({ + method: 'DELETE', + url: '/v1/tool/auth/{tool_id}', + path: { + tool_id: data.toolId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Chat Stream + * Stream chat endpoint to handle user messages and return chatbot responses. + * + * Args: + * session (DBSessionDep): Database session. + * chat_request (CohereChatRequest): Chat request data. + * request (Request): Request object. + * ctx (Context): Context object. + * + * Returns: + * EventSourceResponse: Server-sent event response with chatbot responses. + * @param data The data for the request. + * @param data.requestBody + * @returns ChatResponseEvent Successful Response + * @throws ApiError + */ + public chatStreamV1ChatStreamPost(data: ChatStreamV1ChatStreamPostData): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/v1/chat-stream', + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Regenerate Chat Stream + * Endpoint to regenerate stream chat response for the last user message. + * + * Args: + * session (DBSessionDep): Database session. + * chat_request (CohereChatRequest): Chat request data. + * request (Request): Request object. + * ctx (Context): Context object. + * + * Returns: + * EventSourceResponse: Server-sent event response with chatbot responses. + * @param data The data for the request. + * @param data.requestBody + * @returns unknown Successful Response + * @throws ApiError + */ + public regenerateChatStreamV1ChatStreamRegeneratePost(data: RegenerateChatStreamV1ChatStreamRegeneratePostData): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/v1/chat-stream/regenerate', + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Chat + * Chat endpoint to handle user messages and return chatbot responses. + * + * Args: + * chat_request (CohereChatRequest): Chat request data. + * session (DBSessionDep): Database session. + * request (Request): Request object. + * ctx (Context): Context object. + * + * Returns: + * NonStreamedChatResponse: Chatbot response. + * @param data The data for the request. + * @param data.requestBody + * @returns NonStreamedChatResponse Successful Response + * @throws ApiError + */ + public chatV1ChatPost(data: ChatV1ChatPostData): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/v1/chat', + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Create User + * Create a new user. + * + * Args: + * user (CreateUser): User data to be created. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * User: Created user. + * @param data The data for the request. + * @param data.requestBody + * @returns backend__schemas__user__User Successful Response + * @throws ApiError + */ + public createUserV1UsersPost(data: CreateUserV1UsersPostData): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/v1/users', + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * List Users + * List all users. + * + * Args: + * offset (int): Offset to start the list. + * limit (int): Limit of users to be listed. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * list[User]: List of users. + * @param data The data for the request. + * @param data.offset + * @param data.limit + * @returns backend__schemas__user__User Successful Response + * @throws ApiError + */ + public listUsersV1UsersGet(data: ListUsersV1UsersGetData = {}): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/users', + query: { + offset: data.offset, + limit: data.limit + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Get User + * Get a user by ID. + * + * Args: + * user_id (str): User ID. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * User: User with the given ID. + * + * Raises: + * HTTPException: If the user with the given ID is not found. + * @param data The data for the request. + * @param data.userId + * @returns backend__schemas__user__User Successful Response + * @throws ApiError + */ + public getUserV1UsersUserIdGet(data: GetUserV1UsersUserIdGetData): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/users/{user_id}', + path: { + user_id: data.userId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Update User + * Update a user by ID. + * + * Args: + * user_id (str): User ID. + * new_user (UpdateUser): New user data. + * session (DBSessionDep): Database session. + * request (Request): Request object. + * ctx (Context): Context object + * + * Returns: + * User: Updated user. + * + * Raises: + * HTTPException: If the user with the given ID is not found. + * @param data The data for the request. + * @param data.userId + * @param data.requestBody + * @returns backend__schemas__user__User Successful Response + * @throws ApiError + */ + public updateUserV1UsersUserIdPut(data: UpdateUserV1UsersUserIdPutData): CancelablePromise { + return this.httpRequest.request({ + method: 'PUT', + url: '/v1/users/{user_id}', + path: { + user_id: data.userId + }, + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Delete User + * " + * Delete a user by ID. + * + * Args: + * user_id (str): User ID. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * DeleteUser: Empty response. + * + * Raises: + * HTTPException: If the user with the given ID is not found. + * @param data The data for the request. + * @param data.userId + * @returns DeleteUser Successful Response + * @throws ApiError + */ + public deleteUserV1UsersUserIdDelete(data: DeleteUserV1UsersUserIdDeleteData): CancelablePromise { + return this.httpRequest.request({ + method: 'DELETE', + url: '/v1/users/{user_id}', + path: { + user_id: data.userId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Get Conversation + * Get a conversation by ID. + * + * Args: + * conversation_id (str): Conversation ID. + * session (DBSessionDep): Database session. + * request (Request): Request object. + * + * Returns: + * ConversationPublic: Conversation with the given ID. + * + * Raises: + * HTTPException: If the conversation with the given ID is not found. + * @param data The data for the request. + * @param data.conversationId + * @returns ConversationPublic Successful Response + * @throws ApiError + */ + public getConversationV1ConversationsConversationIdGet(data: GetConversationV1ConversationsConversationIdGetData): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/conversations/{conversation_id}', + path: { + conversation_id: data.conversationId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Update Conversation + * Update a conversation by ID. + * + * Args: + * conversation_id (str): Conversation ID. + * new_conversation (UpdateConversationRequest): New conversation data. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * ConversationPublic: Updated conversation. + * + * Raises: + * HTTPException: If the conversation with the given ID is not found. + * @param data The data for the request. + * @param data.conversationId + * @param data.requestBody + * @returns ConversationPublic Successful Response + * @throws ApiError + */ + public updateConversationV1ConversationsConversationIdPut(data: UpdateConversationV1ConversationsConversationIdPutData): CancelablePromise { + return this.httpRequest.request({ + method: 'PUT', + url: '/v1/conversations/{conversation_id}', + path: { + conversation_id: data.conversationId + }, + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Delete Conversation + * Delete a conversation by ID. + * + * Args: + * conversation_id (str): Conversation ID. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * DeleteConversationResponse: Empty response. + * + * Raises: + * HTTPException: If the conversation with the given ID is not found. + * @param data The data for the request. + * @param data.conversationId + * @returns DeleteConversationResponse Successful Response + * @throws ApiError + */ + public deleteConversationV1ConversationsConversationIdDelete(data: DeleteConversationV1ConversationsConversationIdDeleteData): CancelablePromise { + return this.httpRequest.request({ + method: 'DELETE', + url: '/v1/conversations/{conversation_id}', + path: { + conversation_id: data.conversationId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * List Conversations + * List all conversations. + * + * Args: + * offset (int): Offset to start the list. + * limit (int): Limit of conversations to be listed. + * order_by (str): A field by which to order the conversations. + * agent_id (str): Query parameter for agent ID to optionally filter conversations by agent. + * session (DBSessionDep): Database session. + * request (Request): Request object. + * + * Returns: + * list[ConversationWithoutMessages]: List of conversations. + * @param data The data for the request. + * @param data.offset + * @param data.limit + * @param data.orderBy + * @param data.agentId + * @returns ConversationWithoutMessages Successful Response + * @throws ApiError + */ + public listConversationsV1ConversationsGet(data: ListConversationsV1ConversationsGetData = {}): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/conversations', + query: { + offset: data.offset, + limit: data.limit, + order_by: data.orderBy, + agent_id: data.agentId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Toggle Conversation Pin + * @param data The data for the request. + * @param data.conversationId + * @param data.requestBody + * @returns ConversationWithoutMessages Successful Response + * @throws ApiError + */ + public toggleConversationPinV1ConversationsConversationIdTogglePinPut(data: ToggleConversationPinV1ConversationsConversationIdTogglePinPutData): CancelablePromise { + return this.httpRequest.request({ + method: 'PUT', + url: '/v1/conversations/{conversation_id}/toggle-pin', + path: { + conversation_id: data.conversationId + }, + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Search Conversations + * Search conversations by title. + * + * Args: + * query (str): Query string to search for in conversation titles. + * session (DBSessionDep): Database session. + * request (Request): Request object. + * offset (int): Offset to start the list. + * limit (int): Limit of conversations to be listed. + * agent_id (str): Query parameter for agent ID to optionally filter conversations by agent. + * ctx (Context): Context object. + * + * Returns: + * list[ConversationWithoutMessages]: List of conversations that match the query. + * @param data The data for the request. + * @param data.query + * @param data.offset + * @param data.limit + * @param data.agentId + * @returns ConversationWithoutMessages Successful Response + * @throws ApiError + */ + public searchConversationsV1ConversationsSearchGet(data: SearchConversationsV1ConversationsSearchGetData): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/conversations:search', + query: { + query: data.query, + offset: data.offset, + limit: data.limit, + agent_id: data.agentId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Batch Upload File + * Uploads and creates a batch of File object. + * If no conversation_id is provided, a new Conversation is created as well. + * + * Args: + * session (DBSessionDep): Database session. + * conversation_id (Optional[str]): Conversation ID passed from request query parameter. + * files (list[FastAPIUploadFile]): List of files to be uploaded. + * ctx (Context): Context object. + * + * Returns: + * list[UploadConversationFileResponse]: List of uploaded files. + * + * Raises: + * HTTPException: If the conversation with the given ID is not found. Status code 404. + * HTTPException: If the file wasn't uploaded correctly. Status code 500. + * @param data The data for the request. + * @param data.formData + * @returns UploadConversationFileResponse Successful Response + * @throws ApiError + */ + public batchUploadFileV1ConversationsBatchUploadFilePost(data: BatchUploadFileV1ConversationsBatchUploadFilePostData): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/v1/conversations/batch_upload_file', + formData: data.formData, + mediaType: 'multipart/form-data', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * List Files + * List all files from a conversation. Important - no pagination support yet. + * + * Args: + * conversation_id (str): Conversation ID. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * list[ListConversationFile]: List of files from the conversation. + * + * Raises: + * HTTPException: If the conversation with the given ID is not found. + * @param data The data for the request. + * @param data.conversationId + * @returns ListConversationFile Successful Response + * @throws ApiError + */ + public listFilesV1ConversationsConversationIdFilesGet(data: ListFilesV1ConversationsConversationIdFilesGetData): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/conversations/{conversation_id}/files', + path: { + conversation_id: data.conversationId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Delete File + * Delete a file by ID. + * + * Args: + * conversation_id (str): Conversation ID. + * file_id (str): File ID. + * session (DBSessionDep): Database session. + * + * Returns: + * DeleteFile: Empty response. + * + * Raises: + * HTTPException: If the conversation with the given ID is not found. + * @param data The data for the request. + * @param data.conversationId + * @param data.fileId + * @returns DeleteConversationFileResponse Successful Response + * @throws ApiError + */ + public deleteFileV1ConversationsConversationIdFilesFileIdDelete(data: DeleteFileV1ConversationsConversationIdFilesFileIdDeleteData): CancelablePromise { + return this.httpRequest.request({ + method: 'DELETE', + url: '/v1/conversations/{conversation_id}/files/{file_id}', + path: { + conversation_id: data.conversationId, + file_id: data.fileId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Generate Title + * Generate a title for a conversation and update the conversation with the generated title. + * + * Args: + * conversation_id (str): Conversation ID. + * session (DBSessionDep): Database session. + * request (Request): Request object. + * ctx (Context): Context object. + * + * Returns: + * str: Generated title for the conversation. + * + * Raises: + * HTTPException: If the conversation with the given ID is not found. + * @param data The data for the request. + * @param data.conversationId + * @param data.model + * @returns GenerateTitleResponse Successful Response + * @throws ApiError + */ + public generateTitleV1ConversationsConversationIdGenerateTitlePost(data: GenerateTitleV1ConversationsConversationIdGenerateTitlePostData): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/v1/conversations/{conversation_id}/generate-title', + path: { + conversation_id: data.conversationId + }, + query: { + model: data.model + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Synthesize Message + * Generate a synthesized audio for a specific message in a conversation. + * + * Args: + * conversation_id (str): Conversation ID. + * message_id (str): Message ID. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * Response: Synthesized audio file. + * + * Raises: + * HTTPException: If the message with the given ID is not found or synthesis fails. + * @param data The data for the request. + * @param data.conversationId + * @param data.messageId + * @returns unknown Successful Response + * @throws ApiError + */ + public synthesizeMessageV1ConversationsConversationIdSynthesizeMessageIdGet(data: SynthesizeMessageV1ConversationsConversationIdSynthesizeMessageIdGetData): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/conversations/{conversation_id}/synthesize/{message_id}', + path: { + conversation_id: data.conversationId, + message_id: data.messageId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * List Tools + * List all available tools. + * + * Args: + * request (Request): The request to validate + * session (DBSessionDep): Database session. + * agent_id (str): Agent ID. + * ctx (Context): Context object. + * Returns: + * list[ManagedTool]: List of available tools. + * @param data The data for the request. + * @param data.agentId + * @returns ManagedTool Successful Response + * @throws ApiError + */ + public listToolsV1ToolsGet(data: ListToolsV1ToolsGetData = {}): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/tools', + query: { + agent_id: data.agentId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Create Deployment + * Create a new deployment. + * + * Args: + * deployment (DeploymentCreate): Deployment data to be created. + * session (DBSessionDep): Database session. + * + * Returns: + * DeploymentDefinition: Created deployment. + * @param data The data for the request. + * @param data.requestBody + * @returns DeploymentDefinition Successful Response + * @throws ApiError + */ + public createDeploymentV1DeploymentsPost(data: CreateDeploymentV1DeploymentsPostData): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/v1/deployments', + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * List Deployments + * List all available deployments and their models. + * + * Args: + * session (DBSessionDep) + * all (bool): Include all deployments, regardless of availability. + * ctx (Context): Context object. + * Returns: + * list[Deployment]: List of available deployment options. + * @param data The data for the request. + * @param data.all + * @returns DeploymentDefinition Successful Response + * @throws ApiError + */ + public listDeploymentsV1DeploymentsGet(data: ListDeploymentsV1DeploymentsGetData = {}): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/deployments', + query: { + all: data.all + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Update Deployment + * Update a deployment. + * + * Args: + * deployment_id (str): Deployment ID. + * new_deployment (DeploymentUpdate): Deployment data to be updated. + * session (DBSessionDep): Database session. + * + * Returns: + * Deployment: Updated deployment. + * + * Raises: + * HTTPException: If deployment not found. + * @param data The data for the request. + * @param data.deploymentId + * @param data.requestBody + * @returns DeploymentDefinition Successful Response + * @throws ApiError + */ + public updateDeploymentV1DeploymentsDeploymentIdPut(data: UpdateDeploymentV1DeploymentsDeploymentIdPutData): CancelablePromise { + return this.httpRequest.request({ + method: 'PUT', + url: '/v1/deployments/{deployment_id}', + path: { + deployment_id: data.deploymentId + }, + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Get Deployment + * Get a deployment by ID. + * + * Returns: + * Deployment: Deployment with the given ID. + * @param data The data for the request. + * @param data.deploymentId + * @returns DeploymentDefinition Successful Response + * @throws ApiError + */ + public getDeploymentV1DeploymentsDeploymentIdGet(data: GetDeploymentV1DeploymentsDeploymentIdGetData): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/deployments/{deployment_id}', + path: { + deployment_id: data.deploymentId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Delete Deployment + * Delete a deployment by ID. + * + * Args: + * deployment_id (str): Deployment ID. + * session (DBSessionDep): Database session. + * request (Request): Request object. + * + * Returns: + * DeleteDeployment: Empty response. + * + * Raises: + * HTTPException: If the deployment with the given ID is not found. + * @param data The data for the request. + * @param data.deploymentId + * @returns DeleteDeployment Successful Response + * @throws ApiError + */ + public deleteDeploymentV1DeploymentsDeploymentIdDelete(data: DeleteDeploymentV1DeploymentsDeploymentIdDeleteData): CancelablePromise { + return this.httpRequest.request({ + method: 'DELETE', + url: '/v1/deployments/{deployment_id}', + path: { + deployment_id: data.deploymentId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Update Config + * Set environment variables for the deployment. + * + * Args: + * name (str): Deployment name. + * env_vars (UpdateDeploymentEnv): Environment variables to set. + * valid_env_vars (str): Validated environment variables. + * ctx (Context): Context object. + * Returns: + * str: Empty string. + * @param data The data for the request. + * @param data.deploymentId + * @param data.requestBody + * @returns unknown Successful Response + * @throws ApiError + */ + public updateConfigV1DeploymentsDeploymentIdUpdateConfigPost(data: UpdateConfigV1DeploymentsDeploymentIdUpdateConfigPostData): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/v1/deployments/{deployment_id}/update_config', + path: { + deployment_id: data.deploymentId + }, + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * List Experimental Features + * List all experimental features and if they are enabled + * + * Args: + * ctx (Context): Context object. + * Returns: + * Dict[str, bool]: Experimental feature and their isEnabled state + * @returns boolean Successful Response + * @throws ApiError + */ + public listExperimentalFeaturesV1ExperimentalFeaturesGet(): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/experimental_features/' + }); + } + + /** + * Create Agent + * Create an agent. + * + * Args: + * session (DBSessionDep): Database session. + * agent (CreateAgentRequest): Agent data. + * ctx (Context): Context object. + * Returns: + * AgentPublic: Created agent with no user ID or organization ID. + * Raises: + * HTTPException: If the agent creation fails. + * @param data The data for the request. + * @param data.requestBody + * @returns AgentPublic Successful Response + * @throws ApiError + */ + public createAgentV1AgentsPost(data: CreateAgentV1AgentsPostData): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/v1/agents', + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * List Agents + * List all agents. + * + * Args: + * offset (int): Offset to start the list. + * limit (int): Limit of agents to be listed. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * list[AgentPublic]: List of agents with no user ID or organization ID. + * @param data The data for the request. + * @param data.offset + * @param data.limit + * @param data.visibility + * @param data.organizationId + * @returns AgentPublic Successful Response + * @throws ApiError + */ + public listAgentsV1AgentsGet(data: ListAgentsV1AgentsGetData = {}): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/agents', + query: { + offset: data.offset, + limit: data.limit, + visibility: data.visibility, + organization_id: data.organizationId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Get Agent By Id + * Args: + * agent_id (str): Agent ID. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * Agent: Agent. + * + * Raises: + * HTTPException: If the agent with the given ID is not found. + * @param data The data for the request. + * @param data.agentId + * @returns AgentPublic Successful Response + * @throws ApiError + */ + public getAgentByIdV1AgentsAgentIdGet(data: GetAgentByIdV1AgentsAgentIdGetData): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/agents/{agent_id}', + path: { + agent_id: data.agentId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Update Agent + * Update an agent by ID. + * + * Args: + * agent_id (str): Agent ID. + * new_agent (UpdateAgentRequest): New agent data. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * AgentPublic: Updated agent with no user ID or organization ID. + * + * Raises: + * HTTPException: If the agent with the given ID is not found. + * @param data The data for the request. + * @param data.agentId + * @param data.requestBody + * @returns AgentPublic Successful Response + * @throws ApiError + */ + public updateAgentV1AgentsAgentIdPut(data: UpdateAgentV1AgentsAgentIdPutData): CancelablePromise { + return this.httpRequest.request({ + method: 'PUT', + url: '/v1/agents/{agent_id}', + path: { + agent_id: data.agentId + }, + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Delete Agent + * Delete an agent by ID. + * + * Args: + * agent_id (str): Agent ID. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * DeleteAgent: Empty response. + * + * Raises: + * HTTPException: If the agent with the given ID is not found. + * @param data The data for the request. + * @param data.agentId + * @returns DeleteAgent Successful Response + * @throws ApiError + */ + public deleteAgentV1AgentsAgentIdDelete(data: DeleteAgentV1AgentsAgentIdDeleteData): CancelablePromise { + return this.httpRequest.request({ + method: 'DELETE', + url: '/v1/agents/{agent_id}', + path: { + agent_id: data.agentId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Get Agent Deployments + * Args: + * agent_id (str): Agent ID. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * Agent: Agent. + * + * Raises: + * HTTPException: If the agent with the given ID is not found. + * @param data The data for the request. + * @param data.agentId + * @returns DeploymentDefinition Successful Response + * @throws ApiError + */ + public getAgentDeploymentsV1AgentsAgentIdDeploymentsGet(data: GetAgentDeploymentsV1AgentsAgentIdDeploymentsGetData): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/agents/{agent_id}/deployments', + path: { + agent_id: data.agentId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * List Agent Tool Metadata + * List all agent tool metadata by agent ID. + * + * Args: + * agent_id (str): Agent ID. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * list[AgentToolMetadataPublic]: List of agent tool metadata with no user ID or organization ID. + * + * Raises: + * HTTPException: If the agent tool metadata retrieval fails. + * @param data The data for the request. + * @param data.agentId + * @returns AgentToolMetadataPublic Successful Response + * @throws ApiError + */ + public listAgentToolMetadataV1AgentsAgentIdToolMetadataGet(data: ListAgentToolMetadataV1AgentsAgentIdToolMetadataGetData): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/agents/{agent_id}/tool-metadata', + path: { + agent_id: data.agentId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Create Agent Tool Metadata + * Create an agent tool metadata. + * + * Args: + * session (DBSessionDep): Database session. + * agent_id (str): Agent ID. + * agent_tool_metadata (CreateAgentToolMetadataRequest): Agent tool metadata data. + * ctx (Context): Context object. + * + * Returns: + * AgentToolMetadataPublic: Created agent tool metadata. + * + * Raises: + * HTTPException: If the agent tool metadata creation fails. + * @param data The data for the request. + * @param data.agentId + * @param data.requestBody + * @returns AgentToolMetadataPublic Successful Response + * @throws ApiError + */ + public createAgentToolMetadataV1AgentsAgentIdToolMetadataPost(data: CreateAgentToolMetadataV1AgentsAgentIdToolMetadataPostData): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/v1/agents/{agent_id}/tool-metadata', + path: { + agent_id: data.agentId + }, + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Update Agent Tool Metadata + * Update an agent tool metadata by ID. + * + * Args: + * agent_id (str): Agent ID. + * agent_tool_metadata_id (str): Agent tool metadata ID. + * session (DBSessionDep): Database session. + * new_agent_tool_metadata (UpdateAgentToolMetadataRequest): New agent tool metadata data. + * ctx (Context): Context object. + * + * Returns: + * AgentToolMetadata: Updated agent tool metadata. + * + * Raises: + * HTTPException: If the agent tool metadata with the given ID is not found. + * HTTPException: If the agent tool metadata update fails. + * @param data The data for the request. + * @param data.agentId + * @param data.agentToolMetadataId + * @param data.requestBody + * @returns AgentToolMetadata Successful Response + * @throws ApiError + */ + public updateAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdPut(data: UpdateAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdPutData): CancelablePromise { + return this.httpRequest.request({ + method: 'PUT', + url: '/v1/agents/{agent_id}/tool-metadata/{agent_tool_metadata_id}', + path: { + agent_id: data.agentId, + agent_tool_metadata_id: data.agentToolMetadataId + }, + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Delete Agent Tool Metadata + * Delete an agent tool metadata by ID. + * + * Args: + * agent_id (str): Agent ID. + * agent_tool_metadata_id (str): Agent tool metadata ID. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * DeleteAgentToolMetadata: Empty response. + * + * Raises: + * HTTPException: If the agent tool metadata with the given ID is not found. + * HTTPException: If the agent tool metadata deletion fails. + * @param data The data for the request. + * @param data.agentId + * @param data.agentToolMetadataId + * @returns DeleteAgentToolMetadata Successful Response + * @throws ApiError + */ + public deleteAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdDelete(data: DeleteAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdDeleteData): CancelablePromise { + return this.httpRequest.request({ + method: 'DELETE', + url: '/v1/agents/{agent_id}/tool-metadata/{agent_tool_metadata_id}', + path: { + agent_id: data.agentId, + agent_tool_metadata_id: data.agentToolMetadataId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Batch Upload File + * @param data The data for the request. + * @param data.formData + * @returns UploadAgentFileResponse Successful Response + * @throws ApiError + */ + public batchUploadFileV1AgentsBatchUploadFilePost(data: BatchUploadFileV1AgentsBatchUploadFilePostData): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/v1/agents/batch_upload_file', + formData: data.formData, + mediaType: 'multipart/form-data', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Delete Agent File + * Delete an agent file by ID. + * + * Args: + * agent_id (str): Agent ID. + * file_id (str): File ID. + * session (DBSessionDep): Database session. + * + * Returns: + * DeleteFile: Empty response. + * + * Raises: + * HTTPException: If the agent with the given ID is not found. + * @param data The data for the request. + * @param data.agentId + * @param data.fileId + * @returns DeleteAgentFileResponse Successful Response + * @throws ApiError + */ + public deleteAgentFileV1AgentsAgentIdFilesFileIdDelete(data: DeleteAgentFileV1AgentsAgentIdFilesFileIdDeleteData): CancelablePromise { + return this.httpRequest.request({ + method: 'DELETE', + url: '/v1/agents/{agent_id}/files/{file_id}', + path: { + agent_id: data.agentId, + file_id: data.fileId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * List Snapshots + * List all snapshots. + * + * Args: + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * list[SnapshotWithLinks]: List of all snapshots with their links. + * @returns SnapshotWithLinks Successful Response + * @throws ApiError + */ + public listSnapshotsV1SnapshotsGet(): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/snapshots' + }); + } + + /** + * Create Snapshot + * Create a new snapshot and snapshot link to share the conversation. + * + * Args: + * snapshot_request (CreateSnapshotRequest): Snapshot creation request. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * CreateSnapshotResponse: Snapshot creation response. + * @param data The data for the request. + * @param data.requestBody + * @returns CreateSnapshotResponse Successful Response + * @throws ApiError + */ + public createSnapshotV1SnapshotsPost(data: CreateSnapshotV1SnapshotsPostData): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/v1/snapshots', + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Get Snapshot + * Get a snapshot by link ID. + * + * Args: + * link_id (str): Snapshot link ID. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * Snapshot: Snapshot with the given link ID. + * @param data The data for the request. + * @param data.linkId + * @returns SnapshotPublic Successful Response + * @throws ApiError + */ + public getSnapshotV1SnapshotsLinkLinkIdGet(data: GetSnapshotV1SnapshotsLinkLinkIdGetData): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/snapshots/link/{link_id}', + path: { + link_id: data.linkId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Delete Snapshot Link + * Delete a snapshot link by ID. + * + * Args: + * link_id (str): Snapshot link ID. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * DeleteSnapshotLinkResponse: Empty response. + * @param data The data for the request. + * @param data.linkId + * @returns DeleteSnapshotLinkResponse Successful Response + * @throws ApiError + */ + public deleteSnapshotLinkV1SnapshotsLinkLinkIdDelete(data: DeleteSnapshotLinkV1SnapshotsLinkLinkIdDeleteData): CancelablePromise { + return this.httpRequest.request({ + method: 'DELETE', + url: '/v1/snapshots/link/{link_id}', + path: { + link_id: data.linkId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Delete Snapshot + * Delete a snapshot by ID. + * + * Args: + * snapshot_id (str): Snapshot ID. + * session (DBSessionDep): Database session. + * ctx (Context): Context object. + * + * Returns: + * DeleteSnapshotResponse: Empty response. + * @param data The data for the request. + * @param data.snapshotId + * @returns DeleteSnapshotResponse Successful Response + * @throws ApiError + */ + public deleteSnapshotV1SnapshotsSnapshotIdDelete(data: DeleteSnapshotV1SnapshotsSnapshotIdDeleteData): CancelablePromise { + return this.httpRequest.request({ + method: 'DELETE', + url: '/v1/snapshots/{snapshot_id}', + path: { + snapshot_id: data.snapshotId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * List Organizations + * List all available organizations. + * + * Args: + * request (Request): Request object. + * session (DBSessionDep): Database session. + * + * Returns: + * list[ManagedTool]: List of available organizations. + * @returns Organization Successful Response + * @throws ApiError + */ + public listOrganizationsV1OrganizationsGet(): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/organizations' + }); + } + + /** + * Create Organization + * Create a new organization. + * + * Args: + * organization (CreateOrganization): Organization data + * session (DBSessionDep): Database session. + * + * Returns: + * Organization: Created organization. + * @param data The data for the request. + * @param data.requestBody + * @returns Organization Successful Response + * @throws ApiError + */ + public createOrganizationV1OrganizationsPost(data: CreateOrganizationV1OrganizationsPostData): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/v1/organizations', + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Update Organization + * Update organization by ID. + * + * Args: + * organization_id (str): Tool ID. + * new_organization (ToolUpdate): New organization data. + * session (DBSessionDep): Database session. + * + * Returns: + * Organization: Updated organization. + * @param data The data for the request. + * @param data.organizationId + * @param data.requestBody + * @returns Organization Successful Response + * @throws ApiError + */ + public updateOrganizationV1OrganizationsOrganizationIdPut(data: UpdateOrganizationV1OrganizationsOrganizationIdPutData): CancelablePromise { + return this.httpRequest.request({ + method: 'PUT', + url: '/v1/organizations/{organization_id}', + path: { + organization_id: data.organizationId + }, + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Get Organization + * Get a organization by ID. + * + * Args: + * organization_id (str): Tool ID. + * session (DBSessionDep): Database session. + * + * Returns: + * ManagedTool: Organization with the given ID. + * @param data The data for the request. + * @param data.organizationId + * @returns Organization Successful Response + * @throws ApiError + */ + public getOrganizationV1OrganizationsOrganizationIdGet(data: GetOrganizationV1OrganizationsOrganizationIdGetData): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/organizations/{organization_id}', + path: { + organization_id: data.organizationId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Delete Organization + * Delete a organization by ID. + * + * Args: + * organization_id (str): Tool ID. + * session (DBSessionDep): Database session. + * + * Returns: + * DeleteOrganization: Organization deleted. + * @param data The data for the request. + * @param data.organizationId + * @returns DeleteOrganization Successful Response + * @throws ApiError + */ + public deleteOrganizationV1OrganizationsOrganizationIdDelete(data: DeleteOrganizationV1OrganizationsOrganizationIdDeleteData): CancelablePromise { + return this.httpRequest.request({ + method: 'DELETE', + url: '/v1/organizations/{organization_id}', + path: { + organization_id: data.organizationId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Get Organization Users + * Get organization users by ID. + * + * Args: + * organization_id (str): Organization ID. + * session (DBSessionDep): Database session. + * + * Returns: + * list[User]: List of users in the organization + * @param data The data for the request. + * @param data.organizationId + * @returns backend__schemas__user__User Successful Response + * @throws ApiError + */ + public getOrganizationUsersV1OrganizationsOrganizationIdUsersGet(data: GetOrganizationUsersV1OrganizationsOrganizationIdUsersGetData): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/organizations/{organization_id}/users', + path: { + organization_id: data.organizationId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Create Model + * Create a new model. + * + * Args: + * model (ModelCreate): Model data to be created. + * session (DBSessionDep): Database session. + * + * Returns: + * ModelSchema: Created model. + * @param data The data for the request. + * @param data.requestBody + * @returns Model Successful Response + * @throws ApiError + */ + public createModelV1ModelsPost(data: CreateModelV1ModelsPostData): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/v1/models', + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * List Models + * List all available models + * + * Returns: + * list[Model]: List of available models. + * @param data The data for the request. + * @param data.offset + * @param data.limit + * @returns Model Successful Response + * @throws ApiError + */ + public listModelsV1ModelsGet(data: ListModelsV1ModelsGetData = {}): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/models', + query: { + offset: data.offset, + limit: data.limit + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Update Model + * Update a model by ID. + * + * Args: + * model_id (str): Model ID. + * new_model (ModelCreateUpdate): New model data. + * session (DBSessionDep): Database session. + * + * Returns: + * ModelSchema: Updated model. + * + * Raises: + * HTTPException: If the model with the given ID is not found. + * @param data The data for the request. + * @param data.modelId + * @param data.requestBody + * @returns Model Successful Response + * @throws ApiError + */ + public updateModelV1ModelsModelIdPut(data: UpdateModelV1ModelsModelIdPutData): CancelablePromise { + return this.httpRequest.request({ + method: 'PUT', + url: '/v1/models/{model_id}', + path: { + model_id: data.modelId + }, + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Get Model + * Get a model by ID. + * + * Returns: + * Model: Model with the given ID. + * @param data The data for the request. + * @param data.modelId + * @returns Model Successful Response + * @throws ApiError + */ + public getModelV1ModelsModelIdGet(data: GetModelV1ModelsModelIdGetData): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/v1/models/{model_id}', + path: { + model_id: data.modelId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Delete Model + * Delete a model by ID. + * + * Args: + * model_id (str): Model ID. + * session (DBSessionDep): Database session. + * request (Request): Request object. + * + * Returns: + * DeleteModel: Empty response. + * + * Raises: + * HTTPException: If the model with the given ID is not found. + * @param data The data for the request. + * @param data.modelId + * @returns DeleteModel Successful Response + * @throws ApiError + */ + public deleteModelV1ModelsModelIdDelete(data: DeleteModelV1ModelsModelIdDeleteData): CancelablePromise { + return this.httpRequest.request({ + method: 'DELETE', + url: '/v1/models/{model_id}', + path: { + model_id: data.modelId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Get Users + * @param data The data for the request. + * @param data.count + * @param data.startIndex + * @param data.filter + * @returns ListUserResponse Successful Response + * @throws ApiError + */ + public getUsersScimV2UsersGet(data: GetUsersScimV2UsersGetData = {}): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/scim/v2/Users', + query: { + count: data.count, + start_index: data.startIndex, + filter: data.filter + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Create User + * @param data The data for the request. + * @param data.requestBody + * @returns unknown Successful Response + * @throws ApiError + */ + public createUserScimV2UsersPost(data: CreateUserScimV2UsersPostData): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/scim/v2/Users', + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Get User + * @param data The data for the request. + * @param data.userId + * @returns unknown Successful Response + * @throws ApiError + */ + public getUserScimV2UsersUserIdGet(data: GetUserScimV2UsersUserIdGetData): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/scim/v2/Users/{user_id}', + path: { + user_id: data.userId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Update User + * @param data The data for the request. + * @param data.userId + * @param data.requestBody + * @returns unknown Successful Response + * @throws ApiError + */ + public updateUserScimV2UsersUserIdPut(data: UpdateUserScimV2UsersUserIdPutData): CancelablePromise { + return this.httpRequest.request({ + method: 'PUT', + url: '/scim/v2/Users/{user_id}', + path: { + user_id: data.userId + }, + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Patch User + * @param data The data for the request. + * @param data.userId + * @param data.requestBody + * @returns unknown Successful Response + * @throws ApiError + */ + public patchUserScimV2UsersUserIdPatch(data: PatchUserScimV2UsersUserIdPatchData): CancelablePromise { + return this.httpRequest.request({ + method: 'PATCH', + url: '/scim/v2/Users/{user_id}', + path: { + user_id: data.userId + }, + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Get Groups + * @param data The data for the request. + * @param data.count + * @param data.startIndex + * @param data.filter + * @returns ListGroupResponse Successful Response + * @throws ApiError + */ + public getGroupsScimV2GroupsGet(data: GetGroupsScimV2GroupsGetData = {}): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/scim/v2/Groups', + query: { + count: data.count, + start_index: data.startIndex, + filter: data.filter + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Create Group + * @param data The data for the request. + * @param data.requestBody + * @returns unknown Successful Response + * @throws ApiError + */ + public createGroupScimV2GroupsPost(data: CreateGroupScimV2GroupsPostData): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/scim/v2/Groups', + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Get Group + * @param data The data for the request. + * @param data.groupId + * @returns unknown Successful Response + * @throws ApiError + */ + public getGroupScimV2GroupsGroupIdGet(data: GetGroupScimV2GroupsGroupIdGetData): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/scim/v2/Groups/{group_id}', + path: { + group_id: data.groupId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Patch Group + * @param data The data for the request. + * @param data.groupId + * @param data.requestBody + * @returns unknown Successful Response + * @throws ApiError + */ + public patchGroupScimV2GroupsGroupIdPatch(data: PatchGroupScimV2GroupsGroupIdPatchData): CancelablePromise { + return this.httpRequest.request({ + method: 'PATCH', + url: '/scim/v2/Groups/{group_id}', + path: { + group_id: data.groupId + }, + body: data.requestBody, + mediaType: 'application/json', + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Delete Group + * @param data The data for the request. + * @param data.groupId + * @returns void Successful Response + * @throws ApiError + */ + public deleteGroupScimV2GroupsGroupIdDelete(data: DeleteGroupScimV2GroupsGroupIdDeleteData): CancelablePromise { + return this.httpRequest.request({ + method: 'DELETE', + url: '/scim/v2/Groups/{group_id}', + path: { + group_id: data.groupId + }, + errors: { + 422: 'Validation Error' + } + }); + } + + /** + * Health + * Health check for backend APIs + * @returns unknown Successful Response + * @throws ApiError + */ + public healthHealthGet(): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/health' + }); + } + + /** + * Apply Migrations + * Applies Alembic migrations - useful for serverless applications + * @returns unknown Successful Response + * @throws ApiError + */ + public applyMigrationsMigratePost(): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/migrate' + }); + } + +} \ No newline at end of file diff --git a/src/interfaces/coral_web/src/cohere-client/generated/types.gen.ts b/src/interfaces/coral_web/src/cohere-client/generated/types.gen.ts index d397df874a..ffcf0731e6 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/types.gen.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/types.gen.ts @@ -1,128 +1,111 @@ // This file is auto-generated by @hey-api/openapi-ts -export type Agent = { - user_id: string; - organization_id?: string | null; - id: string; - created_at: string; - updated_at: string; - version: number; - name: string; - description: string | null; - preamble: string | null; - temperature: number; - tools: Array; - tools_metadata?: Array | null; - model: string; - deployment: string; -}; - export type AgentPublic = { - user_id: string; - id: string; - created_at: string; - updated_at: string; - version: number; - name: string; - description: string | null; - preamble: string | null; - temperature: number; - tools: Array; - tools_metadata?: Array | null; - model: string; - deployment: string; + user_id: string; + id: string; + created_at: string; + updated_at: string; + version: number; + name: string; + description: string | null; + preamble: string | null; + temperature: number; + tools: Array<(string)> | null; + tools_metadata?: Array | null; + deployments: Array; + deployment: string | null; + model: string | null; + is_private: boolean | null; }; export type AgentToolMetadata = { - user_id: string; - organization_id?: string | null; - id: string; - tool_name: string; - artifacts: Array<{ - [key: string]: unknown; - }>; + id: string; + created_at: string; + updated_at: string; + user_id: string | null; + agent_id: string; + tool_name: string; + artifacts: Array<{ + [key: string]: unknown; + }>; }; export type AgentToolMetadataPublic = { - organization_id?: string | null; - id: string; - tool_name: string; - artifacts: Array<{ - [key: string]: unknown; - }>; -}; + id: string; + created_at: string; + updated_at: string; + agent_id: string; + tool_name: string; + artifacts: Array<{ + [key: string]: unknown; + }>; +}; + +export enum AgentVisibility { + PRIVATE = 'private', + PUBLIC = 'public', + ALL = 'all' +} -export type Body_batch_upload_file_v1_conversations_batch_upload_file_post = { - conversation_id?: string; - files: Array; +export type Body_batch_upload_file_v1_agents_batch_upload_file_post = { + files: Array<((Blob | File))>; }; -export type Body_upload_file_v1_conversations_upload_file_post = { - conversation_id?: string; - file: Blob | File; +export type Body_batch_upload_file_v1_conversations_batch_upload_file_post = { + conversation_id?: string; + files: Array<((Blob | File))>; }; export enum Category { - FILE_LOADER = 'File loader', - DATA_LOADER = 'Data loader', - FUNCTION = 'Function', + DATA_LOADER = 'Data loader', + FILE_LOADER = 'File loader', + FUNCTION = 'Function', + WEB_SEARCH = 'Web search' } /** * A list of previous messages between the user and the model, meant to give the model conversational context for responding to the user's message. */ export type ChatMessage = { - role: ChatRole; - message?: string | null; - tool_plan?: string | null; - tool_results?: Array<{ + role: ChatRole; + message?: string | null; + tool_plan?: string | null; + tool_results?: Array<{ [key: string]: unknown; - }> | null; - tool_calls?: Array<{ +}> | null; + tool_calls?: Array<{ [key: string]: unknown; - }> | null; +}> | null; }; export type ChatResponseEvent = { - event: StreamEvent; - data: - | StreamStart - | StreamTextGeneration - | StreamCitationGeneration - | StreamQueryGeneration - | StreamSearchResults - | StreamEnd - | StreamToolInput - | StreamToolResult - | StreamSearchQueriesGeneration - | StreamToolCallsGeneration - | StreamToolCallsChunk - | NonStreamedChatResponse; + event: StreamEvent; + data: StreamStart | StreamTextGeneration | StreamCitationGeneration | StreamQueryGeneration | StreamSearchResults | StreamEnd | StreamToolInput | StreamToolResult | StreamSearchQueriesGeneration | StreamToolCallsGeneration | StreamToolCallsChunk | NonStreamedChatResponse; }; /** * One of CHATBOT|USER|SYSTEM to identify who the message is coming from. */ export enum ChatRole { - CHATBOT = 'CHATBOT', - USER = 'USER', - SYSTEM = 'SYSTEM', - TOOL = 'TOOL', + CHATBOT = 'CHATBOT', + USER = 'USER', + SYSTEM = 'SYSTEM', + TOOL = 'TOOL' } export type Citation = { - text: string; - start: number; - end: number; - document_ids: Array; + text: string; + start: number; + end: number; + document_ids: Array<(string)>; }; /** * Dictates how the prompt will be constructed. Defaults to "AUTO_PRESERVE_ORDER". */ export enum CohereChatPromptTruncation { - OFF = 'OFF', - AUTO_PRESERVE_ORDER = 'AUTO_PRESERVE_ORDER', + OFF = 'OFF', + AUTO_PRESERVE_ORDER = 'AUTO_PRESERVE_ORDER' } /** @@ -130,1361 +113,2125 @@ export enum CohereChatPromptTruncation { * See: https://github.com/cohere-ai/cohere-python/blob/main/src/cohere/base_client.py#L1629 */ export type CohereChatRequest = { - message: string; - chat_history?: Array | null; - conversation_id?: string; - tools?: Array | null; - documents?: Array<{ - [key: string]: unknown; - }>; - model?: string | null; - temperature?: number | null; - k?: number | null; - p?: number | null; - preamble?: string | null; - file_ids?: Array | null; - search_queries_only?: boolean | null; - max_tokens?: number | null; - seed?: number | null; - stop_sequences?: Array | null; - presence_penalty?: number | null; - frequency_penalty?: number | null; - prompt_truncation?: CohereChatPromptTruncation; - tool_results?: Array<{ + message: string; + chat_history?: Array | null; + conversation_id?: string; + tools?: Array | null; + documents?: Array<{ + [key: string]: unknown; + }>; + model?: string | null; + temperature?: number | null; + k?: number | null; + p?: number | null; + preamble?: string | null; + file_ids?: Array<(string)> | null; + search_queries_only?: boolean | null; + max_tokens?: number | null; + seed?: number | null; + stop_sequences?: Array<(string)> | null; + presence_penalty?: number | null; + frequency_penalty?: number | null; + prompt_truncation?: CohereChatPromptTruncation; + tool_results?: Array<{ [key: string]: unknown; - }> | null; - force_single_step?: boolean | null; - agent_id?: string | null; +}> | null; + force_single_step?: boolean | null; + agent_id?: string | null; +}; + +export type ConversationFilePublic = { + id: string; + user_id: string; + created_at: string; + updated_at: string; + conversation_id: string; + file_name: string; + file_size?: number; +}; + +export type ConversationPublic = { + id: string; + created_at: string; + updated_at: string; + title: string; + messages: Array; + files: Array; + description: string | null; + agent_id: string | null; + is_pinned: boolean; + readonly total_file_size: number; }; -export type Conversation = { - user_id: string; - organization_id?: string | null; - id: string; - created_at: string; - updated_at: string; - title: string; - messages: Array; - files: Array; - description: string | null; - agent_id: string | null; - readonly total_file_size: number; +export type ConversationWithoutMessages = { + id: string; + created_at: string; + updated_at: string; + title: string; + files: Array; + description: string | null; + agent_id: string | null; + is_pinned: boolean; + readonly total_file_size: number; }; -export type ConversationWithoutMessages = { - user_id: string; - organization_id?: string | null; - id: string; - created_at: string; - updated_at: string; - title: string; - files: Array; - description: string | null; - agent_id: string | null; - readonly total_file_size: number; -}; - -export type CreateAgent = { - name: string; - version?: number | null; - description?: string | null; - preamble?: string | null; - temperature?: number | null; - model: string; - deployment: string; - tools?: Array | null; - tools_metadata?: Array | null; -}; - -export type CreateAgentToolMetadata = { - id?: string | null; - tool_name: string; - artifacts: Array<{ - [key: string]: unknown; - }>; +export type CreateAgentRequest = { + name: string; + version?: number | null; + description?: string | null; + preamble?: string | null; + temperature?: number | null; + tools?: Array<(string)> | null; + tools_metadata?: Array | null; + deployment_config?: { + [key: string]: (string); +} | null; + is_default_deployment?: boolean | null; + model: string; + deployment: string; + organization_id?: string | null; + is_private?: boolean | null; }; -export type CreateSnapshot = { - conversation_id: string; +export type CreateAgentToolMetadataRequest = { + id?: string | null; + tool_name: string; + artifacts: Array<{ + [key: string]: unknown; + }>; }; -export type CreateSnapshotResponse = { - snapshot_id: string; - user_id: string; - link_id: string; - messages: Array; +export type CreateGroup = { + schemas: Array<(string)>; + members: Array; + displayName: string; +}; + +export type CreateOrganization = { + name: string; }; -export type CreateUser = { - password?: string | null; - hashed_password?: (Blob | File) | null; - fullname: string; - email?: string | null; +export type CreateSnapshotRequest = { + conversation_id: string; +}; + +export type CreateSnapshotResponse = { + snapshot_id: string; + link_id: string; + messages: Array; }; export type DeleteAgent = unknown; +export type DeleteAgentFileResponse = unknown; + export type DeleteAgentToolMetadata = unknown; -export type DeleteConversation = unknown; +export type DeleteConversationFileResponse = unknown; + +export type DeleteConversationResponse = unknown; + +export type DeleteDeployment = unknown; + +export type DeleteModel = unknown; + +export type DeleteOrganization = unknown; -export type DeleteFile = unknown; +export type DeleteSnapshotLinkResponse = unknown; + +export type DeleteSnapshotResponse = unknown; + +export type DeleteToolAuth = unknown; export type DeleteUser = unknown; -export type Deployment = { - name: string; - models: Array; - is_available: boolean; - env_vars: Array; +export type DeploymentCreate = { + id?: string | null; + name: string; + description?: string | null; + deployment_class_name: string; + is_community?: boolean; + default_deployment_config: { + [key: string]: (string); + }; +}; + +export type DeploymentDefinition = { + id: string; + name: string; + description?: string | null; + config?: { + [key: string]: (string); + }; + is_available?: boolean; + is_community?: boolean; + models: Array<(string)>; +}; + +export type DeploymentUpdate = { + name?: string | null; + description?: string | null; + deployment_class_name?: string | null; + is_community?: boolean | null; + default_deployment_config?: { + [key: string]: (string); +} | null; +}; + +export type DeploymentWithModels = { + id?: string | null; + name: string; + description?: string | null; + env_vars: Array<(string)> | null; + is_available?: boolean; + is_community?: boolean | null; + models: Array; }; export type Document = { - text: string; - document_id: string; - title: string | null; - url: string | null; - fields: { + text: string; + document_id: string; + title: string | null; + url: string | null; + fields: { [key: string]: unknown; - } | null; - tool_name: string | null; +} | null; + tool_name: string | null; +}; + +export type Email = { + primary: boolean; + value?: string | null; + type: string; }; -export type File = { - id: string; - created_at: string; - updated_at: string; - user_id: string; - conversation_id: string; - file_name: string; - file_path: string; - file_size?: number; +export type GenerateTitleResponse = { + title: string; + error?: string | null; }; -export type GenerateTitle = { - title: string; +export type Group = { + schemas: Array<(string)>; + members: Array; + displayName: string; + id: string; + meta: Meta; }; -export type GenericResponseMessage = { - message: string; +export type GroupMember = { + value: string; + display: string; +}; + +export type GroupOperation = { + op: string; + path?: string | null; + value: { + [key: string]: (string); +} | Array<{ + [key: string]: (string); +}>; }; export type HTTPValidationError = { - detail?: Array; + detail?: Array; }; export type JWTResponse = { - token: string; + token: string; }; -/** - * Request shape for Langchain Streamed Chat. - */ -export type LangchainChatRequest = { - message: string; - chat_history?: Array | null; - conversation_id?: string; - tools?: Array | null; +export type ListAuthStrategy = { + strategy: string; + client_id: string | null; + authorization_endpoint: string | null; + pkce_enabled: boolean; }; -export type ListAuthStrategy = { - strategy: string; - client_id: string | null; - authorization_endpoint: string | null; - pkce_enabled: boolean; +export type ListConversationFile = { + id: string; + user_id: string; + created_at: string; + updated_at: string; + conversation_id: string; + file_name: string; + file_size?: number; }; -export type ListFile = { - id: string; - created_at: string; - updated_at: string; - user_id: string; - conversation_id: string; - file_name: string; - file_path: string; - file_size?: number; +export type ListGroupResponse = { + totalResults: number; + startIndex: number; + itemsPerPage: number; + Resources: Array; +}; + +export type ListUserResponse = { + totalResults: number; + startIndex: number; + itemsPerPage: number; + Resources: Array; }; export type Login = { - strategy: string; - payload?: { - [key: string]: string; - } | null; + strategy: string; + payload?: { + [key: string]: (string); +} | null; }; export type Logout = unknown; export type ManagedTool = { - name?: string | null; - display_name?: string; - description?: string | null; - parameter_definitions?: { - [key: string]: unknown; - } | null; - kwargs?: { + name?: string | null; + display_name?: string; + description?: string | null; + parameter_definitions?: { [key: string]: unknown; - }; - is_visible?: boolean; - is_available?: boolean; - error_message?: string | null; - category?: Category; - is_auth_required?: boolean; - auth_url?: string | null; - token?: string | null; +} | null; + kwargs?: { + [key: string]: unknown; + }; + is_visible?: boolean; + is_available?: boolean; + error_message?: string | null; + category?: Category; + is_auth_required?: boolean; + auth_url?: string | null; + token?: string | null; }; export type Message = { - text: string; - id: string; - created_at: string; - updated_at: string; - generation_id: string | null; - position: number; - is_active: boolean; - documents: Array; - citations: Array; - files: Array; - tool_calls: Array; - tool_plan: string | null; - agent: MessageAgent; + text: string; + id: string; + created_at: string; + updated_at: string; + generation_id: string | null; + position: number; + is_active: boolean; + documents: Array; + citations: Array; + files: Array; + tool_calls: Array; + tool_plan: string | null; + agent: MessageAgent; }; export enum MessageAgent { - USER = 'USER', - CHATBOT = 'CHATBOT', + USER = 'USER', + CHATBOT = 'CHATBOT' } +export type Meta = { + resourceType: string; + created: string; + lastModified: string; +}; + +export type Model = { + id: string; + name: string; + deployment_id: string; + cohere_name: string | null; + description: string | null; +}; + +export type ModelCreate = { + name: string; + cohere_name: string | null; + description: string | null; + deployment_id: string; +}; + +export type ModelSimple = { + id: string; + name: string; + cohere_name: string | null; + description: string | null; +}; + +export type ModelUpdate = { + name?: string | null; + cohere_name?: string | null; + description?: string | null; + deployment_id?: string | null; +}; + +export type Name = { + givenName: string; + familyName: string; +}; + export type NonStreamedChatResponse = { - response_id: string | null; - generation_id: string | null; - chat_history: Array | null; - finish_reason: string; - text: string; - citations?: Array | null; - documents?: Array | null; - search_results?: Array<{ + response_id: string | null; + generation_id: string | null; + chat_history: Array | null; + finish_reason: string; + text: string; + citations?: Array | null; + documents?: Array | null; + search_results?: Array<{ [key: string]: unknown; - }> | null; - search_queries?: Array | null; - conversation_id: string | null; - tool_calls?: Array | null; +}> | null; + search_queries?: Array | null; + conversation_id: string | null; + tool_calls?: Array | null; + error?: string | null; }; -export type SearchQuery = { - text: string; - generation_id: string; +export type Operation = { + op: string; + value: { + [key: string]: (boolean); + }; +}; + +export type Organization = { + name: string; + id: string; + created_at: string; + updated_at: string; }; -export type Snapshot = { - conversation_id: string; - id: string; - last_message_id: string; - user_id: string; - organization_id: string | null; - version: number; - created_at: string; - updated_at: string; - snapshot: SnapshotData; +export type PatchGroup = { + schemas: Array<(string)>; + operations: Array; }; -export type SnapshotAgent = { - id: string; - name: string; - description: string | null; - preamble: string | null; - tools_metadata: Array | null; +export type PatchUser = { + schemas: Array<(string)>; + operations: Array; +}; + +export type SearchQuery = { + text: string; + generation_id: string; }; export type SnapshotData = { - title: string; - description: string; - messages: Array; - agent: SnapshotAgent | null; + title: string; + description: string; + messages: Array; +}; + +export type SnapshotPublic = { + conversation_id: string; + id: string; + last_message_id: string; + version: number; + created_at: string; + updated_at: string; + snapshot: SnapshotData; }; export type SnapshotWithLinks = { - conversation_id: string; - id: string; - last_message_id: string; - user_id: string; - organization_id: string | null; - version: number; - created_at: string; - updated_at: string; - snapshot: SnapshotData; - links: Array; + conversation_id: string; + id: string; + last_message_id: string; + version: number; + created_at: string; + updated_at: string; + snapshot: SnapshotData; + links: Array<(string)>; }; /** * Stream citation generation event. */ export type StreamCitationGeneration = { - citations?: Array; + citations?: Array; }; export type StreamEnd = { - response_id?: string | null; - generation_id?: string | null; - conversation_id?: string | null; - text: string; - citations?: Array; - documents?: Array; - search_results?: Array<{ - [key: string]: unknown; - }>; - search_queries?: Array; - tool_calls?: Array; - finish_reason?: string | null; - chat_history?: Array | null; - error?: string | null; + message_id?: string | null; + response_id?: string | null; + generation_id?: string | null; + conversation_id?: string | null; + text: string; + citations?: Array; + documents?: Array; + search_results?: Array<{ + [key: string]: unknown; + }>; + search_queries?: Array; + tool_calls?: Array; + finish_reason?: string | null; + chat_history?: Array | null; + error?: string | null; }; /** * Stream Events returned by Cohere's chat stream response. */ export enum StreamEvent { - STREAM_START = 'stream-start', - SEARCH_QUERIES_GENERATION = 'search-queries-generation', - SEARCH_RESULTS = 'search-results', - TOOL_INPUT = 'tool-input', - TOOL_RESULT = 'tool-result', - TEXT_GENERATION = 'text-generation', - CITATION_GENERATION = 'citation-generation', - STREAM_END = 'stream-end', - NON_STREAMED_CHAT_RESPONSE = 'non-streamed-chat-response', - TOOL_CALLS_GENERATION = 'tool-calls-generation', - TOOL_CALLS_CHUNK = 'tool-calls-chunk', + STREAM_START = 'stream-start', + SEARCH_QUERIES_GENERATION = 'search-queries-generation', + SEARCH_RESULTS = 'search-results', + TOOL_INPUT = 'tool-input', + TOOL_RESULT = 'tool-result', + TEXT_GENERATION = 'text-generation', + CITATION_GENERATION = 'citation-generation', + STREAM_END = 'stream-end', + NON_STREAMED_CHAT_RESPONSE = 'non-streamed-chat-response', + TOOL_CALLS_GENERATION = 'tool-calls-generation', + TOOL_CALLS_CHUNK = 'tool-calls-chunk' } /** * Stream query generation event. */ export type StreamQueryGeneration = { - query: string; + query: string; }; /** * Stream queries generation event. */ export type StreamSearchQueriesGeneration = { - search_queries?: Array; + search_queries?: Array; }; export type StreamSearchResults = { - search_results?: Array<{ - [key: string]: unknown; - }>; - documents?: Array; + search_results?: Array<{ + [key: string]: unknown; + }>; + documents?: Array; }; /** * Stream start event. */ export type StreamStart = { - generation_id?: string | null; - conversation_id?: string | null; + generation_id?: string | null; + conversation_id?: string | null; }; /** * Stream text generation event. */ export type StreamTextGeneration = { - text: string; + text: string; }; export type StreamToolCallsChunk = { - tool_call_delta?: ToolCallDelta | null; - text: string | null; + tool_call_delta?: ToolCallDelta | null; + text: string | null; }; /** * Stream tool calls generation event. */ export type StreamToolCallsGeneration = { - stream_search_results?: StreamSearchResults | null; - tool_calls?: Array | null; - text: string | null; + stream_search_results?: StreamSearchResults | null; + tool_calls?: Array | null; + text: string | null; }; export type StreamToolInput = { - input_type: ToolInputType; - tool_name: string; - input: string; - text: string; + input_type: ToolInputType; + tool_name: string; + input: string; + text: string; }; export type StreamToolResult = { - result: unknown; - tool_name: string; - documents?: Array; + result: unknown; + tool_name: string; + documents?: Array; +}; + +export type ToggleConversationPinRequest = { + is_pinned: boolean; }; export type Tool = { - name?: string | null; - display_name?: string; - description?: string | null; - parameter_definitions?: { + name?: string | null; + display_name?: string; + description?: string | null; + parameter_definitions?: { [key: string]: unknown; - } | null; +} | null; }; export type ToolCall = { - name: string; - parameters?: { - [key: string]: unknown; - }; + name: string; + parameters?: { + [key: string]: unknown; + }; }; export type ToolCallDelta = { - name: string | null; - index: number | null; - parameters: string | null; + name: string | null; + index: number | null; + parameters: string | null; }; /** * Type of input passed to the tool */ export enum ToolInputType { - QUERY = 'QUERY', - CODE = 'CODE', + QUERY = 'QUERY', + CODE = 'CODE' } -export type UpdateAgent = { - name?: string | null; - version?: number | null; - description?: string | null; - preamble?: string | null; - temperature?: number | null; - model?: string | null; - deployment?: string | null; - tools?: Array | null; - tools_metadata?: Array | null; -}; - -export type UpdateAgentToolMetadata = { - id?: string | null; - tool_name?: string | null; - artifacts?: Array<{ +export type UpdateAgentRequest = { + name?: string | null; + version?: number | null; + description?: string | null; + preamble?: string | null; + temperature?: number | null; + model?: string | null; + deployment?: string | null; + deployment_config?: { + [key: string]: (string); +} | null; + is_default_deployment?: boolean | null; + is_default_model?: boolean | null; + organization_id?: string | null; + tools?: Array<(string)> | null; + tools_metadata?: Array | null; + is_private?: boolean | null; +}; + +export type UpdateAgentToolMetadataRequest = { + id?: string | null; + tool_name?: string | null; + artifacts?: Array<{ [key: string]: unknown; - }> | null; +}> | null; }; -export type UpdateConversation = { - title?: string | null; - description?: string | null; +export type UpdateConversationRequest = { + title?: string | null; + description?: string | null; }; export type UpdateDeploymentEnv = { - env_vars: { - [key: string]: string; - }; + env_vars: { + [key: string]: (string); + }; }; -export type UpdateFile = { - file_name?: string | null; - message_id?: string | null; +export type UpdateOrganization = { + name: string | null; }; -export type UpdateUser = { - password?: string | null; - hashed_password?: (Blob | File) | null; - fullname?: string | null; - email?: string | null; +export type UploadAgentFileResponse = { + id: string; + created_at: string; + updated_at: string; + file_name: string; + file_size?: number; }; -export type UploadFile = { - id: string; - created_at: string; - updated_at: string; - user_id: string; - conversation_id: string; - file_name: string; - file_path: string; - file_size?: number; +export type UploadConversationFileResponse = { + id: string; + user_id: string; + created_at: string; + updated_at: string; + conversation_id: string; + file_name: string; + file_size?: number; }; -export type User = { - fullname: string; - email?: string | null; - id: string; - created_at: string; - updated_at: string; +export type ValidationError = { + loc: Array<(string | number)>; + msg: string; + type: string; }; -export type ValidationError = { - loc: Array; - msg: string; - type: string; +export type backend__schemas__scim__CreateUser = { + userName: string | null; + active: boolean | null; + schemas: Array<(string)>; + name: Name; + emails: Array; + externalId: string; +}; + +export type backend__schemas__scim__UpdateUser = { + userName: string | null; + active: boolean | null; + schemas: Array<(string)>; + emails: Array; + name: Name; +}; + +export type backend__schemas__scim__User = { + userName: string | null; + active: boolean | null; + schemas: Array<(string)>; + id: string; + externalId: string; + meta: Meta; +}; + +export type backend__schemas__user__CreateUser = { + password?: string | null; + hashed_password?: (Blob | File) | null; + fullname: string; + email?: string | null; +}; + +export type backend__schemas__user__UpdateUser = { + password?: string | null; + hashed_password?: (Blob | File) | null; + fullname?: string | null; + email?: string | null; +}; + +export type backend__schemas__user__User = { + fullname: string; + email?: string | null; + id: string; + created_at: string; + updated_at: string; }; export type GetStrategiesV1AuthStrategiesGetResponse = Array; export type LoginV1LoginPostData = { - requestBody: Login; + requestBody: Login; }; export type LoginV1LoginPostResponse = JWTResponse | null; export type AuthorizeV1StrategyAuthPostData = { - code?: string; - strategy: string; + code?: string; + strategy: string; }; export type AuthorizeV1StrategyAuthPostResponse = JWTResponse; export type LogoutV1LogoutGetResponse = Logout; -export type LoginV1ToolAuthGetResponse = unknown; +export type ToolAuthV1ToolAuthGetResponse = unknown; + +export type DeleteToolAuthV1ToolAuthToolIdDeleteData = { + toolId: string; +}; + +export type DeleteToolAuthV1ToolAuthToolIdDeleteResponse = DeleteToolAuth; export type ChatStreamV1ChatStreamPostData = { - requestBody: CohereChatRequest; + requestBody: CohereChatRequest; }; export type ChatStreamV1ChatStreamPostResponse = Array; -export type ChatV1ChatPostData = { - requestBody: CohereChatRequest; +export type RegenerateChatStreamV1ChatStreamRegeneratePostData = { + requestBody: CohereChatRequest; }; -export type ChatV1ChatPostResponse = NonStreamedChatResponse; +export type RegenerateChatStreamV1ChatStreamRegeneratePostResponse = unknown; -export type LangchainChatStreamV1LangchainChatPostData = { - requestBody: LangchainChatRequest; +export type ChatV1ChatPostData = { + requestBody: CohereChatRequest; }; -export type LangchainChatStreamV1LangchainChatPostResponse = unknown; +export type ChatV1ChatPostResponse = NonStreamedChatResponse; export type CreateUserV1UsersPostData = { - requestBody: CreateUser; + requestBody: backend__schemas__user__CreateUser; }; -export type CreateUserV1UsersPostResponse = User; +export type CreateUserV1UsersPostResponse = backend__schemas__user__User; export type ListUsersV1UsersGetData = { - limit?: number; - offset?: number; + limit?: number; + offset?: number; }; -export type ListUsersV1UsersGetResponse = Array; +export type ListUsersV1UsersGetResponse = Array; export type GetUserV1UsersUserIdGetData = { - userId: string; + userId: string; }; -export type GetUserV1UsersUserIdGetResponse = User; +export type GetUserV1UsersUserIdGetResponse = backend__schemas__user__User; export type UpdateUserV1UsersUserIdPutData = { - requestBody: UpdateUser; - userId: string; + requestBody: backend__schemas__user__UpdateUser; + userId: string; }; -export type UpdateUserV1UsersUserIdPutResponse = User; +export type UpdateUserV1UsersUserIdPutResponse = backend__schemas__user__User; export type DeleteUserV1UsersUserIdDeleteData = { - userId: string; + userId: string; }; export type DeleteUserV1UsersUserIdDeleteResponse = DeleteUser; export type GetConversationV1ConversationsConversationIdGetData = { - conversationId: string; + conversationId: string; }; -export type GetConversationV1ConversationsConversationIdGetResponse = Conversation; +export type GetConversationV1ConversationsConversationIdGetResponse = ConversationPublic; export type UpdateConversationV1ConversationsConversationIdPutData = { - conversationId: string; - requestBody: UpdateConversation; + conversationId: string; + requestBody: UpdateConversationRequest; }; -export type UpdateConversationV1ConversationsConversationIdPutResponse = Conversation; +export type UpdateConversationV1ConversationsConversationIdPutResponse = ConversationPublic; export type DeleteConversationV1ConversationsConversationIdDeleteData = { - conversationId: string; + conversationId: string; }; -export type DeleteConversationV1ConversationsConversationIdDeleteResponse = DeleteConversation; +export type DeleteConversationV1ConversationsConversationIdDeleteResponse = DeleteConversationResponse; export type ListConversationsV1ConversationsGetData = { - agentId?: string; - limit?: number; - offset?: number; + agentId?: string; + limit?: number; + offset?: number; + orderBy?: string; }; export type ListConversationsV1ConversationsGetResponse = Array; -export type SearchConversationsV1ConversationsSearchGetData = { - agentId?: string; - limit?: number; - offset?: number; - query: string; +export type ToggleConversationPinV1ConversationsConversationIdTogglePinPutData = { + conversationId: string; + requestBody: ToggleConversationPinRequest; }; -export type SearchConversationsV1ConversationsSearchGetResponse = - Array; +export type ToggleConversationPinV1ConversationsConversationIdTogglePinPutResponse = ConversationWithoutMessages; -export type UploadFileV1ConversationsUploadFilePostData = { - formData: Body_upload_file_v1_conversations_upload_file_post; +export type SearchConversationsV1ConversationsSearchGetData = { + agentId?: string; + limit?: number; + offset?: number; + query: string; }; -export type UploadFileV1ConversationsUploadFilePostResponse = UploadFile; +export type SearchConversationsV1ConversationsSearchGetResponse = Array; export type BatchUploadFileV1ConversationsBatchUploadFilePostData = { - formData: Body_batch_upload_file_v1_conversations_batch_upload_file_post; + formData: Body_batch_upload_file_v1_conversations_batch_upload_file_post; }; -export type BatchUploadFileV1ConversationsBatchUploadFilePostResponse = Array; +export type BatchUploadFileV1ConversationsBatchUploadFilePostResponse = Array; export type ListFilesV1ConversationsConversationIdFilesGetData = { - conversationId: string; + conversationId: string; }; -export type ListFilesV1ConversationsConversationIdFilesGetResponse = Array; +export type ListFilesV1ConversationsConversationIdFilesGetResponse = Array; -export type UpdateFileV1ConversationsConversationIdFilesFileIdPutData = { - conversationId: string; - fileId: string; - requestBody: UpdateFile; +export type DeleteFileV1ConversationsConversationIdFilesFileIdDeleteData = { + conversationId: string; + fileId: string; }; -export type UpdateFileV1ConversationsConversationIdFilesFileIdPutResponse = File; +export type DeleteFileV1ConversationsConversationIdFilesFileIdDeleteResponse = DeleteConversationFileResponse; -export type DeleteFileV1ConversationsConversationIdFilesFileIdDeleteData = { - conversationId: string; - fileId: string; +export type GenerateTitleV1ConversationsConversationIdGenerateTitlePostData = { + conversationId: string; + model?: string | null; }; -export type DeleteFileV1ConversationsConversationIdFilesFileIdDeleteResponse = DeleteFile; +export type GenerateTitleV1ConversationsConversationIdGenerateTitlePostResponse = GenerateTitleResponse; -export type GenerateTitleV1ConversationsConversationIdGenerateTitlePostData = { - conversationId: string; +export type SynthesizeMessageV1ConversationsConversationIdSynthesizeMessageIdGetData = { + conversationId: string; + messageId: string; }; -export type GenerateTitleV1ConversationsConversationIdGenerateTitlePostResponse = GenerateTitle; +export type SynthesizeMessageV1ConversationsConversationIdSynthesizeMessageIdGetResponse = unknown; export type ListToolsV1ToolsGetData = { - agentId?: string | null; + agentId?: string | null; }; export type ListToolsV1ToolsGetResponse = Array; +export type CreateDeploymentV1DeploymentsPostData = { + requestBody: DeploymentCreate; +}; + +export type CreateDeploymentV1DeploymentsPostResponse = DeploymentDefinition; + export type ListDeploymentsV1DeploymentsGetData = { - all?: boolean; + all?: boolean; }; -export type ListDeploymentsV1DeploymentsGetResponse = Array; +export type ListDeploymentsV1DeploymentsGetResponse = Array; -export type SetEnvVarsV1DeploymentsNameSetEnvVarsPostData = { - name: string; - requestBody: UpdateDeploymentEnv; +export type UpdateDeploymentV1DeploymentsDeploymentIdPutData = { + deploymentId: string; + requestBody: DeploymentUpdate; }; -export type SetEnvVarsV1DeploymentsNameSetEnvVarsPostResponse = unknown; +export type UpdateDeploymentV1DeploymentsDeploymentIdPutResponse = DeploymentDefinition; -export type ListExperimentalFeaturesV1ExperimentalFeaturesGetResponse = unknown; +export type GetDeploymentV1DeploymentsDeploymentIdGetData = { + deploymentId: string; +}; + +export type GetDeploymentV1DeploymentsDeploymentIdGetResponse = DeploymentDefinition; + +export type DeleteDeploymentV1DeploymentsDeploymentIdDeleteData = { + deploymentId: string; +}; + +export type DeleteDeploymentV1DeploymentsDeploymentIdDeleteResponse = DeleteDeployment; + +export type UpdateConfigV1DeploymentsDeploymentIdUpdateConfigPostData = { + deploymentId: string; + requestBody: UpdateDeploymentEnv; +}; + +export type UpdateConfigV1DeploymentsDeploymentIdUpdateConfigPostResponse = unknown; + +export type ListExperimentalFeaturesV1ExperimentalFeaturesGetResponse = { + [key: string]: (boolean); +}; export type CreateAgentV1AgentsPostData = { - requestBody: CreateAgent; + requestBody: CreateAgentRequest; }; export type CreateAgentV1AgentsPostResponse = AgentPublic; export type ListAgentsV1AgentsGetData = { - limit?: number; - offset?: number; + limit?: number; + offset?: number; + organizationId?: string | null; + visibility?: AgentVisibility; }; export type ListAgentsV1AgentsGetResponse = Array; export type GetAgentByIdV1AgentsAgentIdGetData = { - agentId: string; + agentId: string; }; -export type GetAgentByIdV1AgentsAgentIdGetResponse = Agent; +export type GetAgentByIdV1AgentsAgentIdGetResponse = AgentPublic; export type UpdateAgentV1AgentsAgentIdPutData = { - agentId: string; - requestBody: UpdateAgent; + agentId: string; + requestBody: UpdateAgentRequest; }; export type UpdateAgentV1AgentsAgentIdPutResponse = AgentPublic; export type DeleteAgentV1AgentsAgentIdDeleteData = { - agentId: string; + agentId: string; }; export type DeleteAgentV1AgentsAgentIdDeleteResponse = DeleteAgent; +export type GetAgentDeploymentsV1AgentsAgentIdDeploymentsGetData = { + agentId: string; +}; + +export type GetAgentDeploymentsV1AgentsAgentIdDeploymentsGetResponse = Array; + export type ListAgentToolMetadataV1AgentsAgentIdToolMetadataGetData = { - agentId: string; + agentId: string; }; -export type ListAgentToolMetadataV1AgentsAgentIdToolMetadataGetResponse = - Array; +export type ListAgentToolMetadataV1AgentsAgentIdToolMetadataGetResponse = Array; export type CreateAgentToolMetadataV1AgentsAgentIdToolMetadataPostData = { - agentId: string; - requestBody: CreateAgentToolMetadata; + agentId: string; + requestBody: CreateAgentToolMetadataRequest; }; -export type CreateAgentToolMetadataV1AgentsAgentIdToolMetadataPostResponse = - AgentToolMetadataPublic; +export type CreateAgentToolMetadataV1AgentsAgentIdToolMetadataPostResponse = AgentToolMetadataPublic; export type UpdateAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdPutData = { - agentId: string; - agentToolMetadataId: string; - requestBody: UpdateAgentToolMetadata; + agentId: string; + agentToolMetadataId: string; + requestBody: UpdateAgentToolMetadataRequest; }; -export type UpdateAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdPutResponse = - AgentToolMetadata; +export type UpdateAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdPutResponse = AgentToolMetadata; export type DeleteAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdDeleteData = { - agentId: string; - agentToolMetadataId: string; + agentId: string; + agentToolMetadataId: string; +}; + +export type DeleteAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdDeleteResponse = DeleteAgentToolMetadata; + +export type BatchUploadFileV1AgentsBatchUploadFilePostData = { + formData: Body_batch_upload_file_v1_agents_batch_upload_file_post; +}; + +export type BatchUploadFileV1AgentsBatchUploadFilePostResponse = Array; + +export type DeleteAgentFileV1AgentsAgentIdFilesFileIdDeleteData = { + agentId: string; + fileId: string; }; -export type DeleteAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdDeleteResponse = - DeleteAgentToolMetadata; +export type DeleteAgentFileV1AgentsAgentIdFilesFileIdDeleteResponse = DeleteAgentFileResponse; export type ListSnapshotsV1SnapshotsGetResponse = Array; export type CreateSnapshotV1SnapshotsPostData = { - requestBody: CreateSnapshot; + requestBody: CreateSnapshotRequest; }; export type CreateSnapshotV1SnapshotsPostResponse = CreateSnapshotResponse; export type GetSnapshotV1SnapshotsLinkLinkIdGetData = { - linkId: string; + linkId: string; }; -export type GetSnapshotV1SnapshotsLinkLinkIdGetResponse = Snapshot; +export type GetSnapshotV1SnapshotsLinkLinkIdGetResponse = SnapshotPublic; export type DeleteSnapshotLinkV1SnapshotsLinkLinkIdDeleteData = { - linkId: string; + linkId: string; }; -export type DeleteSnapshotLinkV1SnapshotsLinkLinkIdDeleteResponse = unknown; +export type DeleteSnapshotLinkV1SnapshotsLinkLinkIdDeleteResponse = DeleteSnapshotLinkResponse; export type DeleteSnapshotV1SnapshotsSnapshotIdDeleteData = { - snapshotId: string; + snapshotId: string; +}; + +export type DeleteSnapshotV1SnapshotsSnapshotIdDeleteResponse = DeleteSnapshotResponse; + +export type ListOrganizationsV1OrganizationsGetResponse = Array; + +export type CreateOrganizationV1OrganizationsPostData = { + requestBody: CreateOrganization; +}; + +export type CreateOrganizationV1OrganizationsPostResponse = Organization; + +export type UpdateOrganizationV1OrganizationsOrganizationIdPutData = { + organizationId: string; + requestBody: UpdateOrganization; }; -export type DeleteSnapshotV1SnapshotsSnapshotIdDeleteResponse = unknown; +export type UpdateOrganizationV1OrganizationsOrganizationIdPutResponse = Organization; + +export type GetOrganizationV1OrganizationsOrganizationIdGetData = { + organizationId: string; +}; + +export type GetOrganizationV1OrganizationsOrganizationIdGetResponse = Organization; + +export type DeleteOrganizationV1OrganizationsOrganizationIdDeleteData = { + organizationId: string; +}; + +export type DeleteOrganizationV1OrganizationsOrganizationIdDeleteResponse = DeleteOrganization; + +export type GetOrganizationUsersV1OrganizationsOrganizationIdUsersGetData = { + organizationId: string; +}; + +export type GetOrganizationUsersV1OrganizationsOrganizationIdUsersGetResponse = Array; + +export type CreateModelV1ModelsPostData = { + requestBody: ModelCreate; +}; + +export type CreateModelV1ModelsPostResponse = Model; + +export type ListModelsV1ModelsGetData = { + limit?: number; + offset?: number; +}; + +export type ListModelsV1ModelsGetResponse = Array; + +export type UpdateModelV1ModelsModelIdPutData = { + modelId: string; + requestBody: ModelUpdate; +}; + +export type UpdateModelV1ModelsModelIdPutResponse = Model; + +export type GetModelV1ModelsModelIdGetData = { + modelId: string; +}; + +export type GetModelV1ModelsModelIdGetResponse = Model; + +export type DeleteModelV1ModelsModelIdDeleteData = { + modelId: string; +}; + +export type DeleteModelV1ModelsModelIdDeleteResponse = DeleteModel; + +export type GetUsersScimV2UsersGetData = { + count?: number; + filter?: string | null; + startIndex?: number; +}; + +export type GetUsersScimV2UsersGetResponse = ListUserResponse; + +export type CreateUserScimV2UsersPostData = { + requestBody: backend__schemas__scim__CreateUser; +}; + +export type CreateUserScimV2UsersPostResponse = unknown; + +export type GetUserScimV2UsersUserIdGetData = { + userId: string; +}; + +export type GetUserScimV2UsersUserIdGetResponse = unknown; + +export type UpdateUserScimV2UsersUserIdPutData = { + requestBody: backend__schemas__scim__UpdateUser; + userId: string; +}; + +export type UpdateUserScimV2UsersUserIdPutResponse = unknown; + +export type PatchUserScimV2UsersUserIdPatchData = { + requestBody: PatchUser; + userId: string; +}; + +export type PatchUserScimV2UsersUserIdPatchResponse = unknown; + +export type GetGroupsScimV2GroupsGetData = { + count?: number; + filter?: string | null; + startIndex?: number; +}; + +export type GetGroupsScimV2GroupsGetResponse = ListGroupResponse; + +export type CreateGroupScimV2GroupsPostData = { + requestBody: CreateGroup; +}; + +export type CreateGroupScimV2GroupsPostResponse = unknown; + +export type GetGroupScimV2GroupsGroupIdGetData = { + groupId: string; +}; + +export type GetGroupScimV2GroupsGroupIdGetResponse = unknown; + +export type PatchGroupScimV2GroupsGroupIdPatchData = { + groupId: string; + requestBody: PatchGroup; +}; + +export type PatchGroupScimV2GroupsGroupIdPatchResponse = unknown; + +export type DeleteGroupScimV2GroupsGroupIdDeleteData = { + groupId: string; +}; + +export type DeleteGroupScimV2GroupsGroupIdDeleteResponse = void; export type HealthHealthGetResponse = unknown; export type ApplyMigrationsMigratePostResponse = unknown; export type $OpenApiTs = { - '/v1/auth_strategies': { - get: { - res: { - /** - * Successful Response - */ - 200: Array; - }; + '/v1/auth_strategies': { + get: { + res: { + /** + * Successful Response + */ + 200: Array; + }; + }; }; - }; - '/v1/login': { - post: { - req: LoginV1LoginPostData; - res: { - /** - * Successful Response - */ - 200: JWTResponse | null; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/login': { + post: { + req: LoginV1LoginPostData; + res: { + /** + * Successful Response + */ + 200: JWTResponse | null; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/{strategy}/auth': { - post: { - req: AuthorizeV1StrategyAuthPostData; - res: { - /** - * Successful Response - */ - 200: JWTResponse; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/{strategy}/auth': { + post: { + req: AuthorizeV1StrategyAuthPostData; + res: { + /** + * Successful Response + */ + 200: JWTResponse; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/logout': { - get: { - res: { - /** - * Successful Response - */ - 200: Logout; - }; + '/v1/logout': { + get: { + res: { + /** + * Successful Response + */ + 200: Logout; + }; + }; }; - }; - '/v1/tool/auth': { - get: { - res: { - /** - * Successful Response - */ - 200: unknown; - }; + '/v1/tool/auth': { + get: { + res: { + /** + * Successful Response + */ + 200: unknown; + }; + }; }; - }; - '/v1/chat-stream': { - post: { - req: ChatStreamV1ChatStreamPostData; - res: { - /** - * Successful Response - */ - 200: Array; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/tool/auth/{tool_id}': { + delete: { + req: DeleteToolAuthV1ToolAuthToolIdDeleteData; + res: { + /** + * Successful Response + */ + 200: DeleteToolAuth; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/chat': { - post: { - req: ChatV1ChatPostData; - res: { - /** - * Successful Response - */ - 200: NonStreamedChatResponse; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/chat-stream': { + post: { + req: ChatStreamV1ChatStreamPostData; + res: { + /** + * Successful Response + */ + 200: Array; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/langchain-chat': { - post: { - req: LangchainChatStreamV1LangchainChatPostData; - res: { - /** - * Successful Response - */ - 200: unknown; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/chat-stream/regenerate': { + post: { + req: RegenerateChatStreamV1ChatStreamRegeneratePostData; + res: { + /** + * Successful Response + */ + 200: unknown; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/users': { - post: { - req: CreateUserV1UsersPostData; - res: { - /** - * Successful Response - */ - 200: User; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/chat': { + post: { + req: ChatV1ChatPostData; + res: { + /** + * Successful Response + */ + 200: NonStreamedChatResponse; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - get: { - req: ListUsersV1UsersGetData; - res: { - /** - * Successful Response - */ - 200: Array; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/users': { + post: { + req: CreateUserV1UsersPostData; + res: { + /** + * Successful Response + */ + 200: backend__schemas__user__User; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + get: { + req: ListUsersV1UsersGetData; + res: { + /** + * Successful Response + */ + 200: Array; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/users/{user_id}': { - get: { - req: GetUserV1UsersUserIdGetData; - res: { - /** - * Successful Response - */ - 200: User; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/users/{user_id}': { + get: { + req: GetUserV1UsersUserIdGetData; + res: { + /** + * Successful Response + */ + 200: backend__schemas__user__User; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + put: { + req: UpdateUserV1UsersUserIdPutData; + res: { + /** + * Successful Response + */ + 200: backend__schemas__user__User; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + delete: { + req: DeleteUserV1UsersUserIdDeleteData; + res: { + /** + * Successful Response + */ + 200: DeleteUser; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - put: { - req: UpdateUserV1UsersUserIdPutData; - res: { - /** - * Successful Response - */ - 200: User; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/conversations/{conversation_id}': { + get: { + req: GetConversationV1ConversationsConversationIdGetData; + res: { + /** + * Successful Response + */ + 200: ConversationPublic; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + put: { + req: UpdateConversationV1ConversationsConversationIdPutData; + res: { + /** + * Successful Response + */ + 200: ConversationPublic; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + delete: { + req: DeleteConversationV1ConversationsConversationIdDeleteData; + res: { + /** + * Successful Response + */ + 200: DeleteConversationResponse; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - delete: { - req: DeleteUserV1UsersUserIdDeleteData; - res: { - /** - * Successful Response - */ - 200: DeleteUser; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/conversations': { + get: { + req: ListConversationsV1ConversationsGetData; + res: { + /** + * Successful Response + */ + 200: Array; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/conversations/{conversation_id}': { - get: { - req: GetConversationV1ConversationsConversationIdGetData; - res: { - /** - * Successful Response - */ - 200: Conversation; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/conversations/{conversation_id}/toggle-pin': { + put: { + req: ToggleConversationPinV1ConversationsConversationIdTogglePinPutData; + res: { + /** + * Successful Response + */ + 200: ConversationWithoutMessages; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - put: { - req: UpdateConversationV1ConversationsConversationIdPutData; - res: { - /** - * Successful Response - */ - 200: Conversation; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/conversations:search': { + get: { + req: SearchConversationsV1ConversationsSearchGetData; + res: { + /** + * Successful Response + */ + 200: Array; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - delete: { - req: DeleteConversationV1ConversationsConversationIdDeleteData; - res: { - /** - * Successful Response - */ - 200: DeleteConversation; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/conversations/batch_upload_file': { + post: { + req: BatchUploadFileV1ConversationsBatchUploadFilePostData; + res: { + /** + * Successful Response + */ + 200: Array; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/conversations': { - get: { - req: ListConversationsV1ConversationsGetData; - res: { - /** - * Successful Response - */ - 200: Array; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/conversations/{conversation_id}/files': { + get: { + req: ListFilesV1ConversationsConversationIdFilesGetData; + res: { + /** + * Successful Response + */ + 200: Array; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/conversations:search': { - get: { - req: SearchConversationsV1ConversationsSearchGetData; - res: { - /** - * Successful Response - */ - 200: Array; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/conversations/{conversation_id}/files/{file_id}': { + delete: { + req: DeleteFileV1ConversationsConversationIdFilesFileIdDeleteData; + res: { + /** + * Successful Response + */ + 200: DeleteConversationFileResponse; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/conversations/upload_file': { - post: { - req: UploadFileV1ConversationsUploadFilePostData; - res: { - /** - * Successful Response - */ - 200: UploadFile; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/conversations/{conversation_id}/generate-title': { + post: { + req: GenerateTitleV1ConversationsConversationIdGenerateTitlePostData; + res: { + /** + * Successful Response + */ + 200: GenerateTitleResponse; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/conversations/batch_upload_file': { - post: { - req: BatchUploadFileV1ConversationsBatchUploadFilePostData; - res: { - /** - * Successful Response - */ - 200: Array; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/conversations/{conversation_id}/synthesize/{message_id}': { + get: { + req: SynthesizeMessageV1ConversationsConversationIdSynthesizeMessageIdGetData; + res: { + /** + * Successful Response + */ + 200: unknown; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/conversations/{conversation_id}/files': { - get: { - req: ListFilesV1ConversationsConversationIdFilesGetData; - res: { - /** - * Successful Response - */ - 200: Array; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/tools': { + get: { + req: ListToolsV1ToolsGetData; + res: { + /** + * Successful Response + */ + 200: Array; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/conversations/{conversation_id}/files/{file_id}': { - put: { - req: UpdateFileV1ConversationsConversationIdFilesFileIdPutData; - res: { - /** - * Successful Response - */ - 200: File; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/deployments': { + post: { + req: CreateDeploymentV1DeploymentsPostData; + res: { + /** + * Successful Response + */ + 200: DeploymentDefinition; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + get: { + req: ListDeploymentsV1DeploymentsGetData; + res: { + /** + * Successful Response + */ + 200: Array; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - delete: { - req: DeleteFileV1ConversationsConversationIdFilesFileIdDeleteData; - res: { - /** - * Successful Response - */ - 200: DeleteFile; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/deployments/{deployment_id}': { + put: { + req: UpdateDeploymentV1DeploymentsDeploymentIdPutData; + res: { + /** + * Successful Response + */ + 200: DeploymentDefinition; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + get: { + req: GetDeploymentV1DeploymentsDeploymentIdGetData; + res: { + /** + * Successful Response + */ + 200: DeploymentDefinition; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + delete: { + req: DeleteDeploymentV1DeploymentsDeploymentIdDeleteData; + res: { + /** + * Successful Response + */ + 200: DeleteDeployment; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/conversations/{conversation_id}/generate-title': { - post: { - req: GenerateTitleV1ConversationsConversationIdGenerateTitlePostData; - res: { - /** - * Successful Response - */ - 200: GenerateTitle; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/deployments/{deployment_id}/update_config': { + post: { + req: UpdateConfigV1DeploymentsDeploymentIdUpdateConfigPostData; + res: { + /** + * Successful Response + */ + 200: unknown; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/tools': { - get: { - req: ListToolsV1ToolsGetData; - res: { - /** - * Successful Response - */ - 200: Array; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/experimental_features/': { + get: { + res: { + /** + * Successful Response + */ + 200: { + [key: string]: (boolean); + }; + }; + }; }; - }; - '/v1/deployments': { - get: { - req: ListDeploymentsV1DeploymentsGetData; - res: { - /** - * Successful Response - */ - 200: Array; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/agents': { + post: { + req: CreateAgentV1AgentsPostData; + res: { + /** + * Successful Response + */ + 200: AgentPublic; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + get: { + req: ListAgentsV1AgentsGetData; + res: { + /** + * Successful Response + */ + 200: Array; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/deployments/{name}/set_env_vars': { - post: { - req: SetEnvVarsV1DeploymentsNameSetEnvVarsPostData; - res: { - /** - * Successful Response - */ - 200: unknown; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/agents/{agent_id}': { + get: { + req: GetAgentByIdV1AgentsAgentIdGetData; + res: { + /** + * Successful Response + */ + 200: AgentPublic; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + put: { + req: UpdateAgentV1AgentsAgentIdPutData; + res: { + /** + * Successful Response + */ + 200: AgentPublic; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + delete: { + req: DeleteAgentV1AgentsAgentIdDeleteData; + res: { + /** + * Successful Response + */ + 200: DeleteAgent; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/experimental_features/': { - get: { - res: { - /** - * Successful Response - */ - 200: unknown; - }; + '/v1/agents/{agent_id}/deployments': { + get: { + req: GetAgentDeploymentsV1AgentsAgentIdDeploymentsGetData; + res: { + /** + * Successful Response + */ + 200: Array; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/agents': { - post: { - req: CreateAgentV1AgentsPostData; - res: { - /** - * Successful Response - */ - 200: AgentPublic; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/agents/{agent_id}/tool-metadata': { + get: { + req: ListAgentToolMetadataV1AgentsAgentIdToolMetadataGetData; + res: { + /** + * Successful Response + */ + 200: Array; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + post: { + req: CreateAgentToolMetadataV1AgentsAgentIdToolMetadataPostData; + res: { + /** + * Successful Response + */ + 200: AgentToolMetadataPublic; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - get: { - req: ListAgentsV1AgentsGetData; - res: { - /** - * Successful Response - */ - 200: Array; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/agents/{agent_id}/tool-metadata/{agent_tool_metadata_id}': { + put: { + req: UpdateAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdPutData; + res: { + /** + * Successful Response + */ + 200: AgentToolMetadata; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + delete: { + req: DeleteAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdDeleteData; + res: { + /** + * Successful Response + */ + 200: DeleteAgentToolMetadata; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/agents/{agent_id}': { - get: { - req: GetAgentByIdV1AgentsAgentIdGetData; - res: { - /** - * Successful Response - */ - 200: Agent; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/agents/batch_upload_file': { + post: { + req: BatchUploadFileV1AgentsBatchUploadFilePostData; + res: { + /** + * Successful Response + */ + 200: Array; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - put: { - req: UpdateAgentV1AgentsAgentIdPutData; - res: { - /** - * Successful Response - */ - 200: AgentPublic; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/agents/{agent_id}/files/{file_id}': { + delete: { + req: DeleteAgentFileV1AgentsAgentIdFilesFileIdDeleteData; + res: { + /** + * Successful Response + */ + 200: DeleteAgentFileResponse; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - delete: { - req: DeleteAgentV1AgentsAgentIdDeleteData; - res: { - /** - * Successful Response - */ - 200: DeleteAgent; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/snapshots': { + get: { + res: { + /** + * Successful Response + */ + 200: Array; + }; + }; + post: { + req: CreateSnapshotV1SnapshotsPostData; + res: { + /** + * Successful Response + */ + 200: CreateSnapshotResponse; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/agents/{agent_id}/tool-metadata': { - get: { - req: ListAgentToolMetadataV1AgentsAgentIdToolMetadataGetData; - res: { - /** - * Successful Response - */ - 200: Array; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/snapshots/link/{link_id}': { + get: { + req: GetSnapshotV1SnapshotsLinkLinkIdGetData; + res: { + /** + * Successful Response + */ + 200: SnapshotPublic; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + delete: { + req: DeleteSnapshotLinkV1SnapshotsLinkLinkIdDeleteData; + res: { + /** + * Successful Response + */ + 200: DeleteSnapshotLinkResponse; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - post: { - req: CreateAgentToolMetadataV1AgentsAgentIdToolMetadataPostData; - res: { - /** - * Successful Response - */ - 200: AgentToolMetadataPublic; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/snapshots/{snapshot_id}': { + delete: { + req: DeleteSnapshotV1SnapshotsSnapshotIdDeleteData; + res: { + /** + * Successful Response + */ + 200: DeleteSnapshotResponse; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/agents/{agent_id}/tool-metadata/{agent_tool_metadata_id}': { - put: { - req: UpdateAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdPutData; - res: { - /** - * Successful Response - */ - 200: AgentToolMetadata; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/organizations': { + get: { + res: { + /** + * Successful Response + */ + 200: Array; + }; + }; + post: { + req: CreateOrganizationV1OrganizationsPostData; + res: { + /** + * Successful Response + */ + 200: Organization; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - delete: { - req: DeleteAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdDeleteData; - res: { - /** - * Successful Response - */ - 200: DeleteAgentToolMetadata; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/organizations/{organization_id}': { + put: { + req: UpdateOrganizationV1OrganizationsOrganizationIdPutData; + res: { + /** + * Successful Response + */ + 200: Organization; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + get: { + req: GetOrganizationV1OrganizationsOrganizationIdGetData; + res: { + /** + * Successful Response + */ + 200: Organization; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + delete: { + req: DeleteOrganizationV1OrganizationsOrganizationIdDeleteData; + res: { + /** + * Successful Response + */ + 200: DeleteOrganization; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/default_agent/': { - get: { - res: { - /** - * Successful Response - */ - 200: GenericResponseMessage; - }; + '/v1/organizations/{organization_id}/users': { + get: { + req: GetOrganizationUsersV1OrganizationsOrganizationIdUsersGetData; + res: { + /** + * Successful Response + */ + 200: Array; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/snapshots': { - get: { - res: { - /** - * Successful Response - */ - 200: Array; - }; + '/v1/models': { + post: { + req: CreateModelV1ModelsPostData; + res: { + /** + * Successful Response + */ + 200: Model; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + get: { + req: ListModelsV1ModelsGetData; + res: { + /** + * Successful Response + */ + 200: Array; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - post: { - req: CreateSnapshotV1SnapshotsPostData; - res: { - /** - * Successful Response - */ - 200: CreateSnapshotResponse; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/v1/models/{model_id}': { + put: { + req: UpdateModelV1ModelsModelIdPutData; + res: { + /** + * Successful Response + */ + 200: Model; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + get: { + req: GetModelV1ModelsModelIdGetData; + res: { + /** + * Successful Response + */ + 200: Model; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + delete: { + req: DeleteModelV1ModelsModelIdDeleteData; + res: { + /** + * Successful Response + */ + 200: DeleteModel; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/snapshots/link/{link_id}': { - get: { - req: GetSnapshotV1SnapshotsLinkLinkIdGetData; - res: { - /** - * Successful Response - */ - 200: Snapshot; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/scim/v2/Users': { + get: { + req: GetUsersScimV2UsersGetData; + res: { + /** + * Successful Response + */ + 200: ListUserResponse; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + post: { + req: CreateUserScimV2UsersPostData; + res: { + /** + * Successful Response + */ + 201: unknown; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - delete: { - req: DeleteSnapshotLinkV1SnapshotsLinkLinkIdDeleteData; - res: { - /** - * Successful Response - */ - 200: unknown; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/scim/v2/Users/{user_id}': { + get: { + req: GetUserScimV2UsersUserIdGetData; + res: { + /** + * Successful Response + */ + 200: unknown; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + put: { + req: UpdateUserScimV2UsersUserIdPutData; + res: { + /** + * Successful Response + */ + 200: unknown; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + patch: { + req: PatchUserScimV2UsersUserIdPatchData; + res: { + /** + * Successful Response + */ + 200: unknown; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/v1/snapshots/{snapshot_id}': { - delete: { - req: DeleteSnapshotV1SnapshotsSnapshotIdDeleteData; - res: { - /** - * Successful Response - */ - 200: unknown; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; + '/scim/v2/Groups': { + get: { + req: GetGroupsScimV2GroupsGetData; + res: { + /** + * Successful Response + */ + 200: ListGroupResponse; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + post: { + req: CreateGroupScimV2GroupsPostData; + res: { + /** + * Successful Response + */ + 201: unknown; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/health': { - get: { - res: { - /** - * Successful Response - */ - 200: unknown; - }; + '/scim/v2/Groups/{group_id}': { + get: { + req: GetGroupScimV2GroupsGroupIdGetData; + res: { + /** + * Successful Response + */ + 200: unknown; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + patch: { + req: PatchGroupScimV2GroupsGroupIdPatchData; + res: { + /** + * Successful Response + */ + 200: unknown; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + delete: { + req: DeleteGroupScimV2GroupsGroupIdDeleteData; + res: { + /** + * Successful Response + */ + 204: void; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; }; - }; - '/migrate': { - post: { - res: { - /** - * Successful Response - */ - 200: unknown; - }; + '/health': { + get: { + res: { + /** + * Successful Response + */ + 200: unknown; + }; + }; }; - }; -}; + '/migrate': { + post: { + res: { + /** + * Successful Response + */ + 200: unknown; + }; + }; + }; +}; \ No newline at end of file diff --git a/src/interfaces/coral_web/src/components/EditEnvVariablesButton.tsx b/src/interfaces/coral_web/src/components/EditEnvVariablesButton.tsx index 9bf92e7463..82906c1761 100644 --- a/src/interfaces/coral_web/src/components/EditEnvVariablesButton.tsx +++ b/src/interfaces/coral_web/src/components/EditEnvVariablesButton.tsx @@ -5,7 +5,7 @@ import React, { useContext, useMemo, useState } from 'react'; import { BasicButton, Button, Dropdown, DropdownOptionGroups, Input } from '@/components/Shared'; import { STRINGS } from '@/constants/strings'; import { ModalContext } from '@/context/ModalContext'; -import { useListAllDeployments } from '@/hooks/deployments'; +import { useListAllDeployments, useUpdateDeploymentConfig } from '@/hooks/deployments'; import { useParamsStore } from '@/stores'; /** @@ -40,16 +40,12 @@ export const EditEnvVariablesModal: React.FC<{ onClose: () => void; }> = ({ defaultDeployment, onClose }) => { const { data: deployments } = useListAllDeployments(); + const updateConfigMutation = useUpdateDeploymentConfig(); const [deployment, setDeployment] = useState(defaultDeployment); const [envVariables, setEnvVariables] = useState>(() => { const selectedDeployment = deployments?.find(({ name }) => name === defaultDeployment); - return ( - selectedDeployment?.env_vars.reduce>((acc, envVar) => { - acc[envVar] = ''; - return acc; - }, {}) ?? {} - ); + return selectedDeployment?.config ?? {}; }); const [isSubmitting, setIsSubmitting] = useState(false); @@ -68,14 +64,10 @@ export const EditEnvVariablesModal: React.FC<{ ); const handleDeploymentChange = (newDeployment: string) => { + console.log('newDeployment', newDeployment); setDeployment(newDeployment); const selectedDeployment = deployments?.find(({ name }) => name === newDeployment); - const emptyEnvVariables = - selectedDeployment?.env_vars.reduce>((acc, envVar) => { - acc[envVar] = ''; - return acc; - }, {}) ?? {}; - setEnvVariables(emptyEnvVariables); + setEnvVariables(selectedDeployment?.config ?? {}); }; const handleEnvVariableChange = (envVar: string) => (e: React.ChangeEvent) => { @@ -83,14 +75,13 @@ export const EditEnvVariablesModal: React.FC<{ }; const handleSubmit = async () => { + console.log('deployment', deployment); if (!deployment) return; + const selectedDeployment = deployments?.find(({ name }) => name === deployment); + if (!selectedDeployment) return; setIsSubmitting(true); - setParams({ - deploymentConfig: Object.entries(envVariables) - .map(([k, v]) => k + '=' + v) - .join(';'), - }); + await updateConfigMutation.mutateAsync({ deploymentId: selectedDeployment.id, config: envVariables }); setIsSubmitting(false); onClose(); }; @@ -108,7 +99,7 @@ export const EditEnvVariablesModal: React.FC<{ key={envVar} placeholder={STRINGS.value} label={envVar} - type="password" + type="text" value={envVariables[envVar]} onChange={handleEnvVariableChange(envVar)} /> diff --git a/src/interfaces/coral_web/src/hooks/deployments.ts b/src/interfaces/coral_web/src/hooks/deployments.ts index df5bfccc31..352851521c 100644 --- a/src/interfaces/coral_web/src/hooks/deployments.ts +++ b/src/interfaces/coral_web/src/hooks/deployments.ts @@ -1,14 +1,14 @@ -import { useQuery } from '@tanstack/react-query'; +import { useQuery, useMutation, UseQueryResult } from '@tanstack/react-query'; import { useMemo } from 'react'; -import { Deployment, useCohereClient } from '@/cohere-client'; +import { DeploymentDefinition, useCohereClient } from '@/cohere-client'; /** * @description Hook to get all possible deployments. */ -export const useListAllDeployments = (options?: { enabled?: boolean }) => { +export const useListAllDeployments = (options?: { enabled?: boolean }): UseQueryResult => { const cohereClient = useCohereClient(); - return useQuery({ + return useQuery({ queryKey: ['allDeployments'], queryFn: () => cohereClient.listDeployments({ all: true }), refetchOnWindowFocus: false, @@ -25,7 +25,18 @@ export const useModels = (deployment: string) => { const selectedDeployment = deployments?.find(({ name }) => name === deployment); if (!selectedDeployment) return []; return selectedDeployment.models; - }, [deployment]); + }, [deployment, deployments]); return { models }; }; + +/** + * @description Hook that provides a function for updating a deployment's configuration. + */ +export const useUpdateDeploymentConfig = () => { + const cohereClient = useCohereClient(); + return useMutation({ + mutationFn: ({ deploymentId, config }: { deploymentId: string; config: Record }) => + cohereClient.updateDeploymentConfig(deploymentId, { "env_vars": config }), + }); +}