# Custom knowledge source not working for Crew and Agents

**URL:** <https://community.crewai.com/t/custom-knowledge-source-not-working-for-crew-and-agents/3980>\
**Category:** CrewAI Community Support\
**Tags:** agent, crewai\
**Created:** [February 19, 2025, 6:44am UTC](https://community.crewai.com/t/custom-knowledge-source-not-working-for-crew-and-agents/3980 "2025-02-19T06:44:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shrey113](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/shrey113/32/2661_2.png) [@shrey113](https://community.crewai.com/u/shrey113)\
**Post date:** [February 19, 2025, 6:44am UTC](https://community.crewai.com/t/custom-knowledge-source-not-working-for-crew-and-agents/3980/1 "2025-02-19T06:44:44Z")

</div>

I have been trying to specify custom text sources for my Agent as well as my Crew, which is failing.  
I am running Ollama locally, and using llama3.

Initially I tried to add a custom source to my agent like this:

```
text_source = TextFileKnowledgeSource(
    file_paths=["./source.txt"]
)
return Agent(
    config=self.agents_config['Source_updater'],
    verbose=True,
    llm = ollama_llm,
    tools=[GetAccessToken(), ....],
    knowledge_sources=[text_source],
    max_iter=5
)

```

But it was asking for an OpenAI api key… I checked the community chats and found that it defaults to OpenAI, and we have to provide embedder configuration for it. so I provided the same:

```
embedder={
"provider": "ollama",
"config": {
    "model": "nomic-embed-text",
}
},

```

but it still throws an error…

```
[2025-02-19 12:07:04][ERROR]: Failed to upsert documents: Expected Embedings to be non-empty list or numpy array, got [] in upsert.

```

 ![Screenshot 2025-02-19 at 12.08.22 PM](https://us1.discourse-cdn.com/flex025/uploads/crewai/original/2X/5/5f81f94841676fdeffc0f731e37fd1b819b58475.png)

So I tried adding the source to the Crew itself,

```
return Crew(
	agents=self.agents,
	tasks=self.tasks,
	process=Process.sequential,
	verbose=True,
	knowledge_sources=[text_source],	
	embedder={
		"provider": "ollama",
		"config": {
			"model": "nomic-embed-text",
		}
	},
)

```

Doing this, the crew doesn’t entirely crash, it runs, but doesn’t seem to take in the knowledge source:

```
python main.py
check:: True

[2025-02-19 12:10:56][ERROR]: Failed to upsert documents: Expected Embedings to be non-empty list or numpy array, got [] in upsert.

[2025-02-19 12:10:56][WARNING]: Failed to init knowledge: Expected Embedings to be non-empty list or numpy array, got [] in upsert.
# Agent: Source Agent

```

Anyone facing the same issues?  
Any help will be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![shrey113](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/shrey113/32/2661_2.png) [@shrey113](https://community.crewai.com/u/shrey113)\
**Post date:** [February 24, 2025, 6:27am UTC](https://community.crewai.com/t/custom-knowledge-source-not-working-for-crew-and-agents/3980/2 "2025-02-24T06:27:15Z")

</div>

It was a simple error.  
Apparently I had not pulled the embeddings from Ollama.  
Running the following command helped:

```
ollama pull nomic-embed-text

```

If you’re facing the same error, it’s probably the same issue. Just search for the embedding that you’re using (on ollama), and pull the embedding. It should get resolved!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex025/uploads/crewai/original/1X/ecda97e72f77c7100e0a761444b1c991925cc789.png) [@system](https://community.crewai.com/u/system)\
**Post date:** [February 25, 2025, 6:27am UTC](https://community.crewai.com/t/custom-knowledge-source-not-working-for-crew-and-agents/3980/3 "2025-02-25T06:27:34Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
