agent: improve knowledge naming (#2041)

This commit is contained in:
Nicolas Lorin
2025-02-06 21:19:22 +01:00
committed by Devin AI
parent 9e267ed23b
commit e1cbeed8fd

View File

@@ -1,3 +1,4 @@
import re
import shutil
import subprocess
from typing import Any, Dict, List, Literal, Optional, Union
@@ -153,7 +154,8 @@ class Agent(BaseAgent):
def _set_knowledge(self):
try:
if self.knowledge_sources:
knowledge_agent_name = f"{self.role.replace(' ', '_')}"
full_pattern = re.compile(r'[^a-zA-Z0-9\-_\r\n]|(\.\.)')
knowledge_agent_name = f"{re.sub(full_pattern, '_', self.role)}"
if isinstance(self.knowledge_sources, list) and all(
isinstance(k, BaseKnowledgeSource) for k in self.knowledge_sources
):