From a897f737acb73f80af732685a8c2192becc20aee Mon Sep 17 00:00:00 2001 From: Scott <146760070+scott-cohere@users.noreply.github.com> Date: Mon, 10 Jun 2024 14:34:36 -0400 Subject: [PATCH] [coral-web] rename schema fields and update openapi client (#189) * update * update client --- src/backend/database_models/agent.py | 12 +- src/backend/schemas/agent.py | 14 +- src/backend/tests/crud/test_agent.py | 42 ++-- src/backend/tests/factories/agent.py | 18 +- src/backend/tests/routers/test_agent.py | 46 ++-- .../src/cohere-client/generated/index.ts | 7 + .../cohere-client/generated/models/Agent.ts | 23 ++ .../generated/models/AgentDeployment.ts | 10 + .../generated/models/AgentModel.ts | 10 + .../cohere-client/generated/models/Auth.ts | 7 + .../generated/models/ChatMessage.ts | 3 +- .../generated/models/ChatRole.ts | 4 +- .../generated/models/CohereChatRequest.ts | 1 + .../generated/models/CreateAgent.ts | 19 ++ .../generated/models/DeleteAgent.ts | 5 + .../cohere-client/generated/models/Login.ts | 2 +- .../models/NonStreamedChatResponse.ts | 1 - .../models/StreamCitationGeneration.ts | 1 - .../generated/models/StreamQueryGeneration.ts | 1 - .../models/StreamSearchQueriesGeneration.ts | 1 - .../generated/models/StreamSearchResults.ts | 1 - .../generated/models/StreamStart.ts | 1 - .../generated/models/StreamTextGeneration.ts | 1 - .../models/StreamToolCallsGeneration.ts | 1 - .../generated/models/StreamToolInput.ts | 1 - .../generated/models/StreamToolResult.ts | 1 - .../generated/models/UpdateAgent.ts | 19 ++ .../generated/services/DefaultService.ts | 223 ++++++++++++++++-- 28 files changed, 375 insertions(+), 100 deletions(-) create mode 100644 src/interfaces/coral_web/src/cohere-client/generated/models/Agent.ts create mode 100644 src/interfaces/coral_web/src/cohere-client/generated/models/AgentDeployment.ts create mode 100644 src/interfaces/coral_web/src/cohere-client/generated/models/AgentModel.ts create mode 100644 src/interfaces/coral_web/src/cohere-client/generated/models/Auth.ts create mode 100644 src/interfaces/coral_web/src/cohere-client/generated/models/CreateAgent.ts create mode 100644 src/interfaces/coral_web/src/cohere-client/generated/models/DeleteAgent.ts create mode 100644 src/interfaces/coral_web/src/cohere-client/generated/models/UpdateAgent.ts diff --git a/src/backend/database_models/agent.py b/src/backend/database_models/agent.py index a443d2e8c7..5097c46ed4 100644 --- a/src/backend/database_models/agent.py +++ b/src/backend/database_models/agent.py @@ -6,14 +6,14 @@ from backend.database_models.base import Base -class Deployment(StrEnum): +class AgentDeployment(StrEnum): COHERE_PLATFORM = "Cohere Platform" SAGE_MAKER = "SageMaker" AZURE = "Azure" BEDROCK = "Bedrock" -class Model(StrEnum): +class AgentModel(StrEnum): COMMAND_R = "command-r" COMMAND_R_PLUS = "command-r-plus" COMMAND_LIGHT = "command-light" @@ -33,9 +33,11 @@ class Agent(Base): # TODO @scott-cohere: eventually switch to Fkey when new deployment tables are implemented # TODO @scott-cohere: deployments have different names for models, need to implement mapping later # enum place holders - model: Mapped[Model] = mapped_column(Enum(Model, native_enum=False), nullable=False) - deployment: Mapped[Deployment] = mapped_column( - Enum(Deployment, native_enum=False), nullable=False + model: Mapped[AgentModel] = mapped_column( + Enum(AgentModel, native_enum=False), nullable=False + ) + deployment: Mapped[AgentDeployment] = mapped_column( + Enum(AgentDeployment, native_enum=False), nullable=False ) user_id: Mapped[str] = mapped_column(Text, nullable=False) diff --git a/src/backend/schemas/agent.py b/src/backend/schemas/agent.py index c3e48f8280..a9b5050459 100644 --- a/src/backend/schemas/agent.py +++ b/src/backend/schemas/agent.py @@ -3,7 +3,7 @@ from pydantic import BaseModel -from backend.database_models.agent import Deployment, Model +from backend.database_models.agent import AgentDeployment, AgentModel class AgentBase(BaseModel): @@ -22,8 +22,8 @@ class Agent(AgentBase): temperature: float # tools: List[Tool] - model: Model - deployment: Deployment + model: AgentModel + deployment: AgentDeployment class Config: from_attributes = True @@ -36,8 +36,8 @@ class CreateAgent(BaseModel): description: Optional[str] = None preamble: Optional[str] = None temperature: Optional[float] = None - model: Model - deployment: Deployment + model: AgentModel + deployment: AgentDeployment class Config: from_attributes = True @@ -50,8 +50,8 @@ class UpdateAgent(BaseModel): description: Optional[str] = None preamble: Optional[str] = None temperature: Optional[float] = None - model: Optional[Model] = None - deployment: Optional[Deployment] = None + model: Optional[AgentModel] = None + deployment: Optional[AgentDeployment] = None # tools: Optional[List[Tool]] = None class Config: diff --git a/src/backend/tests/crud/test_agent.py b/src/backend/tests/crud/test_agent.py index 945c6dc486..ce91729d29 100644 --- a/src/backend/tests/crud/test_agent.py +++ b/src/backend/tests/crud/test_agent.py @@ -4,7 +4,7 @@ from sqlalchemy.exc import IntegrityError from backend.crud import agent as agent_crud -from backend.database_models.agent import Agent, Deployment, Model +from backend.database_models.agent import Agent, AgentDeployment, AgentModel from backend.schemas.agent import UpdateAgent from backend.tests.factories import get_factory @@ -17,8 +17,8 @@ def test_create_agent(session, user): description="test", preamble="test", temperature=0.5, - model=Model.COMMAND_R_PLUS, - deployment=Deployment.COHERE_PLATFORM, + model=AgentModel.COMMAND_R_PLUS, + deployment=AgentDeployment.COHERE_PLATFORM, ) agent = agent_crud.create_agent(session, agent_data) @@ -28,8 +28,8 @@ def test_create_agent(session, user): assert agent.description == "test" assert agent.preamble == "test" assert agent.temperature == 0.5 - assert agent.model == Model.COMMAND_R_PLUS - assert agent.deployment == Deployment.COHERE_PLATFORM + assert agent.model == AgentModel.COMMAND_R_PLUS + assert agent.deployment == AgentDeployment.COHERE_PLATFORM agent = agent_crud.get_agent(session, agent.id) assert agent.user_id == user.id @@ -38,16 +38,16 @@ def test_create_agent(session, user): assert agent.description == "test" assert agent.preamble == "test" assert agent.temperature == 0.5 - assert agent.model == Model.COMMAND_R_PLUS - assert agent.deployment == Deployment.COHERE_PLATFORM + assert agent.model == AgentModel.COMMAND_R_PLUS + assert agent.deployment == AgentDeployment.COHERE_PLATFORM def test_create_agent_empty_non_required_fields(session, user): agent_data = Agent( user_id=user.id, name="test", - deployment=Deployment.COHERE_PLATFORM, - model=Model.COMMAND_R_PLUS, + deployment=AgentDeployment.COHERE_PLATFORM, + model=AgentModel.COMMAND_R_PLUS, ) agent = agent_crud.create_agent(session, agent_data) @@ -57,8 +57,8 @@ def test_create_agent_empty_non_required_fields(session, user): assert agent.description == "" assert agent.preamble == "" assert agent.temperature == 0.3 - assert agent.model == Model.COMMAND_R_PLUS - assert agent.deployment == Deployment.COHERE_PLATFORM + assert agent.model == AgentModel.COMMAND_R_PLUS + assert agent.deployment == AgentDeployment.COHERE_PLATFORM agent = agent_crud.get_agent(session, agent.id) assert agent.user_id == user.id @@ -67,15 +67,15 @@ def test_create_agent_empty_non_required_fields(session, user): assert agent.description == "" assert agent.preamble == "" assert agent.temperature == 0.3 - assert agent.model == Model.COMMAND_R_PLUS - assert agent.deployment == Deployment.COHERE_PLATFORM + assert agent.model == AgentModel.COMMAND_R_PLUS + assert agent.deployment == AgentDeployment.COHERE_PLATFORM def test_create_agent_missing_name(session, user): agent_data = Agent( user_id=user.id, - model=Model.COMMAND_R_PLUS, - deployment=Deployment.COHERE_PLATFORM, + model=AgentModel.COMMAND_R_PLUS, + deployment=AgentDeployment.COHERE_PLATFORM, ) with pytest.raises(IntegrityError): @@ -86,7 +86,7 @@ def test_create_agent_missing_model(session, user): agent_data = Agent( user_id=user.id, name="test", - deployment=Deployment.COHERE_PLATFORM, + deployment=AgentDeployment.COHERE_PLATFORM, ) with pytest.raises(IntegrityError): @@ -97,7 +97,7 @@ def test_create_agent_missing_deployment(session, user): agent_data = Agent( user_id=user.id, name="test", - model=Model.COMMAND_R_PLUS, + model=AgentModel.COMMAND_R_PLUS, ) with pytest.raises(IntegrityError): @@ -107,8 +107,8 @@ def test_create_agent_missing_deployment(session, user): def test_create_agent_missing_user_id(session): agent_data = Agent( name="test", - model=Model.COMMAND_R_PLUS, - deployment=Deployment.COHERE_PLATFORM, + model=AgentModel.COMMAND_R_PLUS, + deployment=AgentDeployment.COHERE_PLATFORM, ) with pytest.raises(IntegrityError): @@ -127,8 +127,8 @@ def test_create_agent_duplicate_name_version(session, user): description="test", preamble="test", temperature=0.5, - model=Model.COMMAND_R_PLUS, - deployment=Deployment.COHERE_PLATFORM, + model=AgentModel.COMMAND_R_PLUS, + deployment=AgentDeployment.COHERE_PLATFORM, ) with pytest.raises(IntegrityError): diff --git a/src/backend/tests/factories/agent.py b/src/backend/tests/factories/agent.py index d85270ef69..6122471ae5 100644 --- a/src/backend/tests/factories/agent.py +++ b/src/backend/tests/factories/agent.py @@ -1,6 +1,6 @@ import factory -from backend.database_models.agent import Agent, Deployment, Model +from backend.database_models.agent import Agent, AgentDeployment, AgentModel from .base import BaseFactory @@ -20,18 +20,18 @@ class Meta: model = factory.Faker( "random_element", elements=( - Model.COMMAND_R, - Model.COMMAND_R_PLUS, - Model.COMMAND_LIGHT, - Model.COMMAND, + AgentModel.COMMAND_R, + AgentModel.COMMAND_R_PLUS, + AgentModel.COMMAND_LIGHT, + AgentModel.COMMAND, ), ) deployment = factory.Faker( "random_element", elements=( - Deployment.COHERE_PLATFORM, - Deployment.SAGE_MAKER, - Deployment.AZURE, - Deployment.BEDROCK, + AgentDeployment.COHERE_PLATFORM, + AgentDeployment.SAGE_MAKER, + AgentDeployment.AZURE, + AgentDeployment.BEDROCK, ), ) diff --git a/src/backend/tests/routers/test_agent.py b/src/backend/tests/routers/test_agent.py index 2acc0f48c4..9bbdb3ca38 100644 --- a/src/backend/tests/routers/test_agent.py +++ b/src/backend/tests/routers/test_agent.py @@ -1,7 +1,7 @@ from fastapi.testclient import TestClient from sqlalchemy.orm import Session -from backend.database_models.agent import Agent, Deployment, Model +from backend.database_models.agent import Agent, AgentDeployment, AgentModel from backend.tests.factories import get_factory @@ -12,8 +12,8 @@ def test_create_agent(session_client: TestClient, session: Session) -> None: "description": "test description", "preamble": "test preamble", "temperature": 0.5, - "model": Model.COMMAND_R, - "deployment": Deployment.COHERE_PLATFORM, + "model": AgentModel.COMMAND_R, + "deployment": AgentDeployment.COHERE_PLATFORM, } response = session_client.post( @@ -48,8 +48,8 @@ def test_create_agent_missing_name( "description": "test description", "preamble": "test preamble", "temperature": 0.5, - "model": Model.COMMAND_R, - "deployment": Deployment.COHERE_PLATFORM, + "model": AgentModel.COMMAND_R, + "deployment": AgentDeployment.COHERE_PLATFORM, } response = session_client.post( "/v1/agents", json=request_json, headers={"User-Id": "123"} @@ -65,7 +65,7 @@ def test_create_agent_missing_model( "description": "test description", "preamble": "test preamble", "temperature": 0.5, - "deployment": Deployment.COHERE_PLATFORM, + "deployment": AgentDeployment.COHERE_PLATFORM, } response = session_client.post( "/v1/agents", json=request_json, headers={"User-Id": "123"} @@ -81,7 +81,7 @@ def test_create_agent_missing_deployment( "description": "test description", "preamble": "test preamble", "temperature": 0.5, - "model": Model.COMMAND_R, + "model": AgentModel.COMMAND_R, } response = session_client.post( "/v1/agents", json=request_json, headers={"User-Id": "123"} @@ -94,8 +94,8 @@ def test_create_agent_missing_user_id_header( ) -> None: request_json = { "name": "test agent", - "model": Model.COMMAND_R, - "deployment": Deployment.COHERE_PLATFORM, + "model": AgentModel.COMMAND_R, + "deployment": AgentDeployment.COHERE_PLATFORM, } response = session_client.post("/v1/agents", json=request_json) assert response.status_code == 401 @@ -106,8 +106,8 @@ def test_create_agent_missing_non_required_fields( ) -> None: request_json = { "name": "test agent", - "model": Model.COMMAND_R, - "deployment": Deployment.COHERE_PLATFORM, + "model": AgentModel.COMMAND_R, + "deployment": AgentDeployment.COHERE_PLATFORM, } print(request_json) @@ -216,8 +216,8 @@ def test_update_agent(session_client: TestClient, session: Session) -> None: description="test description", preamble="test preamble", temperature=0.5, - model=Model.COMMAND_R, - deployment=Deployment.COHERE_PLATFORM, + model=AgentModel.COMMAND_R, + deployment=AgentDeployment.COHERE_PLATFORM, ) request_json = { @@ -226,8 +226,8 @@ def test_update_agent(session_client: TestClient, session: Session) -> None: "description": "updated description", "preamble": "updated preamble", "temperature": 0.7, - "model": Model.COMMAND_R_PLUS, - "deployment": Deployment.SAGE_MAKER, + "model": AgentModel.COMMAND_R_PLUS, + "deployment": AgentDeployment.SAGE_MAKER, } response = session_client.put( @@ -240,8 +240,8 @@ def test_update_agent(session_client: TestClient, session: Session) -> None: assert updated_agent["description"] == "updated description" assert updated_agent["preamble"] == "updated preamble" assert updated_agent["temperature"] == 0.7 - assert updated_agent["model"] == Model.COMMAND_R_PLUS - assert updated_agent["deployment"] == Deployment.SAGE_MAKER + assert updated_agent["model"] == AgentModel.COMMAND_R_PLUS + assert updated_agent["deployment"] == AgentDeployment.SAGE_MAKER def test_partial_update_agent(session_client: TestClient, session: Session) -> None: @@ -251,8 +251,8 @@ def test_partial_update_agent(session_client: TestClient, session: Session) -> N description="test description", preamble="test preamble", temperature=0.5, - model=Model.COMMAND_R, - deployment=Deployment.COHERE_PLATFORM, + model=AgentModel.COMMAND_R, + deployment=AgentDeployment.COHERE_PLATFORM, ) request_json = { @@ -269,8 +269,8 @@ def test_partial_update_agent(session_client: TestClient, session: Session) -> N assert updated_agent["description"] == "test description" assert updated_agent["preamble"] == "test preamble" assert updated_agent["temperature"] == 0.5 - assert updated_agent["model"] == Model.COMMAND_R - assert updated_agent["deployment"] == Deployment.COHERE_PLATFORM + assert updated_agent["model"] == AgentModel.COMMAND_R + assert updated_agent["deployment"] == AgentDeployment.COHERE_PLATFORM def test_update_nonexistent_agent(session_client: TestClient, session: Session) -> None: @@ -293,8 +293,8 @@ def test_update_agent_wrong_model_deployment_enums( description="test description", preamble="test preamble", temperature=0.5, - model=Model.COMMAND_R, - deployment=Deployment.COHERE_PLATFORM, + model=AgentModel.COMMAND_R, + deployment=AgentDeployment.COHERE_PLATFORM, ) request_json = { 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 9b3dffeda2..845b82cc13 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/index.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/index.ts @@ -7,6 +7,10 @@ export { CancelablePromise, CancelError } from './core/CancelablePromise'; export { OpenAPI } from './core/OpenAPI'; export type { OpenAPIConfig } from './core/OpenAPI'; +export type { Agent } from './models/Agent'; +export { AgentDeployment } from './models/AgentDeployment'; +export { AgentModel } from './models/AgentModel'; +export type { Auth } from './models/Auth'; export type { Body_upload_file_v1_conversations_upload_file_post } from './models/Body_upload_file_v1_conversations_upload_file_post'; export { Category } from './models/Category'; export type { ChatMessage } from './models/ChatMessage'; @@ -17,7 +21,9 @@ export { CohereChatPromptTruncation } from './models/CohereChatPromptTruncation' export type { CohereChatRequest } from './models/CohereChatRequest'; export type { Conversation } from './models/Conversation'; export type { ConversationWithoutMessages } from './models/ConversationWithoutMessages'; +export type { CreateAgent } from './models/CreateAgent'; export type { CreateUser } from './models/CreateUser'; +export type { DeleteAgent } from './models/DeleteAgent'; export type { DeleteConversation } from './models/DeleteConversation'; export type { DeleteFile } from './models/DeleteFile'; export type { DeleteUser } from './models/DeleteUser'; @@ -47,6 +53,7 @@ export type { StreamToolResult } from './models/StreamToolResult'; export type { Tool } from './models/Tool'; export type { ToolCall } from './models/ToolCall'; export { ToolInputType } from './models/ToolInputType'; +export type { UpdateAgent } from './models/UpdateAgent'; export type { UpdateConversation } from './models/UpdateConversation'; export type { UpdateDeploymentEnv } from './models/UpdateDeploymentEnv'; export type { UpdateFile } from './models/UpdateFile'; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/Agent.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/Agent.ts new file mode 100644 index 0000000000..c51543700c --- /dev/null +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/Agent.ts @@ -0,0 +1,23 @@ +/* generated using openapi-typescript-codegen -- do no edit */ + +/* istanbul ignore file */ + +/* tslint:disable */ + +/* eslint-disable */ +import type { AgentDeployment } from './AgentDeployment'; +import type { AgentModel } from './AgentModel'; + +export type Agent = { + user_id: string; + id: string; + created_at: string; + updated_at: string; + version: number; + name: string; + description: string | null; + preamble: string | null; + temperature: number; + model: AgentModel; + deployment: AgentDeployment; +}; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/AgentDeployment.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/AgentDeployment.ts new file mode 100644 index 0000000000..78d833a765 --- /dev/null +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/AgentDeployment.ts @@ -0,0 +1,10 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export enum AgentDeployment { + COHERE_PLATFORM = 'Cohere Platform', + SAGE_MAKER = 'SageMaker', + AZURE = 'Azure', + BEDROCK = 'Bedrock', +} diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/AgentModel.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/AgentModel.ts new file mode 100644 index 0000000000..8e0b56d0f7 --- /dev/null +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/AgentModel.ts @@ -0,0 +1,10 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export enum AgentModel { + COMMAND_R = 'command-r', + COMMAND_R_PLUS = 'command-r-plus', + COMMAND_LIGHT = 'command-light', + COMMAND = 'command', +} diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/Auth.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/Auth.ts new file mode 100644 index 0000000000..6a7b355839 --- /dev/null +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/Auth.ts @@ -0,0 +1,7 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type Auth = { + strategy: string; +}; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/ChatMessage.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/ChatMessage.ts index be744e9e40..2cfa972f85 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/ChatMessage.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/ChatMessage.ts @@ -12,5 +12,6 @@ import type { ChatRole } from './ChatRole'; */ export type ChatMessage = { role: ChatRole; - message: string; + message: string | null; + tool_results?: null; }; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/ChatRole.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/ChatRole.ts index 1ab76b24f8..9700b1978d 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/ChatRole.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/ChatRole.ts @@ -3,9 +3,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * One of CHATBOT|USER to identify who the message is coming from. + * One of CHATBOT|USER|SYSTEM to identify who the message is coming from. */ export enum ChatRole { CHATBOT = 'CHATBOT', USER = 'USER', + SYSTEM = 'SYSTEM', + TOOL = 'TOOL', } diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/CohereChatRequest.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/CohereChatRequest.ts index 2deff6c712..63f30459ec 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/CohereChatRequest.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/CohereChatRequest.ts @@ -32,4 +32,5 @@ export type CohereChatRequest = { presence_penalty?: number | null; frequency_penalty?: number | null; prompt_truncation?: CohereChatPromptTruncation; + tool_results?: null; }; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/CreateAgent.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/CreateAgent.ts new file mode 100644 index 0000000000..592fd5b397 --- /dev/null +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/CreateAgent.ts @@ -0,0 +1,19 @@ +/* generated using openapi-typescript-codegen -- do no edit */ + +/* istanbul ignore file */ + +/* tslint:disable */ + +/* eslint-disable */ +import type { AgentDeployment } from './AgentDeployment'; +import type { AgentModel } from './AgentModel'; + +export type CreateAgent = { + name: string; + version?: number | null; + description?: string | null; + preamble?: string | null; + temperature?: number | null; + model: AgentModel; + deployment: AgentDeployment; +}; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/DeleteAgent.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/DeleteAgent.ts new file mode 100644 index 0000000000..0adf65e72f --- /dev/null +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/DeleteAgent.ts @@ -0,0 +1,5 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type DeleteAgent = {}; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/Login.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/Login.ts index 7153dc68b1..a5a5b9dfc7 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/Login.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/Login.ts @@ -4,5 +4,5 @@ /* eslint-disable */ export type Login = { strategy: string; - payload: Record; + payload?: Record | null; }; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/NonStreamedChatResponse.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/NonStreamedChatResponse.ts index bb79d59749..c5fbce5d4d 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/NonStreamedChatResponse.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/NonStreamedChatResponse.ts @@ -12,7 +12,6 @@ import type { SearchQuery } from './SearchQuery'; import type { ToolCall } from './ToolCall'; export type NonStreamedChatResponse = { - is_finished: boolean; response_id: string | null; generation_id: string | null; chat_history: Array | null; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/StreamCitationGeneration.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/StreamCitationGeneration.ts index 9bcddea103..4fdb76ad49 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/StreamCitationGeneration.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/StreamCitationGeneration.ts @@ -11,6 +11,5 @@ import type { Citation } from './Citation'; * Stream citation generation event. */ export type StreamCitationGeneration = { - is_finished: boolean; citations?: Array; }; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/StreamQueryGeneration.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/StreamQueryGeneration.ts index 5cfb098fe0..dcf35f9061 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/StreamQueryGeneration.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/StreamQueryGeneration.ts @@ -6,6 +6,5 @@ * Stream query generation event. */ export type StreamQueryGeneration = { - is_finished: boolean; query: string; }; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/StreamSearchQueriesGeneration.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/StreamSearchQueriesGeneration.ts index 1b10fc81ca..b37c78c4f2 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/StreamSearchQueriesGeneration.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/StreamSearchQueriesGeneration.ts @@ -11,6 +11,5 @@ import type { SearchQuery } from './SearchQuery'; * Stream queries generation event. */ export type StreamSearchQueriesGeneration = { - is_finished: boolean; search_queries?: Array; }; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/StreamSearchResults.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/StreamSearchResults.ts index 2bac2f36fc..bcaa372538 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/StreamSearchResults.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/StreamSearchResults.ts @@ -8,7 +8,6 @@ import type { Document } from './Document'; export type StreamSearchResults = { - is_finished: boolean; search_results?: Array>; documents?: Array; }; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/StreamStart.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/StreamStart.ts index d1881dba4f..8c99d68447 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/StreamStart.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/StreamStart.ts @@ -6,7 +6,6 @@ * Stream start event. */ export type StreamStart = { - is_finished: boolean; generation_id?: string | null; conversation_id?: string | null; }; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/StreamTextGeneration.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/StreamTextGeneration.ts index 4aa0b5b74e..2732dcd518 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/StreamTextGeneration.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/StreamTextGeneration.ts @@ -6,6 +6,5 @@ * Stream text generation event. */ export type StreamTextGeneration = { - is_finished: boolean; text: string; }; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/StreamToolCallsGeneration.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/StreamToolCallsGeneration.ts index 9b46169f6e..b0c58742ee 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/StreamToolCallsGeneration.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/StreamToolCallsGeneration.ts @@ -11,6 +11,5 @@ import type { ToolCall } from './ToolCall'; * Stream tool calls generation event. */ export type StreamToolCallsGeneration = { - is_finished: boolean; tool_calls?: Array; }; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/StreamToolInput.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/StreamToolInput.ts index c4676f3c37..197fb283a3 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/StreamToolInput.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/StreamToolInput.ts @@ -8,7 +8,6 @@ import type { ToolInputType } from './ToolInputType'; export type StreamToolInput = { - is_finished: boolean; input_type: ToolInputType; tool_name: string; input: string; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/StreamToolResult.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/StreamToolResult.ts index daca3c0a45..d185c99f28 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/StreamToolResult.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/StreamToolResult.ts @@ -8,7 +8,6 @@ import type { Document } from './Document'; export type StreamToolResult = { - is_finished: boolean; result: any; tool_name: string; documents?: Array; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/UpdateAgent.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/UpdateAgent.ts new file mode 100644 index 0000000000..fb30ce9a1f --- /dev/null +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/UpdateAgent.ts @@ -0,0 +1,19 @@ +/* generated using openapi-typescript-codegen -- do no edit */ + +/* istanbul ignore file */ + +/* tslint:disable */ + +/* eslint-disable */ +import type { AgentDeployment } from './AgentDeployment'; +import type { AgentModel } from './AgentModel'; + +export type UpdateAgent = { + name?: string | null; + version?: number | null; + description?: string | null; + preamble?: string | null; + temperature?: number | null; + model?: AgentModel | null; + deployment?: AgentDeployment | null; +}; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/services/DefaultService.ts b/src/interfaces/coral_web/src/cohere-client/generated/services/DefaultService.ts index 60667b54af..82803b859f 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/services/DefaultService.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/services/DefaultService.ts @@ -8,12 +8,16 @@ import type { CancelablePromise } from '../core/CancelablePromise'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; +import type { Agent } from '../models/Agent'; +import type { Auth } from '../models/Auth'; import type { Body_upload_file_v1_conversations_upload_file_post } from '../models/Body_upload_file_v1_conversations_upload_file_post'; import type { ChatResponseEvent } from '../models/ChatResponseEvent'; import type { CohereChatRequest } from '../models/CohereChatRequest'; import type { Conversation } from '../models/Conversation'; import type { ConversationWithoutMessages } from '../models/ConversationWithoutMessages'; +import type { CreateAgent } from '../models/CreateAgent'; import type { CreateUser } from '../models/CreateUser'; +import type { DeleteAgent } from '../models/DeleteAgent'; import type { DeleteConversation } from '../models/DeleteConversation'; import type { DeleteFile } from '../models/DeleteFile'; import type { DeleteUser } from '../models/DeleteUser'; @@ -24,6 +28,7 @@ import type { ListFile } from '../models/ListFile'; import type { Login } from '../models/Login'; import type { ManagedTool } from '../models/ManagedTool'; import type { NonStreamedChatResponse } from '../models/NonStreamedChatResponse'; +import type { UpdateAgent } from '../models/UpdateAgent'; import type { UpdateConversation } from '../models/UpdateConversation'; import type { UpdateDeploymentEnv } from '../models/UpdateDeploymentEnv'; import type { UpdateFile } from '../models/UpdateFile'; @@ -33,30 +38,26 @@ import type { User } from '../models/User'; export class DefaultService { /** - * Get Session - * Retrievers the current session user. + * Get Strategies + * Retrieves the currently enabled list of Authentication strategies. * - * Args: - * request (Request): current Request object. * * Returns: - * session: current user session ({} if no active session) - * - * Raises: - * 401 HTTPException if no user found in session. + * List[dict]: List of dictionaries containing the enabled auth strategy names. * @returns any Successful Response * @throws ApiError */ - public static getSessionSessionGet(): CancelablePromise { + public static getStrategiesV1AuthStrategiesGet(): CancelablePromise { return __request(OpenAPI, { method: 'GET', - url: '/session', + url: '/v1/auth_strategies', }); } /** * Login - * Logs user in, verifying their credentials and either setting the user session, - * or redirecting to /auth endpoint. + * Logs user in and either: + * - (Basic email/password authentication) Verifies their credentials, retrieves the user and returns a JWT token. + * - (OAuth) Redirects to the /auth endpoint. * * Args: * request (Request): current Request object. @@ -64,17 +65,19 @@ export class DefaultService { * session (DBSessionDep): Database session. * * Returns: - * dict: On success. + * dict: JWT token on basic auth success + * or + * Redirect: to /auth endpoint * * Raises: * HTTPException: If the strategy or payload are invalid, or if the login fails. * @returns any Successful Response * @throws ApiError */ - public static loginLoginPost({ requestBody }: { requestBody: Login }): CancelablePromise { + public static loginV1LoginPost({ requestBody }: { requestBody: Login }): CancelablePromise { return __request(OpenAPI, { method: 'POST', - url: '/login', + url: '/v1/login', body: requestBody, mediaType: 'application/json', errors: { @@ -83,32 +86,53 @@ export class DefaultService { }); } /** - * Auth + * Authenticate + * Authentication endpoint used for OAuth strategies. Logs the user in the redirect environment and then + * sets the current session with the user returned from the auth token. + * + * Args: + * request (Request): current Request object. + * login (Login): Login payload. + * + * Returns: + * RedirectResponse: On success. + * + * Raises: + * HTTPException: If authentication fails, or strategy is invalid. * @returns any Successful Response * @throws ApiError */ - public static authAuthPost(): CancelablePromise { + public static authenticateV1AuthPost({ + requestBody, + }: { + requestBody: Auth; + }): CancelablePromise { return __request(OpenAPI, { method: 'POST', - url: '/auth', + url: '/v1/auth', + body: requestBody, + mediaType: 'application/json', + errors: { + 422: `Validation Error`, + }, }); } /** * Logout - * Logs out the current user session. + * Logs out the current user. * * Args: * request (Request): current Request object. * * Returns: - * dict: On success. + * dict: Empty on success * @returns any Successful Response * @throws ApiError */ - public static logoutLogoutGet(): CancelablePromise { + public static logoutV1LogoutGet(): CancelablePromise { return __request(OpenAPI, { method: 'GET', - url: '/logout', + url: '/v1/logout', }); } /** @@ -714,6 +738,161 @@ export class DefaultService { url: '/v1/experimental_features/', }); } + /** + * Create Agent + * @returns Agent Successful Response + * @throws ApiError + */ + public static createAgentV1AgentsPost({ + requestBody, + }: { + requestBody: CreateAgent; + }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/v1/agents', + body: 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[Agent]: List of agents. + * @returns Agent Successful Response + * @throws ApiError + */ + public static listAgentsV1AgentsGet({ + offset, + limit = 100, + }: { + offset?: number; + limit?: number; + }): CancelablePromise> { + return __request(OpenAPI, { + method: 'GET', + url: '/v1/agents', + query: { + offset: offset, + limit: limit, + }, + errors: { + 422: `Validation Error`, + }, + }); + } + /** + * Get Agent + * 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. + * @returns Agent Successful Response + * @throws ApiError + */ + public static getAgentV1AgentsAgentIdGet({ + agentId, + }: { + agentId: string; + }): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/v1/agents/{agent_id}', + path: { + agent_id: 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: + * Agent: Updated agent. + * + * Raises: + * HTTPException: If the agent with the given ID is not found. + * @returns Agent Successful Response + * @throws ApiError + */ + public static updateAgentV1AgentsAgentIdPut({ + agentId, + requestBody, + }: { + agentId: string; + requestBody: UpdateAgent; + }): CancelablePromise { + return __request(OpenAPI, { + method: 'PUT', + url: '/v1/agents/{agent_id}', + path: { + agent_id: agentId, + }, + body: 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. + * @returns DeleteAgent Successful Response + * @throws ApiError + */ + public static deleteAgentV1AgentsAgentIdDelete({ + agentId, + }: { + agentId: string; + }): CancelablePromise { + return __request(OpenAPI, { + method: 'DELETE', + url: '/v1/agents/{agent_id}', + path: { + agent_id: agentId, + }, + errors: { + 422: `Validation Error`, + }, + }); + } /** * Health * Health check for backend APIs