diff --git a/application/api/user/routes.py b/application/api/user/routes.py index cb2e7b0a..bdc01d87 100644 --- a/application/api/user/routes.py +++ b/application/api/user/routes.py @@ -1222,6 +1222,10 @@ class CreateAgent(Resource): "lastUsedAt": None, "key": key, } + if new_agent["chunks"] == "": + new_agent["chunks"] = "0" + if new_agent["source"] == "" and new_agent["retriever"] == "": + new_agent["retriever"] = "classic" resp = agents_collection.insert_one(new_agent) new_id = str(resp.inserted_id) @@ -1334,6 +1338,33 @@ class UpdateAgent(Resource): ) else: update_fields[field] = "" + elif field == "chunks": + chunks_value = data.get("chunks") + if chunks_value == "": + update_fields[field] = "0" + else: + try: + if int(chunks_value) < 0: + return make_response( + jsonify( + { + "success": False, + "message": "Chunks value must be a positive integer", + } + ), + 400, + ) + update_fields[field] = chunks_value + except ValueError: + return make_response( + jsonify( + { + "success": False, + "message": "Invalid chunks value provided", + } + ), + 400, + ) else: update_fields[field] = data[field] diff --git a/frontend/src/agents/NewAgent.tsx b/frontend/src/agents/NewAgent.tsx index 475571cf..464b49fe 100644 --- a/frontend/src/agents/NewAgent.tsx +++ b/frontend/src/agents/NewAgent.tsx @@ -102,12 +102,7 @@ export default function NewAgent({ mode }: { mode: 'new' | 'edit' | 'draft' }) { const isPublishable = () => { return ( - agent.name && - agent.description && - (agent.source || agent.retriever) && - agent.chunks && - agent.prompt_id && - agent.agent_type + agent.name && agent.description && agent.prompt_id && agent.agent_type ); };