Repository navigation
Conversation
…rser mixing - Replace problematic instance variable assignment with dynamic parser selection - Fix issue where self.response_parser persisted across calls causing mode confusion - Add type-specific logic to distinguish Response, AsyncIterable, and Iterable objects - Exclude basic types (str, bytes, dict) from streaming detection - Ensure correct parser is always selected based on completion type Resolves: OpenAI client getting 'stuck' in streaming or non-streaming mode after switching between stream=True and stream=False calls.
… optimization instructions - Separate optimization context from target content in TEXT_GRAD_DESC_TEMPLATE - Replace problematic mixed instructions with structured sections - Add OPTIMIZATION_CONTEXT section for meta-instructions about iteration strategy - Add TARGET_CONTENT_TO_OPTIMIZE section to isolate content to be optimized - Add CRITICAL_INSTRUCTION section with explicit contamination prevention - Use clear XML-like boundaries to prevent context bleeding between sections - Maintain full backward compatibility with existing template variables Resolves: TGDOptimizer contaminating prompts with phrases like 'when steps exceed 3' that don't belong in optimized content, making the optimizer unsuitable for production.
…al errors
- Remove ValueError when data_id is None in Gradient.__init__
- Auto-generate default data_id using pattern 'gradient_{gradient_id}' when None
- Maintain full backward compatibility with existing explicit data_id usage
- Fix tutorial notebook errors where users create Gradient objects without data_id
- Ensure unique data_ids for each gradient to prevent conflicts
Resolves: ValueError: The data_id should not be None in question answering tutorials
and other notebook examples where users manually create Gradient objects.
- Implement lazy initialization of bedrock client to avoid AWS credential requirements during import - Add get_bedrock_runtime_exceptions() function with error handling and mock fallback - Update all references to use the new lazy function instead of immediate client creation - Resolves collection errors that were preventing CI tests from running This ensures PR SylphAI-Inc#448 can pass CI checks while maintaining the Gradient data_id fix.
- Add pytest-mock dependency for logger tests - Add lancedb dependency for retriever tests - Fix OpenAI client parser switching tests to work with dynamic parser selection - All tests now pass locally (535 passed, 2 skipped)
This branch has not been deployed
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.
Fix #382: Make Gradient data_id optional to prevent tutorial errors
Problem
Tutorial notebooks fail with
ValueError: The data_id should not be Nonewhen users createGradientobjects without providing the requireddata_idparameter. This breaks the learning experience for new users following documentation examples.Root Cause
The
Gradient.__init__method enforced thatdata_idmust be provided, raising aValueErrorifNone:This was problematic for tutorial scenarios where users manually create
Gradientobjects without understanding the internal data tracking requirements.Solution
data_idisNonegradient_{gradient_id}whenNonedata_idusageBefore (Problematic):
After (Fixed):
Benefits
data_idcontinues to workdata_idvalues are unique and predictableTesting
data_idstill works (backward compatibility)data_id=Nonegenerates sensible defaultsdata_idparameter works with auto-generationdata_idgeneration for multiple gradientsImpact
This fix resolves a common barrier for new users learning AdalFlow through tutorials and documentation. Users can now create
Gradientobjects intuitively without needing to understand internal data tracking mechanisms.Type of Change
Fixes #382