diff --git a/application/api/user/routes.py b/application/api/user/routes.py index f2d1be06..4bcbd719 100644 --- a/application/api/user/routes.py +++ b/application/api/user/routes.py @@ -185,8 +185,13 @@ class SubmitFeedback(Resource): ), "answer": fields.String(required=False, description="The AI answer"), "feedback": fields.String(required=True, description="User feedback"), - "question_index":fields.Integer(required=True, description="The question number in that particular conversation"), - "conversation_id":fields.String(required=True, description="id of the particular conversation"), + "question_index": fields.Integer( + required=True, + description="The question number in that particular conversation", + ), + "conversation_id": fields.String( + required=True, description="id of the particular conversation" + ), "api_key": fields.String(description="Optional API key"), }, ) @@ -196,21 +201,24 @@ class SubmitFeedback(Resource): ) def post(self): data = request.get_json() - required_fields = [ "feedback","conversation_id","question_index"] + required_fields = ["feedback", "conversation_id", "question_index"] missing_fields = check_required_fields(data, required_fields) if missing_fields: return missing_fields try: conversations_collection.update_one( - {"_id": ObjectId(data["conversation_id"]), f"queries.{data['question_index']}": {"$exists": True}}, - { - "$set": { - f"queries.{data['question_index']}.feedback": data["feedback"] - } - } - ) - + { + "_id": ObjectId(data["conversation_id"]), + f"queries.{data['question_index']}": {"$exists": True}, + }, + { + "$set": { + f"queries.{data['question_index']}.feedback": data["feedback"] + } + }, + ) + except Exception as err: return make_response(jsonify({"success": False, "error": str(err)}), 400) @@ -253,11 +261,9 @@ class DeleteOldIndexes(Resource): jsonify({"success": False, "message": "Missing required fields"}), 400 ) - doc = sources_collection.find_one( - {"_id": ObjectId(source_id), "user": "local"} - ) + doc = sources_collection.find_one({"_id": ObjectId(source_id), "user": "local"}) if not doc: - return make_response(jsonify({"status": "not found"}), 404) + return make_response(jsonify({"status": "not found"}), 404) try: if settings.VECTOR_STORE == "faiss": shutil.rmtree(os.path.join(current_dir, "indexes", str(doc["_id"]))) @@ -271,7 +277,7 @@ class DeleteOldIndexes(Resource): pass except Exception as err: return make_response(jsonify({"success": False, "error": str(err)}), 400) - + sources_collection.delete_one({"_id": ObjectId(source_id)}) return make_response(jsonify({"success": True}), 200) @@ -498,7 +504,9 @@ class PaginatedSources(Resource): total_documents = sources_collection.count_documents(query) total_pages = max(1, math.ceil(total_documents / rows_per_page)) - page = min(max(1, page), total_pages) # add this to make sure page inbound is within the range + page = min( + max(1, page), total_pages + ) # add this to make sure page inbound is within the range sort_order = 1 if sort_order == "asc" else -1 skip = (page - 1) * rows_per_page @@ -2098,4 +2106,3 @@ class DeleteTool(Resource): return {"success": False, "error": str(err)}, 400 return {"success": True}, 200 - \ No newline at end of file diff --git a/frontend/src/api/endpoints.ts b/frontend/src/api/endpoints.ts index 8a7f9ae2..66c334c1 100644 --- a/frontend/src/api/endpoints.ts +++ b/frontend/src/api/endpoints.ts @@ -23,6 +23,7 @@ const endpoints = { CREATE_TOOL: '/api/create_tool', UPDATE_TOOL_STATUS: '/api/update_tool_status', UPDATE_TOOL: '/api/update_tool', + DELETE_TOOL: '/api/delete_tool', }, CONVERSATION: { ANSWER: '/api/answer', diff --git a/frontend/src/api/services/userService.ts b/frontend/src/api/services/userService.ts index ab91a0a4..8a9b5858 100644 --- a/frontend/src/api/services/userService.ts +++ b/frontend/src/api/services/userService.ts @@ -45,6 +45,8 @@ const userService = { apiClient.post(endpoints.USER.UPDATE_TOOL_STATUS, data), updateTool: (data: any): Promise => apiClient.post(endpoints.USER.UPDATE_TOOL, data), + deleteTool: (data: any): Promise => + apiClient.post(endpoints.USER.DELETE_TOOL, data), }; export default userService; diff --git a/frontend/src/assets/no-files-dark.svg b/frontend/src/assets/no-files-dark.svg new file mode 100644 index 00000000..b1e28a0f --- /dev/null +++ b/frontend/src/assets/no-files-dark.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/frontend/src/assets/no-files.svg b/frontend/src/assets/no-files.svg new file mode 100644 index 00000000..36510546 --- /dev/null +++ b/frontend/src/assets/no-files.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/frontend/src/modals/AddToolModal.tsx b/frontend/src/modals/AddToolModal.tsx index 330cf3bb..0763321d 100644 --- a/frontend/src/modals/AddToolModal.tsx +++ b/frontend/src/modals/AddToolModal.tsx @@ -84,7 +84,7 @@ export default function AddToolModal({

Select a tool to set up

-
+
{availableTools.map((tool, index) => (
); } - -export default ConfirmationModal; diff --git a/frontend/src/modals/WrapperModal.tsx b/frontend/src/modals/WrapperModal.tsx index f17e0a8a..da718a7a 100644 --- a/frontend/src/modals/WrapperModal.tsx +++ b/frontend/src/modals/WrapperModal.tsx @@ -1,12 +1,13 @@ import React, { useEffect, useRef } from 'react'; -import { WrapperModalProps } from './types'; -import Exit from '../assets/exit.svg'; -const WrapperModal: React.FC = ({ +import Exit from '../assets/exit.svg'; +import { WrapperModalProps } from './types'; + +export default function WrapperModal({ children, close, isPerformingTask, -}) => { +}: WrapperModalProps) { const modalRef = useRef(null); useEffect(() => { @@ -39,10 +40,13 @@ const WrapperModal: React.FC = ({
{!isPerformingTask && ( - )} @@ -50,6 +54,4 @@ const WrapperModal: React.FC = ({
); -}; - -export default WrapperModal; +} diff --git a/frontend/src/settings/ToolConfig.tsx b/frontend/src/settings/ToolConfig.tsx index 0de4dab9..cd5516fd 100644 --- a/frontend/src/settings/ToolConfig.tsx +++ b/frontend/src/settings/ToolConfig.tsx @@ -58,6 +58,12 @@ export default function ToolConfig({ handleGoBack(); }); }; + + const handleDelete = () => { + userService.deleteTool({ id: tool.id }).then(() => { + handleGoBack(); + }); + }; return (
@@ -83,7 +89,7 @@ export default function ToolConfig({ Authentication

)} -
+
{Object.keys(tool?.config).length !== 0 && (
@@ -98,12 +104,20 @@ export default function ToolConfig({ >
)} - +
+ + +
@@ -118,7 +132,7 @@ export default function ToolConfig({ key={actionIndex} className="w-full border border-silver dark:border-silver/40 rounded-xl" > -
+

{action.name}

@@ -146,7 +160,7 @@ export default function ToolConfig({
-
+
('INACTIVE'); @@ -86,62 +90,77 @@ export default function Tools() {
- {userTools - .filter((tool) => - tool.displayName - .toLowerCase() - .includes(searchTerm.toLowerCase()), - ) - .map((tool, index) => ( -
-
-
- - + +
+
+

+ {tool.displayName} +

+

+ {tool.description} +

+
-
-

- {tool.displayName} -

-

- {tool.description} -

+
+
-
- -
-
- ))} + )) + )}