updates to add more docs and correct imports with huggingface embedding server enabled

This commit is contained in:
Lorenze Jay
2024-10-22 12:27:47 -07:00
parent 5803b3fb69
commit e2f70cb53f
2 changed files with 29 additions and 4 deletions

View File

@@ -164,7 +164,8 @@ my_crew = Crew(
embedder={
"provider": "google",
"config": {
api_key="YOUR_API_KEY"
"api_key": "<YOUR_API_KEY>",
"model_name": "<model_name>"
}
}
)
@@ -231,6 +232,25 @@ my_crew = Crew(
}
)
```
### Using HuggingFace embeddings
```python Code
from crewai import Crew, Agent, Task, Process
my_crew = Crew(
agents=[...],
tasks=[...],
process=Process.sequential,
memory=True,
verbose=True,
embedder={
"provider": "huggingface",
"config": {
"api_url": "<api_url>",
}
}
)
```
### Resetting Memory

View File

@@ -109,21 +109,26 @@ class RAGStorage(BaseRAGStorage):
model_name=model_name,
api_key=config.get("api_key"),
)
elif provider == "huggingface":
self.embedder_config = embedding_functions.HuggingFaceEmbeddingServer(
url=config.get("api_url"),
)
else:
raise Exception(
f"Unsupported embedding provider: {provider}"
) # TODO: here are the supported providers: [openai, ...]
f"Unsupported embedding provider: {provider}, supported providers: [openai, azure, ollama, vertexai, google, cohere, huggingface]"
)
else:
validate_embedding_function(self.embedder_config) # type: ignore # used for validating embedder_config if defined a embedding function/class
self.embedder_config = self.embedder_config
def _initialize_app(self):
import chromadb
from chromadb.config import Settings
self._set_embedder_config()
chroma_client = chromadb.PersistentClient(
path=f"{db_storage_path()}/{self.type}/{self.agents}",
settings=chromadb.Settings(allow_reset=self.allow_reset),
settings=Settings(allow_reset=self.allow_reset),
)
self.app = chroma_client