diff --git a/CODEOWNERS b/CODEOWNERS index 465981a4e5..abfd055b73 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,3 +1,3 @@ * @cohere-ai/toolkit @EugeneLightsOn @malexw @scottmx81 @tianjing-li -src/interfaces/coral_web @tomtobac @abimacarmes @knajjars -src/interfaces/assistants_web @tomtobac @abimacarmes @knajjars \ No newline at end of file +src/interfaces/coral_web @tomtobac @abimacarmes @knajjars @BeatrixCohere +src/interfaces/assistants_web @tomtobac @abimacarmes @knajjars @BeatrixCohere \ No newline at end of file diff --git a/src/backend/services/compass.py b/src/backend/services/compass.py index 78e04a906b..f44bacb50b 100644 --- a/src/backend/services/compass.py +++ b/src/backend/services/compass.py @@ -116,19 +116,19 @@ def invoke( index_name=parameters["index"] ) case self.ValidActions.CREATE.value: - self._create(parameters, **kwargs) + return self._create(parameters, **kwargs) case self.ValidActions.SEARCH.value: return self._search(parameters, **kwargs) case self.ValidActions.UPDATE.value: - self._update(parameters, **kwargs) + return self._update(parameters, **kwargs) case self.ValidActions.DELETE.value: - self._delete(parameters, **kwargs) + return self._delete(parameters, **kwargs) case self.ValidActions.GET_DOCUMENT.value: return self._get_document(parameters, **kwargs) case self.ValidActions.ADD_CONTEXT.value: - self._add_context(parameters, **kwargs) + return self._add_context(parameters, **kwargs) case self.ValidActions.REFRESH.value: - self._refresh(parameters, **kwargs) + return self._refresh(parameters, **kwargs) case self.ValidActions.PROCESS_FILE.value: return self._process_file(parameters, **kwargs) case _: diff --git a/src/backend/services/file.py b/src/backend/services/file.py index 316d9f66fe..81b0b58e20 100644 --- a/src/backend/services/file.py +++ b/src/backend/services/file.py @@ -318,6 +318,9 @@ def delete_all_conversation_files( if self.is_compass_enabled: compass = get_compass() try: + logger.info( + event=f"[Compass File Service] Deleting conversation {conversation_id} files from Compass" + ) compass.invoke( action=Compass.ValidActions.DELETE_INDEX, parameters={"index": conversation_id}, @@ -377,6 +380,9 @@ def delete_file_in_compass( compass = get_compass() try: + logger.info( + event=f"[Compass File Service] Deleting file {file_id} from Compass {index}" + ) compass.invoke( action=Compass.ValidActions.DELETE, parameters={"index": index, "file_id": file_id}, @@ -496,9 +502,12 @@ async def consolidate_agent_files_in_compass( action=Compass.ValidActions.REFRESH, parameters={"index": agent_id}, ) + logger.info( + event=f"[Compass File Service] Delete temporary file index: {file_id}" + ) # Remove the temporary file index entry compass.invoke( - action=Compass.ValidActions.DELETE_INDEX, parameters={"index": file_id} + action=Compass.ValidActions.DELETE_INDEX, parameters={"index": agent_id} ) except Exception as e: logger.error( diff --git a/src/backend/tools/google_drive/tool.py b/src/backend/tools/google_drive/tool.py index 158ed83e76..8ccf21f5a6 100644 --- a/src/backend/tools/google_drive/tool.py +++ b/src/backend/tools/google_drive/tool.py @@ -24,7 +24,7 @@ class GoogleDrive(BaseTool): @classmethod def is_available(cls) -> bool: - return cls.CLIENT_ID is not None and cls.CLIENT_ID is not None + return cls.CLIENT_ID is not None and cls.CLIENT_SECRET is not None def _handle_tool_specific_errors(cls, error: Exception, **kwargs: Any): message = "[Google Drive] Tool Error: {}".format(str(error)) diff --git a/src/interfaces/assistants_web/src/app/(main)/edit/[agentId]/page.tsx b/src/interfaces/assistants_web/src/app/(main)/edit/[agentId]/page.tsx index 6feb7f09e9..8776e588f6 100644 --- a/src/interfaces/assistants_web/src/app/(main)/edit/[agentId]/page.tsx +++ b/src/interfaces/assistants_web/src/app/(main)/edit/[agentId]/page.tsx @@ -1,6 +1,7 @@ import { NextPage } from 'next'; import { UpdateAgent } from '@/components/Agents/UpdateAgent'; +import { getCohereServerClient } from '@/server/cohereServerClient'; type Props = { params: { @@ -9,12 +10,11 @@ type Props = { searchParams: Record; }; -const Page: NextPage = ({ params }) => { - return ( -
- -
- ); +const Page: NextPage = async ({ params }) => { + const cohereServerClient = getCohereServerClient(); + const agent = await cohereServerClient.getAgent(params.agentId); + + return ; }; export default Page; diff --git a/src/interfaces/assistants_web/src/app/(main)/new/page.tsx b/src/interfaces/assistants_web/src/app/(main)/new/page.tsx index d6eb4257f8..28d642b0e4 100644 --- a/src/interfaces/assistants_web/src/app/(main)/new/page.tsx +++ b/src/interfaces/assistants_web/src/app/(main)/new/page.tsx @@ -1,5 +1,4 @@ import { Metadata } from 'next'; -import { Suspense } from 'react'; import { CreateAgent } from '@/components/Agents/CreateAgent'; @@ -8,13 +7,7 @@ export const metadata: Metadata = { }; const NewAssistantPage: React.FC = () => { - return ( - -
- -
-
- ); + return ; }; export default NewAssistantPage; diff --git a/src/interfaces/assistants_web/src/components/Agents/AgentSettings/AgentSettingsForm.tsx b/src/interfaces/assistants_web/src/components/Agents/AgentSettings/AgentSettingsForm.tsx index dec291de88..f36762e935 100644 --- a/src/interfaces/assistants_web/src/components/Agents/AgentSettings/AgentSettingsForm.tsx +++ b/src/interfaces/assistants_web/src/components/Agents/AgentSettings/AgentSettingsForm.tsx @@ -158,7 +158,7 @@ export const AgentSettingsForm: React.FC = (props) => { }; return ( -
+
{/* Step 1: Define your assistant - name, description, instruction */} { }; return ( -
+
@@ -114,14 +114,16 @@ export const CreateAgent: React.FC = () => {
Create assistant
-
- setPendingAssistant(fields)} - /> +
+
+ setPendingAssistant(fields)} + /> +
); diff --git a/src/interfaces/assistants_web/src/components/Agents/UpdateAgent.tsx b/src/interfaces/assistants_web/src/components/Agents/UpdateAgent.tsx index b01bef88b7..6c49acdfdd 100644 --- a/src/interfaces/assistants_web/src/components/Agents/UpdateAgent.tsx +++ b/src/interfaces/assistants_web/src/components/Agents/UpdateAgent.tsx @@ -2,8 +2,9 @@ import { useLocalStorageValue } from '@react-hookz/web'; import Link from 'next/link'; -import React, { useEffect, useState } from 'react'; +import React, { useState } from 'react'; +import { AgentPublic } from '@/cohere-client'; import { AgentSettingsFields, AgentSettingsForm, @@ -13,22 +14,30 @@ import { MobileHeader } from '@/components/MobileHeader'; import { Button, Icon, Spinner, Text } from '@/components/Shared'; import { DEFAULT_AGENT_MODEL, DEPLOYMENT_COHERE_PLATFORM } from '@/constants'; import { useContextStore } from '@/context'; -import { useAgent, useIsAgentNameUnique, useUpdateAgent } from '@/hooks/agents'; +import { useIsAgentNameUnique, useUpdateAgent } from '@/hooks/agents'; import { useNotify } from '@/hooks/toast'; type Props = { - agentId: string; + agent: AgentPublic; }; -export const UpdateAgent: React.FC = ({ agentId }) => { +export const UpdateAgent: React.FC = ({ agent }) => { const { error, success } = useNotify(); - const { data: agent, isLoading } = useAgent({ agentId }); const { open, close } = useContextStore(); const { mutateAsync: updateAgent } = useUpdateAgent(); const isAgentNameUnique = useIsAgentNameUnique(); const [isSubmitting, setIsSubmitting] = useState(false); - const [fields, setFields] = useState(); + const [fields, setFields] = useState({ + name: agent.name, + description: agent.description, + deployment: agent.deployment ?? DEPLOYMENT_COHERE_PLATFORM, + model: agent.model ?? DEFAULT_AGENT_MODEL, + tools: agent.tools, + preamble: agent.preamble, + tools_metadata: agent.tools_metadata, + is_private: agent.is_private, + }); const { set: setPendingAssistant } = useLocalStorageValue( 'pending_assistant', @@ -38,54 +47,24 @@ export const UpdateAgent: React.FC = ({ agentId }) => { } ); - useEffect(() => { - if (agent) { - setFields({ - name: agent.name, - description: agent.description, - deployment: agent.deployment ?? DEPLOYMENT_COHERE_PLATFORM, - model: agent.model ?? DEFAULT_AGENT_MODEL, - tools: agent.tools, - preamble: agent.preamble, - tools_metadata: agent.tools_metadata, - is_private: agent.is_private, - }); - } - }, [agent]); - const handleOpenDeleteModal = () => { - if (!agent || !agent.name || !agentId) return; open({ title: `Delete ${agent.name}`, - content: , + content: , }); }; - if (isLoading && !fields) { - return ( -
- -
- ); - } - - if (!agent || !fields) { - return ( -
- Unable to load assistant information -
- ); - } - const handleSubmit = async () => { - if (!agentId) return; const tools_metadata = (fields.tools_metadata ?? []).map((tool) => ({ ...tool, id: agent.tools_metadata?.find((t) => t.tool_name === tool.tool_name)?.id, })); try { setIsSubmitting(true); - const newAgent = await updateAgent({ request: { ...fields, tools_metadata }, agentId }); + const newAgent = await updateAgent({ + request: { ...fields, tools_metadata }, + agentId: agent.id, + }); setIsSubmitting(false); success(`Updated ${newAgent?.name}`); } catch (e) { @@ -96,7 +75,7 @@ export const UpdateAgent: React.FC = ({ agentId }) => { }; return ( -
+
@@ -108,16 +87,18 @@ export const UpdateAgent: React.FC = ({ agentId }) => {
Edit {agent.name}
-
- setPendingAssistant(fields)} - agentId={agentId} - /> -
+
+
+ setPendingAssistant(fields)} + agentId={agent.id} + /> +
+