Skip to content

Commit

Permalink
frontend: Fix assistants_web client imports (#820)
Browse files Browse the repository at this point in the history
* wip

* fix createuser issues
  • Loading branch information
tianjing-li authored Oct 24, 2024
1 parent 08af2ff commit 083b530
Show file tree
Hide file tree
Showing 16 changed files with 12 additions and 183 deletions.
11 changes: 0 additions & 11 deletions src/backend/config/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,6 @@ class RouterName(StrEnum):
Depends(validate_organization_header),
],
},
RouterName.DEFAULT_AGENT: {
"default": [
Depends(get_session),
Depends(validate_organization_header),
],
"auth": [
Depends(get_session),
Depends(validate_authorization),
Depends(validate_organization_header),
],
},
RouterName.SNAPSHOT: {
"default": [
Depends(get_session),
Expand Down
2 changes: 0 additions & 2 deletions src/backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
)
from backend.config.routers import ROUTER_DEPENDENCIES
from backend.config.settings import Settings
from backend.routers.agent import default_agent_router
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
Expand Down Expand Up @@ -48,7 +47,6 @@ def create_app():
deployment_router,
experimental_feature_router,
agent_router,
default_agent_router,
snapshot_router,
organization_router,
model_router,
Expand Down
8 changes: 0 additions & 8 deletions src/backend/routers/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
)
router.name = RouterName.AGENT


@router.post(
"",
response_model=AgentPublic,
Expand Down Expand Up @@ -663,10 +662,3 @@ async def delete_agent_file(
get_file_service().delete_agent_file_by_id(session, agent_id, file_id, user_id, ctx)

return DeleteAgentFileResponse()


# Default Agent Router
default_agent_router = APIRouter(
prefix="/v1/default_agent",
)
default_agent_router.name = RouterName.DEFAULT_AGENT
1 change: 0 additions & 1 deletion src/backend/routers/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ async def chat_stream(
ctx,
) = process_chat(session, chat_request, request, ctx)


return EventSourceResponse(
generate_chat_stream(
session,
Expand Down
12 changes: 1 addition & 11 deletions src/backend/schemas/agent.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime
from enum import StrEnum
from typing import Any, Dict, Optional
from typing import Optional

from pydantic import BaseModel, Field

Expand Down Expand Up @@ -115,16 +115,6 @@ class ListAgentsResponse(BaseModel):
agents: list[Agent]


class AgentTaskResponse(BaseModel):
task_id: str
status: str
result: Optional[Dict[str, Any]] = None
date_done: str
exception_snippet: Optional[str] = None
name: str
retries: int


class UpdateAgentRequest(BaseModel):
name: Optional[str] = None
version: Optional[int] = None
Expand Down
1 change: 0 additions & 1 deletion src/backend/services/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from backend.database_models.agent import Agent, AgentToolMetadata
from backend.database_models.database import DBSessionDep

TASK_TRACE_PREVIEW_LIMIT = 200

def validate_agent_exists(session: DBSessionDep, agent_id: str, user_id: str) -> Agent:
agent = agent_crud.get_agent_by_id(session, agent_id, user_id)
Expand Down
70 changes: 0 additions & 70 deletions src/interfaces/assistants_web/src/app/tasks/[agentId]/page.tsx

This file was deleted.

16 changes: 3 additions & 13 deletions src/interfaces/assistants_web/src/cohere-client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
CohereUnauthorizedError,
CreateAgentRequest,
CreateSnapshotRequest,
CreateUser,
CreateUserV1UsersPostData,
Fetch,
ToggleConversationPinRequest,
UpdateAgentRequest,
Expand Down Expand Up @@ -206,10 +206,8 @@ export class CohereClient {
return this.cohereService.default.getStrategiesV1AuthStrategiesGet();
}

public createUser(requestBody: CreateUser) {
return this.cohereService.default.createUserV1UsersPost({
requestBody,
});
public createUser(requestBody: CreateUserV1UsersPostData) {
return this.cohereService.default.createUserV1UsersPost(requestBody);
}

public async googleSSOAuth({ code }: { code: string }) {
Expand Down Expand Up @@ -271,14 +269,6 @@ export class CohereClient {
return this.cohereService.default.getAgentByIdV1AgentsAgentIdGet({ agentId });
}

public getAgentTasks(agentId: string) {
return this.cohereService.default.getAgentTasksV1AgentsAgentIdTasksGet({ agentId });
}

public getDefaultAgent() {
return this.cohereService.default.getDefaultAgentV1DefaultAgentGet();
}

public createAgent(requestBody: CreateAgentRequest) {
return this.cohereService.default.createAgentV1AgentsPost({ requestBody });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ export class DefaultService {
* Response: Synthesized audio file.
*
* Raises:
* HTTPException: If the message with the given ID is not found.
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ import {
LongPressMenu,
} from '@/components/UI';
import { Breakpoint, useBreakpoint } from '@/hooks';
import { useSettingsStore } from '@/stores';
import { useExperimentalFeatures } from '@/hooks/use-experimentalFeatures';
import { SynthesisStatus } from '@/hooks/use-synthesizer';

import { useSettingsStore } from '@/stores';
import {
type ChatMessage,
isAbortedMessage,
Expand Down Expand Up @@ -68,7 +67,7 @@ export const MessageRow = forwardRef<HTMLDivElement, Props>(function MessageRowI
// For showing thinking steps
const { showSteps } = useSettingsStore();
const [isStepsExpanded, setIsStepsExpanded] = useState(true);

useEffect(() => {
setIsStepsExpanded(showSteps);
}, [showSteps]);
Expand Down
29 changes: 0 additions & 29 deletions src/interfaces/assistants_web/src/hooks/use-agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,35 +70,6 @@ export const useAgent = ({ agentId }: { agentId?: string }) => {
});
};

export const useAgentTasks = ({ agentId }: { agentId?: string }) => {
const cohereClient = useCohereClient();
return useQuery({
queryKey: ['agentTasks', agentId],
queryFn: async () => {
try {
if (!agentId) {
throw new Error('must have agent id');
}
return await cohereClient.getAgentTasks(agentId);
} catch (e) {
console.error(e);
throw e;
}
},
});
};

export const useDefaultAgent = (enabled?: boolean) => {
const cohereClient = useCohereClient();
return useQuery({
queryKey: ['defaultAgent'],
enabled: enabled,
queryFn: async () => {
return await cohereClient.getDefaultAgent();
},
});
};

/**
* @description Returns a function to check if an agent name is unique.
*/
Expand Down
8 changes: 5 additions & 3 deletions src/interfaces/assistants_web/src/hooks/use-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ export const useSession = () => {
const registerMutation = useMutation({
mutationFn: async (params: RegisterParams) => {
return cohereClient.createUser({
fullname: params.name,
email: params.email,
password: params.password,
requestBody: {
fullname: params.name,
email: params.email,
password: params.password,
},
});
},
});
Expand Down
4 changes: 0 additions & 4 deletions src/interfaces/coral_web/src/cohere-client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,6 @@ export class CohereClient {
return this.cohereService.default.getAgentByIdV1AgentsAgentIdGet({ agentId });
}

public getDefaultAgent() {
return this.cohereService.default.getDefaultAgentV1DefaultAgentGet();
}

public createAgent(requestBody: CreateAgent) {
return this.cohereService.default.createAgentV1AgentsPost({ requestBody });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import type {
GetAgentByIdV1AgentsAgentIdGetResponse,
GetConversationV1ConversationsConversationIdGetData,
GetConversationV1ConversationsConversationIdGetResponse,
GetDefaultAgentV1DefaultAgentGetResponse,
GetSnapshotV1SnapshotsLinkLinkIdGetData,
GetSnapshotV1SnapshotsLinkLinkIdGetResponse,
GetStrategiesV1AuthStrategiesGetResponse,
Expand Down Expand Up @@ -1274,18 +1273,6 @@ export class DefaultService {
});
}

/**
* Get Default Agent
* @returns GenericResponseMessage Successful Response
* @throws ApiError
*/
public getDefaultAgentV1DefaultAgentGet(): CancelablePromise<GetDefaultAgentV1DefaultAgentGetResponse> {
return this.httpRequest.request({
method: 'GET',
url: '/v1/default_agent/',
});
}

/**
* List Snapshots
* List all snapshots.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -847,8 +847,6 @@ export type DeleteAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataI
export type DeleteAgentToolMetadataV1AgentsAgentIdToolMetadataAgentToolMetadataIdDeleteResponse =
DeleteAgentToolMetadata;

export type GetDefaultAgentV1DefaultAgentGetResponse = GenericResponseMessage;

export type ListSnapshotsV1SnapshotsGetResponse = Array<SnapshotWithLinks>;

export type CreateSnapshotV1SnapshotsPostData = {
Expand Down
11 changes: 0 additions & 11 deletions src/interfaces/coral_web/src/hooks/agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,6 @@ export const useAgent = ({ agentId }: { agentId?: string }) => {
});
};

export const useDefaultAgent = (enabled?: boolean) => {
const cohereClient = useCohereClient();
return useQuery({
queryKey: ['defaultAgent'],
enabled: enabled,
queryFn: async () => {
return await cohereClient.getDefaultAgent();
},
});
};

/**
* @description Returns a function to check if an agent name is unique.
*/
Expand Down

0 comments on commit 083b530

Please sign in to comment.