Compare commits

...

3 Commits

Author SHA1 Message Date
Devin AI
2c12b91083 fix: use isinstance for proper type narrowing in Knowledge.query
Co-Authored-By: Joe Moura <joao@crewai.com>
2024-12-27 20:55:45 +00:00
Devin AI
2d23ef7e12 fix: improve type narrowing in Knowledge.query with local variable
Co-Authored-By: Joe Moura <joao@crewai.com>
2024-12-27 20:54:14 +00:00
Devin AI
b56c4c52c0 fix: handle None storage in Knowledge.query for type checks
Co-Authored-By: Joe Moura <joao@crewai.com>
2024-12-27 20:51:50 +00:00

View File

@@ -49,9 +49,15 @@ class Knowledge(BaseModel):
"""
Query across all knowledge sources to find the most relevant information.
Returns the top_k most relevant chunks.
"""
results = self.storage.search(
Raises:
ValueError: If no storage is configured for querying.
"""
storage = self.storage
if not isinstance(storage, KnowledgeStorage):
raise ValueError("No storage found to perform query.")
# Using isinstance check for proper type narrowing
results = storage.search(
query,
limit,
)