fix: Respect custom trained data file during inference#4968
Open
goingforstudying-ctrl wants to merge 1 commit intocrewAIInc:mainfrom
Open
fix: Respect custom trained data file during inference#4968goingforstudying-ctrl wants to merge 1 commit intocrewAIInc:mainfrom
goingforstudying-ctrl wants to merge 1 commit intocrewAIInc:mainfrom
Conversation
413ebc3 to
3bc7c6f
Compare
When training a crew with a custom filename via `train -f <file>`, the crew now correctly loads from that same file during inference, instead of always loading from the hardcoded `trained_agents_data.pkl`. Changes: - Add _trained_data_file attribute to Crew class - Store custom filename during _setup_for_training() - Pass trained_data_file to _use_trained_data() method - Use custom file if provided, fall back to default otherwise Fixes crewAIInc#4905
3bc7c6f to
2b86b61
Compare
Author
|
Rebased with latest main. Ready for review! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When training a crew with a custom filename via
train -f <custom_file>.pkl, the crew now correctly loads from that same file during inference, instead of always loading from the hardcodedtrained_agents_data.pkl.Problem
The
_use_trained_data()method in Agent always loaded fromTRAINED_AGENTS_DATA_FILEconstant, ignoring any custom filename provided during training.Solution
_trained_data_fileattribute to Crew class to store the custom filename_setup_for_training()_use_trained_data()via the utility functiontrained_agents_data.pklwhen no custom file is specifiedChanges
src/crewai/crew.py: Add_trained_data_fileattribute and store filename during setupsrc/crewai/agent/core.py: Addtrained_data_fileparameter to_use_trained_data()src/crewai/agent/utils.py: Retrieve and passtrained_data_filefrom crewBackwards Compatibility
Fully backwards compatible. Existing code using default filename continues to work unchanged.
Fixes #4905