Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -76,9 +76,13 @@ class Answer(BaseModel):
|
|
| 76 |
|
| 77 |
class Tool(BaseModel):
|
| 78 |
"""Base class for all tools"""
|
| 79 |
-
name: str
|
| 80 |
-
description: str
|
| 81 |
-
type: ToolType
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
async def execute(self, input_data: Any) -> ToolResult:
|
| 84 |
raise NotImplementedError
|
|
@@ -127,22 +131,25 @@ class LocalSearch(Tool):
|
|
| 127 |
super().__init__(
|
| 128 |
name="local_search",
|
| 129 |
description="Searches local knowledge base",
|
| 130 |
-
type=ToolType.LOCAL_SEARCH
|
|
|
|
| 131 |
)
|
| 132 |
-
self.knowledge_base_path = knowledge_base_path
|
| 133 |
self._load_knowledge_base()
|
| 134 |
|
| 135 |
def _load_knowledge_base(self):
|
| 136 |
# Implement knowledge base loading logic
|
| 137 |
-
|
|
|
|
|
|
|
| 138 |
|
| 139 |
@lru_cache(maxsize=1000)
|
| 140 |
async def execute(self, query: str) -> ToolResult:
|
| 141 |
# Implement vector search logic
|
|
|
|
| 142 |
return ToolResult(
|
| 143 |
success=True,
|
| 144 |
-
result="Search result
|
| 145 |
-
metadata={"query": query}
|
| 146 |
)
|
| 147 |
|
| 148 |
class ImprovedAgent:
|
|
|
|
| 76 |
|
| 77 |
class Tool(BaseModel):
|
| 78 |
"""Base class for all tools"""
|
| 79 |
+
name: str = Field(..., description="Name of the tool")
|
| 80 |
+
description: str = Field(..., description="Description of what the tool does")
|
| 81 |
+
type: ToolType = Field(..., description="Type of tool")
|
| 82 |
+
|
| 83 |
+
class Config:
|
| 84 |
+
arbitrary_types_allowed = True # Allow Path and other complex types
|
| 85 |
+
extra = "allow" # Allow additional fields
|
| 86 |
|
| 87 |
async def execute(self, input_data: Any) -> ToolResult:
|
| 88 |
raise NotImplementedError
|
|
|
|
| 131 |
super().__init__(
|
| 132 |
name="local_search",
|
| 133 |
description="Searches local knowledge base",
|
| 134 |
+
type=ToolType.LOCAL_SEARCH,
|
| 135 |
+
knowledge_base_path=knowledge_base_path
|
| 136 |
)
|
|
|
|
| 137 |
self._load_knowledge_base()
|
| 138 |
|
| 139 |
def _load_knowledge_base(self):
|
| 140 |
# Implement knowledge base loading logic
|
| 141 |
+
# For now, just create the directory if it doesn't exist
|
| 142 |
+
if self.knowledge_base_path:
|
| 143 |
+
os.makedirs(self.knowledge_base_path, exist_ok=True)
|
| 144 |
|
| 145 |
@lru_cache(maxsize=1000)
|
| 146 |
async def execute(self, query: str) -> ToolResult:
|
| 147 |
# Implement vector search logic
|
| 148 |
+
# For now, return a placeholder result
|
| 149 |
return ToolResult(
|
| 150 |
success=True,
|
| 151 |
+
result=f"Search result for: {query}",
|
| 152 |
+
metadata={"query": query, "source": "local_knowledge_base"}
|
| 153 |
)
|
| 154 |
|
| 155 |
class ImprovedAgent:
|