Skip to content

Commit

Permalink
update latest collab-ai code
Browse files Browse the repository at this point in the history
  • Loading branch information
abuhurayra0889 committed Jun 11, 2024
1 parent 8a10c3a commit bc529cc
Show file tree
Hide file tree
Showing 243 changed files with 16,569 additions and 4,550 deletions.
9 changes: 6 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.0.1",
"@testing-library/user-event": "^13.5.0",
"antd": "^5.2.2",
"axios": "^0.27.2",
"antd": "^5.18.0",
"axios": "^1.6.8",
"bootstrap": "^5.2.2",
"bootstrap-icons": "^1.9.1",
"dompurify": "^3.0.9",
Expand All @@ -16,6 +16,7 @@
"js-cookie": "^3.0.5",
"marked": "^9.1.6",
"moment": "^2.29.4",
"openai": "^4.36.0",
"rc-scrollbars": "^1.1.6",
"react": "^18.0.0",
"react-bootstrap": "^2.5.0",
Expand All @@ -25,8 +26,10 @@
"react-icons": "^4.4.0",
"react-infinite-scroll-component": "^6.1.0",
"react-router-dom": "^6.3.0",
"react-scripts": "5.0.1",
"react-scripts": "^5.0.1",
"react-scroll": "^1.9.0",
"react-spinners": "^0.13.8",
"react-toastify": "^10.0.5",
"sass": "^1.50.0",
"socket.io-client": "^4.7.4",
"uuid": "^9.0.1",
Expand Down
34 changes: 27 additions & 7 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ import SuperAdminRoutes from "./component/RoutesData/SuperAdminRoutes";
import Templates from "./component/Prompt/Templates";
import TrackUsage from "./Pages/SuperAdmin/TrackUsage/TrackUsage";
import TrackUsageComponent from "./Pages/SuperAdmin/TrackUsage/TrackUsageComponent";

import PublicAssistant from "./Pages/ExploreGPTs";
import ProtectedRoutes from "./component/ProtectedRoute/ProtectedRoute";
import AssistantTypeList from "./Pages/AssistantType/index";
import TaskCommands from "./Pages/SuperAdmin/TaskCommands/TaskCommands";
function App() {
// Hook to get the current location
const location = useLocation();
Expand All @@ -56,7 +59,23 @@ function App() {
<Route path="promptlistview/:id" element={<PromptList />} />
<Route path="promptuserview" element={<PrompotUsersList />} />

<Route element={<ProtectedRoutes />}>
<Route
path="assistants/:assistant_id"
element={<AssistantsChatPage />}
/>
<Route
path="assistants/:assistant_id/:thread_id"
element={<AssistantsChatPage />}
/>
</Route>


<Route path="/assistant-types" element={<AssistantTypeList />} />


<Route path="/templates" element={<Templates />} />
<Route path="/public-assistant" element={<PublicAssistant />} />

{/* Protected Routes of SuperAdmin */}
<Route element={<SuperAdminRoutes />}>
Expand All @@ -74,10 +93,11 @@ function App() {
<Route path="/teams" element={<TeamList />} />

<Route path="/assistantsList" element={<AssistantsList />} />
<Route path="/trackUsage" element={<TrackUsageComponent/>} />
<Route path="/trackUsage" element={<TrackUsageComponent />} />
<Route path="/taskCommands" element={<TaskCommands />} />
</Route>
</Route>
<Route path="/assistants" element={<AssistantLayout />}>
{/* <Route path="/assistants" element={<AssistantLayout />}>
<Route
path=":assistant_name/:assistant_id"
element={<AssistantsChatPage />}
Expand All @@ -86,11 +106,11 @@ function App() {
path=":assistant_name/:assistant_id/:thread_id"
element={<AssistantsChatPage />}
/>
</Route>
</Route> */}
<Route
path="assistants/download/:file_id"
element={<AssistantFileDownloadPage />}
/>
path="assistants/download/:file_id"
element={<AssistantFileDownloadPage />}
/>
</Routes>
);
}
Expand Down
30 changes: 25 additions & 5 deletions client/src/Hooks/useAssistantFileUpload.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from "react";
import { message } from "antd";
import { message,Upload } from "antd";
import { createAssistantWithFiles, updateAssistantWithDetailsAndFiles } from "../api/assistant";
import {
retrievalFileTypes,
Expand All @@ -9,6 +9,8 @@ import {
const useAssistantFileUpload = (onDeleteFile, selectedTools, getInitialFiles) => {
const [fileList, setFileList] = useState([]);
const [uploading, setUploading] = useState(false);
const [countTotalFile, setCountTotalFile] = useState(0)
const [totalFileList,setTotalFileList] = useState([]);

useEffect(() => {
const initialFiles = getInitialFiles();
Expand All @@ -19,7 +21,7 @@ const useAssistantFileUpload = (onDeleteFile, selectedTools, getInitialFiles) =>
}));
setFileList(fileListFormatted);
}, [getInitialFiles]);

const handleCreateOrUpdateAssistantWithFiles = async (
formData,
editMode,
Expand Down Expand Up @@ -48,15 +50,22 @@ const useAssistantFileUpload = (onDeleteFile, selectedTools, getInitialFiles) =>

const handleRemoveFile = (file) => {
const newFileList = fileList.filter((f) => f.uid !== file.uid);
const newTotalFileList = totalFileList.filter((f) => f.uid !== file.uid);

setFileList(newFileList);
setTotalFileList(newTotalFileList);

if (file.uid.startsWith("existing")) {
const index = parseInt(file.uid.split("-")[1], 10);
onDeleteFile(index);
}
};
const handleAddFile = (file) => {
const fileExtension = `.${file.name.split(".").pop().toLowerCase()}`;
const handleAddFile = (file, fileList) => {
if (countTotalFile > 20) {
return false;

}
const fileExtension = `.${file.name.split(".").pop().toLowerCase()}`;
let allowedFileTypes = [];

const flatSelectedTools = Array.isArray(selectedTools)
Expand All @@ -80,8 +89,17 @@ const useAssistantFileUpload = (onDeleteFile, selectedTools, getInitialFiles) =>
message.error(`Unsupported file type: ${file.name} select the files that are supported for your tools enabled.`);
return false;
}
const existingFilenames = totalFileList.map(f => f.name);
if (existingFilenames.includes(file.name)) {
message.error(`The file "${file.name}" already exists. Please upload a file with a unique name.`);
return Upload.LIST_IGNORE;
}
else{
setFileList((prevList) => [...prevList, file]);
setTotalFileList((prevList) => [...prevList, file]);

}

setFileList((prevList) => [...prevList, file]);
return false;
};

Expand All @@ -94,6 +112,8 @@ const useAssistantFileUpload = (onDeleteFile, selectedTools, getInitialFiles) =>
fileList,
setFileList,
isUploading,
setCountTotalFile,
countTotalFile
};
};

Expand Down
49 changes: 45 additions & 4 deletions client/src/Hooks/useAssistantPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { axiosSecureInstance } from "../api/axios";
import { getUserID } from "../Utility/service";
import { SEARCH_ASSISTANTS } from "../api/assistant_api_constant";
import { deleteAssistant, fetchAllAssistants, fetchAssistantStatisticsForUser, fetchAssistantsCreatedByUser, fetchTeams, updateAssistant, updateAssistantTeams } from "../api/assistant";

import { addPublicAssistant, deletePublicAssistant, isPublicStateChange, deleteSinglePublicAssistant } from "../api/publicAssistant";
import { AssistantSetAsPublic,AssistantSetAsPrivate,AssistantNeedToActiveFirst } from "../constants/PublicAndPrivateAssistantMessages";
const initialLoaderState = {
ASSISTANT_UPDATING: false,
ASSISTANT_DELETING: false,
Expand Down Expand Up @@ -89,8 +90,11 @@ const useAssistantPage = () => {
const handleUpdateAssistant = async (assistantId, data) => {
try {
updateLoader({ ASSISTANT_UPDATING: assistantId });
const response = await updateAssistant(assistantId, data);
if(data.is_active === false){
await deleteSinglePublicAssistant(assistantId);

}
const response = await updateAssistant(assistantId, data);
if(response) {
handleFetchUserCreatedAssistants();
handleFetchAllAssistants(1);
Expand Down Expand Up @@ -239,7 +243,43 @@ const useAssistantPage = () => {

}


const handlePublicAssistantAdd = async (id, data, checked, assistantId, isActive) => {
updateLoader({ ASSISTANT_UPDATING: checked });
try {
if (checked == true && isActive == true) {
const response = await addPublicAssistant(id, data, checked, assistantId);
if (response?.data) {
const resp = await isPublicStateChange(id, data, checked, assistantId);
if (resp?.data) {
message.success(AssistantSetAsPublic);
}
}
}else if (checked == true && isActive == false) {
message.error(AssistantNeedToActiveFirst);
}
else {
const response = await deletePublicAssistant(id, data, checked, assistantId);
if (response?.data) {
const resp = await isPublicStateChange(id, data, checked, assistantId);
if (resp?.data) {
message.success(AssistantSetAsPrivate);
}
}


}


} catch(error) {

handleShowMessage(error?.response?.data?.message);
} finally {
updateLoader({ ASSISTANT_UPDATING: !checked });
}
handleFetchUserCreatedAssistants();
handleFetchAllAssistants(1);
};


return {
setAdminUserAssistants,
Expand Down Expand Up @@ -268,7 +308,8 @@ const useAssistantPage = () => {
setOrgAssistantSearchQuery,
//Search query for personal assistants
personalAssistantSearchQuery,
setPersonalAssistantSearchQuery
setPersonalAssistantSearchQuery,
handlePublicAssistantAdd
};
};

Expand Down
Loading

0 comments on commit bc529cc

Please sign in to comment.