From b7a6bad7cdf2a807059b3929f49f9289c8842672 Mon Sep 17 00:00:00 2001 From: Siddhant Rai Date: Tue, 27 May 2025 13:50:13 +0530 Subject: [PATCH 1/9] fix: minor bugs and route errors --- application/api/user/routes.py | 5 ++++- application/requirements.txt | 4 ++-- frontend/src/App.tsx | 6 ++++-- frontend/src/agents/SharedAgentGate.tsx | 7 +++++++ 4 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 frontend/src/agents/SharedAgentGate.tsx diff --git a/application/api/user/routes.py b/application/api/user/routes.py index ae653c39..60277132 100644 --- a/application/api/user/routes.py +++ b/application/api/user/routes.py @@ -1500,7 +1500,10 @@ class PinnedAgents(Resource): "description": agent.get("description", ""), "source": ( str(db.dereference(agent["source"])["_id"]) - if "source" in agent and isinstance(agent["source"], DBRef) + if "source" in agent + and agent["source"] + and isinstance(agent["source"], DBRef) + and db.dereference(agent["source"]) is not None else "" ), "chunks": agent.get("chunks", ""), diff --git a/application/requirements.txt b/application/requirements.txt index 3891c852..3778d941 100644 --- a/application/requirements.txt +++ b/application/requirements.txt @@ -46,7 +46,7 @@ pandas==2.2.3 openpyxl==3.1.5 pathable==0.4.4 pillow==11.1.0 -portalocker==3.1.1 +portalocker>=2.7.0,<3.0.0 prance==23.6.21.0 prompt-toolkit==3.0.51 protobuf==5.29.3 @@ -62,7 +62,7 @@ python-dotenv==1.0.1 python-jose==3.4.0 python-pptx==1.0.2 redis==5.2.1 -referencing==0.36.2 +referencing>=0.28.0,<0.31.0 regex==2024.11.6 requests==2.32.3 retry==0.9.2 diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 1bba5f44..b3604c46 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -4,6 +4,9 @@ import { useState } from 'react'; import { Outlet, Route, Routes } from 'react-router-dom'; import About from './About'; +import Agents from './agents'; +import SharedAgentGate from './agents/SharedAgentGate'; +import ActionButtons from './components/ActionButtons'; import Spinner from './components/Spinner'; import Conversation from './conversation/Conversation'; import { SharedConversation } from './conversation/SharedConversation'; @@ -12,8 +15,6 @@ import useTokenAuth from './hooks/useTokenAuth'; import Navigation from './Navigation'; import PageNotFound from './PageNotFound'; import Setting from './settings'; -import Agents from './agents'; -import ActionButtons from './components/ActionButtons'; function AuthWrapper({ children }: { children: React.ReactNode }) { const { isAuthLoading } = useTokenAuth(); @@ -69,6 +70,7 @@ export default function App() { } /> } /> + } /> } /> diff --git a/frontend/src/agents/SharedAgentGate.tsx b/frontend/src/agents/SharedAgentGate.tsx new file mode 100644 index 00000000..877b6b1f --- /dev/null +++ b/frontend/src/agents/SharedAgentGate.tsx @@ -0,0 +1,7 @@ +import { Navigate, useParams } from 'react-router-dom'; + +export default function SharedAgentGate() { + const { agentId } = useParams(); + + return ; +} From ad1a944276b9e5118bc7257c5983d051cd0971af Mon Sep 17 00:00:00 2001 From: Siddhant Rai Date: Wed, 28 May 2025 13:58:55 +0530 Subject: [PATCH 2/9] refactor: agents sharing and shared with me logic --- application/api/user/routes.py | 157 +++++++++++++---------- frontend/src/agents/SharedAgent.tsx | 63 +-------- frontend/src/agents/SharedAgentCard.tsx | 64 +++++++++ frontend/src/agents/index.tsx | 5 +- frontend/src/api/endpoints.ts | 2 +- frontend/src/api/services/userService.ts | 4 +- 6 files changed, 158 insertions(+), 137 deletions(-) create mode 100644 frontend/src/agents/SharedAgentCard.tsx diff --git a/application/api/user/routes.py b/application/api/user/routes.py index 60277132..32d76fd7 100644 --- a/application/api/user/routes.py +++ b/application/api/user/routes.py @@ -15,6 +15,7 @@ from flask_restx import fields, inputs, Namespace, Resource from werkzeug.utils import secure_filename from application.agents.tools.tool_manager import ToolManager +from pymongo import ReturnDocument from application.api.user.tasks import ( ingest, @@ -50,6 +51,7 @@ agents_collection.create_index( name="shared_index", background=True, ) +users_collection.create_index("user_id", unique=True) user = Blueprint("user", __name__) user_ns = Namespace("user", description="User related operations", path="/") @@ -85,29 +87,29 @@ def generate_date_range(start_date, end_date): def ensure_user_doc(user_id): - user_doc = users_collection.find_one({"user_id": user_id}) + default_prefs = { + "pinned": [], + "shared_with_me": [], + } - if not user_doc: - user_doc = { - "user_id": user_id, - "agent_preferences": {"pinned": [], "hidden_shared": []}, - } - users_collection.insert_one(user_doc) - return user_doc - updated = False - preferences = user_doc.get("agent_preferences", {}) + user_doc = users_collection.find_one_and_update( + {"user_id": user_id}, + {"$setOnInsert": {"agent_preferences": default_prefs}}, + upsert=True, + return_document=ReturnDocument.AFTER, + ) + + prefs = user_doc.get("agent_preferences", {}) + updates = {} + if "pinned" not in prefs: + updates["agent_preferences.pinned"] = [] + if "shared_with_me" not in prefs: + updates["agent_preferences.shared_with_me"] = [] + + if updates: + users_collection.update_one({"user_id": user_id}, {"$set": updates}) + user_doc = users_collection.find_one({"user_id": user_id}) - if "pinned" not in preferences: - preferences["pinned"] = [] - updated = True - if "hidden_shared" not in preferences: - preferences["hidden_shared"] = [] - updated = True - if updated: - users_collection.update_one( - {"user_id": user_id}, {"$set": {"agent_preferences": preferences}} - ) - user_doc["agent_preferences"] = preferences return user_doc @@ -1464,26 +1466,25 @@ class PinnedAgents(Resource): decoded_token = request.decoded_token if not decoded_token: return make_response(jsonify({"success": False}), 401) + user_id = decoded_token.get("sub") try: user_doc = ensure_user_doc(user_id) pinned_ids = user_doc.get("agent_preferences", {}).get("pinned", []) - hidden_ids = set( - user_doc.get("agent_preferences", {}).get("hidden_shared", []) - ) if not pinned_ids: return make_response(jsonify([]), 200) + pinned_object_ids = [ObjectId(agent_id) for agent_id in pinned_ids] + pinned_agents_cursor = agents_collection.find( {"_id": {"$in": pinned_object_ids}} ) pinned_agents = list(pinned_agents_cursor) + existing_ids = {str(agent["_id"]) for agent in pinned_agents} - existing_agents = pinned_agents - existing_ids = {str(agent["_id"]) for agent in existing_agents} - + # Clean up any stale pinned IDs stale_ids = [ agent_id for agent_id in pinned_ids if agent_id not in existing_ids ] @@ -1523,12 +1524,13 @@ class PinnedAgents(Resource): "pinned": True, } for agent in pinned_agents - if ("source" in agent or "retriever" in agent) - and str(agent["_id"]) not in hidden_ids + if "source" in agent or "retriever" in agent ] + except Exception as err: current_app.logger.error(f"Error retrieving pinned agents: {err}") return make_response(jsonify({"success": False}), 400) + return make_response(jsonify(list_pinned_agents), 200) @@ -1575,11 +1577,11 @@ class PinAgent(Resource): return make_response(jsonify({"success": True, "action": action}), 200) -@user_ns.route("/api/hide_shared_agent") -class HideSharedAgent(Resource): +@user_ns.route("/api/remove_shared_agent") +class RemoveSharedAgent(Resource): @api.doc( params={"id": "ID of the shared agent"}, - description="Hide or unhide a shared agent for the current user", + description="Remove a shared agent from the current user's shared list", ) def delete(self): decoded_token = request.decoded_token @@ -1592,6 +1594,7 @@ class HideSharedAgent(Resource): return make_response( jsonify({"success": False, "message": "ID is required"}), 400 ) + try: agent = agents_collection.find_one( {"_id": ObjectId(agent_id), "shared_publicly": True} @@ -1601,27 +1604,25 @@ class HideSharedAgent(Resource): jsonify({"success": False, "message": "Shared agent not found"}), 404, ) - user_doc = ensure_user_doc(user_id) - hidden_list = user_doc.get("agent_preferences", {}).get("hidden_shared", []) - if agent_id in hidden_list: - users_collection.update_one( - {"user_id": user_id}, - {"$pull": {"agent_preferences.hidden_shared": agent_id}}, - ) - action = "unhidden" - else: - users_collection.update_one( - {"user_id": user_id}, - {"$addToSet": {"agent_preferences.hidden_shared": agent_id}}, - ) - action = "hidden" + ensure_user_doc(user_id) + users_collection.update_one( + {"user_id": user_id}, + { + "$pull": { + "agent_preferences.shared_with_me": agent_id, + "agent_preferences.pinned": agent_id, + } + }, + ) + + return make_response(jsonify({"success": True, "action": "removed"}), 200) + except Exception as err: - current_app.logger.error(f"Error hiding/unhiding shared agent: {err}") + current_app.logger.error(f"Error removing shared agent: {err}") return make_response( jsonify({"success": False, "message": "Server error"}), 500 ) - return make_response(jsonify({"success": True, "action": action}), 200) @user_ns.route("/api/shared_agent") @@ -1639,19 +1640,22 @@ class SharedAgent(Resource): return make_response( jsonify({"success": False, "message": "Token or ID is required"}), 400 ) - try: - query = {} - query["shared_publicly"] = True - query["shared_token"] = shared_token + try: + query = { + "shared_publicly": True, + "shared_token": shared_token, + } shared_agent = agents_collection.find_one(query) if not shared_agent: return make_response( jsonify({"success": False, "message": "Shared agent not found"}), 404, ) + + agent_id = str(shared_agent["_id"]) data = { - "id": str(shared_agent["_id"]), + "id": agent_id, "user": shared_agent.get("user", ""), "name": shared_agent.get("name", ""), "description": shared_agent.get("description", ""), @@ -1672,15 +1676,29 @@ class SharedAgent(Resource): if tool_data: enriched_tools.append(tool_data.get("name", "")) data["tools"] = enriched_tools + + decoded_token = getattr(request, "decoded_token", None) + if decoded_token: + user_id = decoded_token.get("sub") + owner_id = shared_agent.get("user") + + if user_id != owner_id: + ensure_user_doc(user_id) + users_collection.update_one( + {"user_id": user_id}, + {"$addToSet": {"agent_preferences.shared_with_me": agent_id}}, + ) + + return make_response(jsonify(data), 200) + except Exception as err: current_app.logger.error(f"Error retrieving shared agent: {err}") return make_response(jsonify({"success": False}), 400) - return make_response(jsonify(data), 200) @user_ns.route("/api/shared_agents") class SharedAgents(Resource): - @api.doc(description="Get shared agents") + @api.doc(description="Get shared agents explicitly shared with the user") def get(self): try: decoded_token = request.decoded_token @@ -1689,29 +1707,25 @@ class SharedAgents(Resource): user_id = decoded_token.get("sub") user_doc = ensure_user_doc(user_id) - pinned_ids = set(user_doc.get("agent_preferences", {}).get("pinned", [])) - hidden_ids = user_doc.get("agent_preferences", {}).get("hidden_shared", []) - hidden_object_ids = [ObjectId(id) for id in hidden_ids] + shared_with_ids = user_doc.get("agent_preferences", {}).get( + "shared_with_me", [] + ) + shared_object_ids = [ObjectId(id) for id in shared_with_ids] shared_agents_cursor = agents_collection.find( - {"shared_publicly": True, "user": {"$ne": user_id}} + {"_id": {"$in": shared_object_ids}, "shared_publicly": True} ) shared_agents = list(shared_agents_cursor) - shared_ids_set = {agent["_id"] for agent in shared_agents} - hidden_ids_set = set(hidden_object_ids) - - stale_hidden_ids = [ - str(id) for id in hidden_ids_set if id not in shared_ids_set - ] - if stale_hidden_ids: + found_ids_set = {str(agent["_id"]) for agent in shared_agents} + stale_ids = [id for id in shared_with_ids if id not in found_ids_set] + if stale_ids: users_collection.update_one( {"user_id": user_id}, - {"$pullAll": {"agent_preferences.hidden_shared": stale_hidden_ids}}, + {"$pullAll": {"agent_preferences.shared_with_me": stale_ids}}, ) - visible_shared_agents = [ - agent for agent in shared_agents if agent["_id"] not in hidden_ids_set - ] + + pinned_ids = set(user_doc.get("agent_preferences", {}).get("pinned", [])) list_shared_agents = [ { @@ -1728,10 +1742,11 @@ class SharedAgents(Resource): "shared_token": agent.get("shared_token", ""), "shared_metadata": agent.get("shared_metadata", {}), } - for agent in visible_shared_agents + for agent in shared_agents ] return make_response(jsonify(list_shared_agents), 200) + except Exception as err: current_app.logger.error(f"Error retrieving shared agents: {err}") return make_response(jsonify({"success": False}), 400) diff --git a/frontend/src/agents/SharedAgent.tsx b/frontend/src/agents/SharedAgent.tsx index 8c7e76c9..d1d2d370 100644 --- a/frontend/src/agents/SharedAgent.tsx +++ b/frontend/src/agents/SharedAgent.tsx @@ -21,6 +21,7 @@ import { import { useDarkTheme } from '../hooks'; import { selectToken, setSelectedAgent } from '../preferences/preferenceSlice'; import { AppDispatch } from '../store'; +import SharedAgentCard from './SharedAgentCard'; import { Agent } from './types'; export default function SharedAgent() { @@ -193,65 +194,3 @@ export default function SharedAgent() { ); } - -function SharedAgentCard({ agent }: { agent: Agent }) { - return ( -
-
-
- -
-
-

- {agent.name} -

-

- {agent.description} -

-
-
-
- {agent.shared_metadata?.shared_by && ( -

- by {agent.shared_metadata.shared_by} -

- )} - {agent.shared_metadata?.shared_at && ( -

- Shared on{' '} - {new Date(agent.shared_metadata.shared_at).toLocaleString('en-US', { - month: 'long', - day: 'numeric', - year: 'numeric', - hour: '2-digit', - minute: '2-digit', - hour12: true, - })} -

- )} -
- {agent.tools.length > 0 && ( -
-

- Connected Tools -

-
- {agent.tools.map((tool, index) => ( - - {`${tool}{' '} - {tool} - - ))} -
-
- )} -
- ); -} diff --git a/frontend/src/agents/SharedAgentCard.tsx b/frontend/src/agents/SharedAgentCard.tsx new file mode 100644 index 00000000..9c8160e5 --- /dev/null +++ b/frontend/src/agents/SharedAgentCard.tsx @@ -0,0 +1,64 @@ +import Robot from '../assets/robot.svg'; +import { Agent } from './types'; + +export default function SharedAgentCard({ agent }: { agent: Agent }) { + return ( +
+
+
+ +
+
+

+ {agent.name} +

+

+ {agent.description} +

+
+
+
+ {agent.shared_metadata?.shared_by && ( +

+ by {agent.shared_metadata.shared_by} +

+ )} + {agent.shared_metadata?.shared_at && ( +

+ Shared on{' '} + {new Date(agent.shared_metadata.shared_at).toLocaleString('en-US', { + month: 'long', + day: 'numeric', + year: 'numeric', + hour: '2-digit', + minute: '2-digit', + hour12: true, + })} +

+ )} +
+ {agent.tools.length > 0 && ( +
+

+ Connected Tools +

+
+ {agent.tools.map((tool, index) => ( + + {`${tool}{' '} + {tool} + + ))} +
+
+ )} +
+ ); +} diff --git a/frontend/src/agents/index.tsx b/frontend/src/agents/index.tsx index 2f8bf484..8fe1afc9 100644 --- a/frontend/src/agents/index.tsx +++ b/frontend/src/agents/index.tsx @@ -286,7 +286,10 @@ function AgentCard({ const handleHideSharedAgent = async () => { try { - const response = await userService.hideSharedAgent(agent.id ?? '', token); + const response = await userService.removeSharedAgent( + agent.id ?? '', + token, + ); if (!response.ok) throw new Error('Failed to hide shared agent'); const updatedAgents = agents.filter( (prevAgent) => prevAgent.id !== agent.id, diff --git a/frontend/src/api/endpoints.ts b/frontend/src/api/endpoints.ts index 72db0595..bb98f02a 100644 --- a/frontend/src/api/endpoints.ts +++ b/frontend/src/api/endpoints.ts @@ -18,7 +18,7 @@ const endpoints = { SHARED_AGENT: (id: string) => `/api/shared_agent?token=${id}`, SHARED_AGENTS: '/api/shared_agents', SHARE_AGENT: `/api/share_agent`, - HIDE_SHARED_AGENT: (id: string) => `/api/hide_shared_agent?id=${id}`, + REMOVE_SHARED_AGENT: (id: string) => `/api/remove_shared_agent?id=${id}`, AGENT_WEBHOOK: (id: string) => `/api/agent_webhook?id=${id}`, PROMPTS: '/api/get_prompts', CREATE_PROMPT: '/api/create_prompt', diff --git a/frontend/src/api/services/userService.ts b/frontend/src/api/services/userService.ts index 9dd679a5..564c3b97 100644 --- a/frontend/src/api/services/userService.ts +++ b/frontend/src/api/services/userService.ts @@ -41,8 +41,8 @@ const userService = { apiClient.get(endpoints.USER.SHARED_AGENTS, token), shareAgent: (data: any, token: string | null): Promise => apiClient.put(endpoints.USER.SHARE_AGENT, data, token), - hideSharedAgent: (id: string, token: string | null): Promise => - apiClient.delete(endpoints.USER.HIDE_SHARED_AGENT(id), token), + removeSharedAgent: (id: string, token: string | null): Promise => + apiClient.delete(endpoints.USER.REMOVE_SHARED_AGENT(id), token), getAgentWebhook: (id: string, token: string | null): Promise => apiClient.get(endpoints.USER.AGENT_WEBHOOK(id), token), getPrompts: (token: string | null): Promise => From 8cd41956571c96e483fd5c8738e391d3fd0abfb4 Mon Sep 17 00:00:00 2001 From: Siddhant Rai Date: Wed, 28 May 2025 14:25:37 +0530 Subject: [PATCH 3/9] feat: add SharedAgentCard to display selected agent in Conversation component --- frontend/src/conversation/Conversation.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frontend/src/conversation/Conversation.tsx b/frontend/src/conversation/Conversation.tsx index 753a3725..4f34c26c 100644 --- a/frontend/src/conversation/Conversation.tsx +++ b/frontend/src/conversation/Conversation.tsx @@ -3,6 +3,7 @@ import { useDropzone } from 'react-dropzone'; import { useTranslation } from 'react-i18next'; import { useDispatch, useSelector } from 'react-redux'; +import SharedAgentCard from '../agents/SharedAgentCard'; import DragFileUpload from '../assets/DragFileUpload.svg'; import MessageInput from '../components/MessageInput'; import { useMediaQuery } from '../hooks'; @@ -193,6 +194,14 @@ export default function Conversation() { handleFeedback={handleFeedback} queries={queries} status={status} + showHeroOnEmpty={selectedAgent ? false : true} + headerContent={ + selectedAgent ? ( +
+ +
+ ) : undefined + } />
From 3b8733e0855be59f3a17e1659856954a5ba44b7a Mon Sep 17 00:00:00 2001 From: Siddhant Rai Date: Thu, 29 May 2025 10:58:49 +0530 Subject: [PATCH 4/9] feat: add tool details resolution and update SharedAgentCard to display tool names --- application/api/user/routes.py | 19 +++++++++++++++++++ frontend/src/agents/SharedAgentCard.tsx | 10 +++++----- frontend/src/agents/types/index.ts | 7 +++++++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/application/api/user/routes.py b/application/api/user/routes.py index 32d76fd7..5c9975fb 100644 --- a/application/api/user/routes.py +++ b/application/api/user/routes.py @@ -113,6 +113,20 @@ def ensure_user_doc(user_id): return user_doc +def resolve_tool_details(tool_ids): + tools = user_tools_collection.find( + {"_id": {"$in": [ObjectId(tid) for tid in tool_ids]}} + ) + return [ + { + "id": str(tool["_id"]), + "name": tool.get("name", ""), + "display_name": tool.get("displayName", tool.get("name", "")), + } + for tool in tools + ] + + def get_vector_store(source_id): """ Get the Vector Store @@ -1059,6 +1073,7 @@ class GetAgent(Resource): "retriever": agent.get("retriever", ""), "prompt_id": agent.get("prompt_id", ""), "tools": agent.get("tools", []), + "tool_details": resolve_tool_details(agent.get("tools", [])), "agent_type": agent.get("agent_type", ""), "status": agent.get("status", ""), "created_at": agent.get("createdAt", ""), @@ -1108,6 +1123,7 @@ class GetAgents(Resource): "retriever": agent.get("retriever", ""), "prompt_id": agent.get("prompt_id", ""), "tools": agent.get("tools", []), + "tool_details": resolve_tool_details(agent.get("tools", [])), "agent_type": agent.get("agent_type", ""), "status": agent.get("status", ""), "created_at": agent.get("createdAt", ""), @@ -1511,6 +1527,7 @@ class PinnedAgents(Resource): "retriever": agent.get("retriever", ""), "prompt_id": agent.get("prompt_id", ""), "tools": agent.get("tools", []), + "tool_details": resolve_tool_details(agent.get("tools", [])), "agent_type": agent.get("agent_type", ""), "status": agent.get("status", ""), "created_at": agent.get("createdAt", ""), @@ -1660,6 +1677,7 @@ class SharedAgent(Resource): "name": shared_agent.get("name", ""), "description": shared_agent.get("description", ""), "tools": shared_agent.get("tools", []), + "tool_details": resolve_tool_details(shared_agent.get("tools", [])), "agent_type": shared_agent.get("agent_type", ""), "status": shared_agent.get("status", ""), "created_at": shared_agent.get("createdAt", ""), @@ -1733,6 +1751,7 @@ class SharedAgents(Resource): "name": agent.get("name", ""), "description": agent.get("description", ""), "tools": agent.get("tools", []), + "tool_details": resolve_tool_details(agent.get("tools", [])), "agent_type": agent.get("agent_type", ""), "status": agent.get("status", ""), "created_at": agent.get("createdAt", ""), diff --git a/frontend/src/agents/SharedAgentCard.tsx b/frontend/src/agents/SharedAgentCard.tsx index 9c8160e5..6c778ba4 100644 --- a/frontend/src/agents/SharedAgentCard.tsx +++ b/frontend/src/agents/SharedAgentCard.tsx @@ -37,23 +37,23 @@ export default function SharedAgentCard({ agent }: { agent: Agent }) {

)}
- {agent.tools.length > 0 && ( + {agent.tool_details && agent.tool_details.length > 0 && (

Connected Tools

- {agent.tools.map((tool, index) => ( + {agent.tool_details.map((tool, index) => ( {`${tool}{' '} - {tool} + {tool.name} ))}
diff --git a/frontend/src/agents/types/index.ts b/frontend/src/agents/types/index.ts index fe3cb418..4a1af145 100644 --- a/frontend/src/agents/types/index.ts +++ b/frontend/src/agents/types/index.ts @@ -1,3 +1,9 @@ +export type ToolSummary = { + id: string; + name: string; + display_name: string; +}; + export type Agent = { id?: string; name: string; @@ -8,6 +14,7 @@ export type Agent = { retriever: string; prompt_id: string; tools: string[]; + tool_details?: ToolSummary[]; agent_type: string; status: string; key?: string; From c4e471ac478bfd46e63486c3d2da2d78db1ed9b6 Mon Sep 17 00:00:00 2001 From: Siddhant Rai Date: Thu, 29 May 2025 11:16:38 +0530 Subject: [PATCH 5/9] fix: ensure shared metadata is displayed only when available in SharedAgentCard --- frontend/src/agents/SharedAgentCard.tsx | 45 ++++++++++++++----------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/frontend/src/agents/SharedAgentCard.tsx b/frontend/src/agents/SharedAgentCard.tsx index 6c778ba4..bf542ca9 100644 --- a/frontend/src/agents/SharedAgentCard.tsx +++ b/frontend/src/agents/SharedAgentCard.tsx @@ -17,26 +17,31 @@ export default function SharedAgentCard({ agent }: { agent: Agent }) {

-
- {agent.shared_metadata?.shared_by && ( -

- by {agent.shared_metadata.shared_by} -

- )} - {agent.shared_metadata?.shared_at && ( -

- Shared on{' '} - {new Date(agent.shared_metadata.shared_at).toLocaleString('en-US', { - month: 'long', - day: 'numeric', - year: 'numeric', - hour: '2-digit', - minute: '2-digit', - hour12: true, - })} -

- )} -
+ {agent.shared_metadata && ( +
+ {agent.shared_metadata?.shared_by && ( +

+ by {agent.shared_metadata.shared_by} +

+ )} + {agent.shared_metadata?.shared_at && ( +

+ Shared on{' '} + {new Date(agent.shared_metadata.shared_at).toLocaleString( + 'en-US', + { + month: 'long', + day: 'numeric', + year: 'numeric', + hour: '2-digit', + minute: '2-digit', + hour12: true, + }, + )} +

+ )} +
+ )} {agent.tool_details && agent.tool_details.length > 0 && (

From a393ad8e04127998b9acfa8c7346ba93c4b9126e Mon Sep 17 00:00:00 2001 From: Siddhant Rai Date: Fri, 30 May 2025 12:50:11 +0530 Subject: [PATCH 6/9] refactor: standardize string quotes and improve retriever type handling in RetrieverCreator --- application/retriever/retriever_creator.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/application/retriever/retriever_creator.py b/application/retriever/retriever_creator.py index 07be373d..26cb41ca 100644 --- a/application/retriever/retriever_creator.py +++ b/application/retriever/retriever_creator.py @@ -3,18 +3,18 @@ from application.retriever.duckduck_search import DuckDuckSearch from application.retriever.brave_search import BraveRetSearch - class RetrieverCreator: retrievers = { - 'classic': ClassicRAG, - 'duckduck_search': DuckDuckSearch, - 'brave_search': BraveRetSearch, - 'default': ClassicRAG + "classic": ClassicRAG, + "duckduck_search": DuckDuckSearch, + "brave_search": BraveRetSearch, + "default": ClassicRAG, } @classmethod def create_retriever(cls, type, *args, **kwargs): - retiever_class = cls.retrievers.get(type.lower()) + retriever_type = (type or "default").lower() + retiever_class = cls.retrievers.get(retriever_type) if not retiever_class: raise ValueError(f"No retievers class found for type {type}") - return retiever_class(*args, **kwargs) \ No newline at end of file + return retiever_class(*args, **kwargs) From 773788fb32ca3abb8b4713fa4da10fb326bfcdd2 Mon Sep 17 00:00:00 2001 From: Siddhant Rai Date: Fri, 30 May 2025 14:30:51 +0530 Subject: [PATCH 7/9] fix: correct vectorstore path and improve file existence checks in FaissStore --- application/vectorstore/faiss.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/application/vectorstore/faiss.py b/application/vectorstore/faiss.py index ce455bd8..541ec17e 100644 --- a/application/vectorstore/faiss.py +++ b/application/vectorstore/faiss.py @@ -11,9 +11,9 @@ from application.storage.storage_creator import StorageCreator def get_vectorstore(path: str) -> str: if path: - vectorstore = f"indexes/{path}" + vectorstore = f"application/indexes/{path}" else: - vectorstore = "indexes" + vectorstore = "application/indexes" return vectorstore @@ -32,22 +32,26 @@ class FaissStore(BaseVectorStore): with tempfile.TemporaryDirectory() as temp_dir: faiss_path = f"{self.path}/index.faiss" pkl_path = f"{self.path}/index.pkl" - - if not self.storage.file_exists(faiss_path) or not self.storage.file_exists(pkl_path): - raise FileNotFoundError(f"Index files not found in storage at {self.path}") - + + if not self.storage.file_exists( + faiss_path + ) or not self.storage.file_exists(pkl_path): + raise FileNotFoundError( + f"Index files not found in storage at {self.path}" + ) + faiss_file = self.storage.get_file(faiss_path) pkl_file = self.storage.get_file(pkl_path) - + local_faiss_path = os.path.join(temp_dir, "index.faiss") local_pkl_path = os.path.join(temp_dir, "index.pkl") - - with open(local_faiss_path, 'wb') as f: + + with open(local_faiss_path, "wb") as f: f.write(faiss_file.read()) - - with open(local_pkl_path, 'wb') as f: + + with open(local_pkl_path, "wb") as f: f.write(pkl_file.read()) - + self.docsearch = FAISS.load_local( temp_dir, self.embeddings, allow_dangerous_deserialization=True ) From 381d737d2442c4cbc339da029999c5735f87ee5f Mon Sep 17 00:00:00 2001 From: Siddhant Rai Date: Tue, 3 Jun 2025 15:14:00 +0530 Subject: [PATCH 8/9] fix: correct vectorstore path in get_vectorstore function --- application/vectorstore/faiss.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/vectorstore/faiss.py b/application/vectorstore/faiss.py index 541ec17e..2c1fcb93 100644 --- a/application/vectorstore/faiss.py +++ b/application/vectorstore/faiss.py @@ -11,9 +11,9 @@ from application.storage.storage_creator import StorageCreator def get_vectorstore(path: str) -> str: if path: - vectorstore = f"application/indexes/{path}" + vectorstore = f"indexes/{path}" else: - vectorstore = "application/indexes" + vectorstore = "indexes" return vectorstore From c0f693d35db91da07671fa8db698f0a0423b8a8e Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 3 Jun 2025 15:40:16 +0100 Subject: [PATCH 9/9] remove abount --- frontend/src/App.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 93e41c17..9c5de77f 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -3,7 +3,6 @@ import './locale/i18n'; import { useState } from 'react'; import { Outlet, Route, Routes } from 'react-router-dom'; -import About from './About'; import Agents from './agents'; import SharedAgentGate from './agents/SharedAgentGate'; import ActionButtons from './components/ActionButtons';