Closed mdkberry closed 6 months ago
Sharing my findings. It seems the AI (I was using ollama local with mistal 7b adjusted with the recommended modelfile) was choosing to look for the wrong function randomly adding backslashes to the _ so I changed the function name to "fetchpdfcontent" and that helped but it would go off doing other things instead after that. After I constained it further (see below) it behaved itself. This explains why I could not see the problem in step-through debugging the code because the code wasnt the problem, the lack of constraint for the AI was.
I have since had it start doing other things like deciding to sit and think instead of continue on with the process, but it informed me of this in the action info on screen, so I was able to spot it.
Here is my current change but it will need further additions before it works every time, no doubt. Changing the goal and backstory for the pdf_reader Agent to try to constrain it further.
role='PDF Content Extractor',
goal="""Extract text from a PDF. Important: Only perform the action you have been asked to perform. Once you've found the information, immediately stop searching for additional information.""",
backstory="""As a PDF Content Extractor you specialize in handling text extracted from PDF documents.""",
I cant figure out the cause and it is intermittent. It works one in ten times maybe.
I am in a conda environment using VSCode with python 3.10.14 I am using the code shown here with very little changed - https://medium.com/@foadmk/optimizing-everyday-tasks-with-crewai-fc655ca08944
The error I get during a run, shows the defined Action call "fetch_pdf_content" being used incorrectly with backslashes getting added, but like I said it is intermittent. Some runs it will do it, some it wont, but mostly it does this.
The error message:
The code for the agent:
The code for the fetch_pdf_content, but it doesnt get that far when it decides to include "backslashes"
I have run debugs and cant catch where it is happening, as far as I can see it is passing it correctly from debug info. If anyone has some idea of what is going on here I would appreciate hearing it. As far as I can tell it is with the Agents at some level. (I am using local LLM mistral with Ollama, if that makes a difference but I have used this with a number of other projects and not had this problem).