feat: Add parallel tool calling support for Meta/Llama models #58
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
Add support for parallel tool calling (
is_parallel_tool_calls) to enable Meta/Llama models to execute multiple tools simultaneously, improving performance for multi-tool workflows.Problem
The langchain-oracle SDK did not expose the OCI API's
is_parallel_tool_callsparameter, forcing sequential tool execution even when tools could run in parallel.Performance Impact:
Solution
Implemented hybrid approach allowing both class-level defaults and per-binding overrides:
Changes
Core Implementation
parallel_tool_callsparameter toOCIGenAIBase- Default:Falsefor backward compatibilitybind_tools()method - Accept optionalparallel_tool_callsparameterMetaProvider.messages_to_oci_params()- Passis_parallel_tool_callsto OCI APIFiles Modified:
langchain_oci/llms/oci_generative_ai.py- Add class parameterlangchain_oci/chat_models/oci_generative_ai.py- Add bind_tools parameter and provider logicREADME.md- Add usage documentationTesting
Created comprehensive test suite with 9 unit tests covering:
Test Results:
tests/unit_tests/chat_models/test_parallel_tool_calling.py ✅ 9 passed in 0.38s tests/unit_tests/chat_models/test_oci_generative_ai.py ✅ 11 passed (2 pre-existing failures unrelated to this PR)Documentation
README.mdwith usage examplesBackward Compatibility
✅ Fully backward compatible - no breaking changes
False(same behavior as before)API Parity
This PR addresses a documented gap between the OCI GenAI API and langchain-oracle:
OCI API: Supports
is_parallel_tool_callsparameterlangchain-oracle (before): Parameter not exposed ❌
langchain-oracle (after): Parameter fully supported ✅
Model Support
Supported Models:
GenericChatRequestUnsupported Models:
Benefits
tool_choice)Testing Checklist
Next Steps
Related
Ready for review! 🎉