mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-08 23:58:34 +00:00
added knowledge to agent level (#1655)
* added knowledge to agent level * linted * added doc * added from suggestions * added test * fixes from discussion * fix docs * fix test * rm cassette for knowledge_sources test as its a mock and update agent doc string * fix test * rm unused * linted
This commit is contained in:
@@ -51,12 +51,41 @@ crew = Crew(
|
||||
tasks=[task],
|
||||
verbose=True,
|
||||
process=Process.sequential,
|
||||
knowledge={"sources": [string_source], "metadata": {"preference": "personal"}}, # Enable knowledge by adding the sources here. You can also add more sources to the sources list.
|
||||
knowledge_sources=[string_source], # Enable knowledge by adding the sources here.
|
||||
)
|
||||
|
||||
result = crew.kickoff(inputs={"question": "What city does John live in and how old is he?"})
|
||||
```
|
||||
|
||||
## Appending Knowledge Sources To Individual Agents
|
||||
Sometimes you may want to append knowledge sources to an individual agent. You can do this by setting the `knowledge` parameter in the `Agent` class.
|
||||
|
||||
```python
|
||||
agent = Agent(
|
||||
...
|
||||
knowledge_sources=[
|
||||
StringKnowledgeSource(
|
||||
content="Users name is John. He is 30 years old and lives in San Francisco.",
|
||||
metadata={"preference": "personal"},
|
||||
)
|
||||
],
|
||||
)
|
||||
```
|
||||
|
||||
## Agent Level Knowledge Sources
|
||||
|
||||
You can also append knowledge sources to an individual agent by setting the `knowledge_sources` parameter in the `Agent` class.
|
||||
|
||||
```python
|
||||
string_source = StringKnowledgeSource(
|
||||
content="Users name is John. He is 30 years old and lives in San Francisco.",
|
||||
metadata={"preference": "personal"},
|
||||
)
|
||||
agent = Agent(
|
||||
...
|
||||
knowledge_sources=[string_source],
|
||||
)
|
||||
```
|
||||
|
||||
## Embedder Configuration
|
||||
|
||||
@@ -70,10 +99,7 @@ string_source = StringKnowledgeSource(
|
||||
)
|
||||
crew = Crew(
|
||||
...
|
||||
knowledge={
|
||||
"sources": [string_source],
|
||||
"metadata": {"preference": "personal"},
|
||||
"embedder_config": {"provider": "openai", "config": {"model": "text-embedding-3-small"}},
|
||||
},
|
||||
knowledge_sources=[string_source],
|
||||
embedder_config={"provider": "ollama", "config": {"model": "nomic-embed-text:latest"}},
|
||||
)
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user