Skip to content

Conversation

pxkundu
Copy link
Contributor

@pxkundu pxkundu commented Oct 6, 2025

Summary

This PR improves the existing AzureAIClient by:

  • Use provided Azure credentials for token provider initialization (fallback to DefaultAzureCredential)
  • Fix parse_chat_completion to return parsed text in data field instead of None
  • Preserve raw_response for compatibility

Why

  • Aligns with Azure AD authentication usage patterns
  • Ensures downstream components receive parsed text in the expected data field
  • Fixes a bug where parsed content was only available in raw_response

Changes

  • adalflow/adalflow/components/model_client/azureai_client.py
    • Use provided credential in init_sync_client() and init_async_client()
    • Return parsed text in data within parse_chat_completion()
  • adalflow/tests/test_AzureClient.py
    • Add tests for provided credential usage and parser behavior

Testing

  • Lint clean on edited files
  • Follow-up: add more unit tests for AAD token path and parsing behavior

Related

Closes #285

…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.
…rrors; Tests: align OpenAI parser tests with dynamic parser selection; CI: add pytest-mock and lancedb to test group
… instances

- Fix Agent initialization in open_ai_test.py by adding required model_client and model_kwargs parameters
- Fix setup_env() calls in test files to handle missing .env file gracefully
- Add pytest.mark.asyncio decorators to async test functions
- Fix import path for AutoApprovalHandler in test_permission_system.py
- Use fake API keys for testing to avoid environment variable requirements

All tests now pass: 542 passed, 2 skipped, 11 warnings
…in data; tidy parser usage and keep raw_response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Azure AI integration
1 participant