improvements

This commit is contained in:
Lorenze Jay
2024-11-19 11:27:01 -08:00
parent efa8a378a1
commit de742c827d
3 changed files with 7 additions and 7 deletions

View File

@@ -30,7 +30,7 @@ class Knowledge(BaseModel):
Logger(verbose=True).log(
"warning",
f"Failed to init knowledge: {e}",
color="red",
color="yellow",
)
def query(

View File

@@ -1,11 +1,10 @@
from abc import ABC, abstractmethod
from typing import List
from typing import List, Dict, Any
import numpy as np
from pydantic import BaseModel, ConfigDict, Field
from crewai.knowledge.storage.knowledge_storage import KnowledgeStorage
from typing import Dict, Any
class BaseKnowledgeSource(BaseModel, ABC):

View File

@@ -1,4 +1,5 @@
from typing import List
from typing import Dict, List
from pathlib import Path
from crewai.knowledge.source.base_file_knowledge_source import BaseFileKnowledgeSource
@@ -6,11 +7,11 @@ from crewai.knowledge.source.base_file_knowledge_source import BaseFileKnowledge
class TextFileKnowledgeSource(BaseFileKnowledgeSource):
"""A knowledge source that stores and queries text file content using embeddings."""
def load_content(self) -> str:
def load_content(self) -> Dict[Path, str]:
"""Load and preprocess text file content."""
super().load_content() # Validate the file path
super().load_content()
with self.file_path.open("r", encoding="utf-8") as f:
return f.read()
return f.read() # type: ignore
def add(self) -> None:
"""