Icon

CrewAI - AI-Agents scan your document and solve your Task using Ollama

KNIME and CrewAI - use an AI-Agent system to use a local file like (PDF, CSV, TXT, JSON ...) and let a local LLM like Llama3 solve your tasks

KNIME and CrewAI - use an AI-Agent system to use a local file like (PDF, CSV, TXT, JSON ...) and let a local LLM like Llama3 solve your tasks

The agents will 'discuss' among themselvesm use the documents provided and come back with a (hopefully) perfect soltion to your task based on the instructions you gave

---
Adapted from:

Integrating Agent Frameworks into Low Code Tools: Making CrewAI work in KNIME
https://medium.com/p/a7fecb042915
https://hub.knime.com/lowcodeaiftw/spaces/Public/LLMs/CrewAI~lgdow45tWuhhb4fT/

by https://medium.com/@martindausa


Annotations and comments
  • Maybe download the whole LLM workflow group in order to get all the folders and documents (https://hub.knime.com/mlauber71/spaces/LLM_Space/~17k4zAECNryrZw1X/)
  • work in progress
  • Prerequisites: Ideally, the KNIME 4.7 (or higher) Version Installed including Python Integration Extension. Custom Python Environment set up including key KNIME Packages and CrewAI package as well as Ollama (also pull the LLM models you want to use). cf. "py_knime_crewai.yml" in the /data/ folder Define Agents: Agent Name Agent Goal Agent Backstory Agent Model (currently Llama3 and Mistral, vou can add more) Define Tasks with Documents: Task Name Task Description Assign Agent to perform the Task The Parameter with the document path is preassigned (Do not change) Flexibility to inject certain parameters into the task (ParameterName: ParameterValue) Further Hints: Using an agent system seem attractive but will provide you with an additional set of challenges (especially when wrapping it in KNIME nodes to meke it easier to access). Currently we try to get back a JSON file that should either stand alone of be enclosed in backticks (```) that you might have to process further. One option would b eto further explore the "expected_output" setting (currently empty) in order to get the system to give back a -well- defined output.
  • Adapted from: Integrating Agent Frameworks into Low Code Tools: Making CrewAI work in KNIME https://medium.com/p/a7fecb042915 by https://medium.com/@martindausa
  • Make sure you have the Ollama models pulled locally and they are running ollama pull mxbai-embed-large ollama pull mistral:instruct ollama pull llama3:instruct ollama pull llama3.1 ollama run mistral:instruct ollama run llama3:instruct ollama run llama3.1
  • Define Agents and their models
  • Concatenate Agent and Task Outputs Note: Add new Agents / Tasks by copying respective components. Make sure to add additional input ports to Concat nodes and connect new Agents/tasks accordingly
  • Kickoff your Agents - you can check the progress and the results in the log folder ../data/chat/ollama_crewai_rag_<...>
  • Define the Tasks - in this case we have tasks that would have a document as a parameter. And although we also provide the document in the code it seems the agents also do want to have the document within the task itself. {path_to_document}
  • A Task without access to documents
  • RowID
  • agentsMaxIter
  • agentsAllowCooperation
  • context.workflow.parent-path
  • path.separator.system length_parent_path= length(column("context.workflow.parent-path")) substr(column("context.workflow.parent-path"), length_parent_path-1, 1)
  • => paths
  • create /data/ folder if it does not exist
  • context.workflow.absolute-path context.workflow.path context.workflow.name
  • context.workflow.data-path
  • data-path
  • path variables
  • path_to_document
  • path_to_document convert to string
  • list_files keep as List
  • collect Agents
  • Task Details
  • TaskParameterDetails
  • current time
  • agentModel
  • AgentName
  • AgentGoal
  • AgentBackStory
  • parameterValue {path_to_document}
  • parameterName
  • parameterValue Bankstatement_Information
  • taskName
  • taskDescription
  • explain the use of
  • selectedAgent
  • parameterValue
  • File Path
  • list_files => if you want just one file
  • var_document_folder bank_01 => try to avoid special characers and blanks in paths and file names
  • File Path escaped
  • scan for PDF-Files
  • URI
  • CrewAI using local Ollama / Llama3 / Mistral
  • !!! only one document currently
  • var_document_folder
  • list_files
  • olama_crewai_
  • TaskDetails
  • if (equals(column("os.name"), "Mac OS X") ) {"0"} else if (contains(lowerCase(column("os.name")),"mac" )) {"0"} else {"1"}
  • conda.environment java.home
  • conda.environment "py_knime_crewai" Windows
  • conda.environment "py_knime_crewai" MacOSX Apple Scilicon
  • osgi.syspath => find where the KNIME installtion is located on Windows or MacOSX also java.home
  • $$ROWID$$ = "java.home" => TRUE
  • var_environment_validation
  • java.home
  • stamp_day_txt
  • stamp_time_txt
  • var_file_name ../data/chat/
  • var_file_name_html
  • var_file_name_pdf
  • var_file_name_part return "ollama_crewai_rag_result"; return "ollama_crewai_rag_" + $${Sstamp_day_txt}$$ + "_" + $${Sstamp_time_txt}$$;
  • var_folder_log
  • stamp_time
  • stamp_day
  • stamp_*

Nodes

Extensions

Links