After adding "knowledge_sources" in agent, I get the error sqlite3.OperationalError: table embeddings already exists

If run it without adding knowledge_sources, it should work fine.

how to fix it?

First off, welcome!

Regarding the error you’re getting, it looks like there might be an issue with how you’re setting up your knowledge_sources. So, here’s what I suggest:

  • Check out the concepts and examples in the official docs.
  • Brush up on it with the “CrewAI Knowledge Tutorial for Beginners” video by Lorenze Jay (he’s part of the CrewAI dev team).
  • Finally, if you’re still running into trouble after that, go ahead and share the code snippet showing how you’re defining your knowledge_sources.

In addition to Max’s great advice. I found getting a really simple crew running first as a base is a good idea and then add complexity to it.
To that end this is a good video from CrewAI for setting up https://www.youtube.com/watch?v=-kSOTtYzgEw

Would love to hear how you are getting on

After watching this video, I ran it on my first setup and it worked fine. Then I ran ‘crewai run’ with just one additional pdf and got the error ‘sqlite3.OperationalError: no such module: fts5’,

After that, I ran ‘crewai run’ one more time without any action, and got the error ‘sqlite3.OperationalError: table embeddings already exists’.

I attach my code snippet.

I tried testing with StringKnowledgeSource, but got the same error.

When using KnowledgeSource, the embeddings table seems to be the problem in the part where sqlite3 uses the DB, but I don’t know how to fix it.

I’m using ubuntu 20.04, and I’m using python 3.11.12

Oh yes, python gives some really rubbish error messages that mean nothing… well not to me or cursor.

I look to use the following at the standard setup needs all “knowledge” Knowledge - CrewAI to be in this directory.
You are working with a potential python issue where it cannot find the file. I tend to play with the location of the file, so try ‘[full path]/knowledge/text/pdf’ etc. You can play with the Path() python as well.

As this is a rabbit hole. Well it was for me. I prefer to get “something working” and then modify.

Try using the String knowledge source as it mean you can remove the PDF location issues and see if there is another issue.

Create a knowledge source

from crewai.knowledge.source.string_knowledge_source import StringKnowledgeSource

content = “Users name is John. He is 30 years old and lives in San Francisco.”
string_source = StringKnowledgeSource(
content=content,
)

Hopefully this gets you further.

For CrewAI : Can we have the crewai check for things like this. Maybe a simple check or advice. The examples are good but vague enough to cause issues for non experts.

For me the issues are generally.

Agents and Tasks not matching Yaml files
File locations for knowledge sources
Tabbing on yaml files

Even better errors would be better as Cursor and chatgpt cannot figure them out.

Keep at it Mono… You are almost there… and the results are worth it!!

Using StringKnowledgeSource, the result is same :frowning:

“sqlite3.OperationalError: table embeddings already exists”

Below is snippet of using StringKnowledgeSource

ok then i recommend following the video as it is likely to be something about your setup. Do not worry, once you figure it out CrewAI is as solid as a rock