Skip to content

Conversation

@fede-kamel
Copy link
Contributor

Summary

This PR adds parallel tool calling support for Meta Llama 4+ models and comprehensive integration tests to ensure quality and compatibility.

Changes:

  • Parallel tool calling support for Meta Llama 4+ models via bind_tools(tools, parallel_tool_calls=True)
  • Validation that prevents parallel tool calls on unsupported models (Llama 3.x)
  • 4 new integration test files with 97 tests total
  • LangChain 1.x compatibility verified
  • Backwards compatibility with LangChain 0.3.x verified

Test Evidence

Test Count Summary

Test Suite Count
Unit Tests 47
Integration Tests 97
Total 144

New Integration Test Files

  1. test_langchain_compatibility.py (18 tests)

    • Basic invoke, streaming, async
    • Tool calling (single, multiple, parallel)
    • Structured output (function calling, JSON mode)
    • Response format tests
    • LangChain 1.x specific tests
  2. test_chat_features.py (20 tests)

    • LCEL chain tests (simple, with history, batch)
    • Async chain invocation
    • Streaming through chains
    • Advanced tool calling with execution
    • Structured output (complex schemas, extraction)
    • Model configuration (temperature, max_tokens, stop)
    • Error handling
    • Conversation patterns
  3. test_multi_model.py (30+ tests)

    • Meta Llama models (4-scout, 4-maverick, 3.3-70b, 3.1-70b)
    • Cohere models (command-a, command-r-plus)
    • xAI Grok models (grok-3-70b, grok-3-mini-8b)
    • OpenAI models (gpt-oss-20b, gpt-oss-120b)
  4. test_tool_calling.py (modified)

    • Fixed import for LangChain 1.x compatibility

LangChain Compatibility Testing

LangChain 1.1.0 (Latest)

langchain-core==1.1.0
langchain==1.1.0
  • Unit tests: 47/47 passed (100%)
  • Integration tests: All core functionality verified with real OCI inference

LangChain 0.3.x (Backwards Compatibility)

langchain-core==0.3.80
langchain==0.3.27
  • Unit tests: 47/47 passed (100%)
  • Full backwards compatibility confirmed

Models Tested (Real OCI Inference - Chicago Region)

Meta Llama

Model Basic Streaming Tool Calling Structured Output
meta.llama-4-scout-17b-16e-instruct
meta.llama-4-maverick-17b-128e-instruct-fp8
meta.llama-3.3-70b-instruct
meta.llama-3.1-70b-instruct

Cohere

Model Basic Streaming Tool Calling Structured Output
cohere.command-a-03-2025
cohere.command-r-plus-08-2024

xAI Grok

Model Basic Streaming Tool Calling Structured Output
xai.grok-3-70b
xai.grok-3-mini-8b

OpenAI

Model Basic Streaming Tool Calling Structured Output
openai.gpt-oss-20b
openai.gpt-oss-120b

Parallel Tool Calling Feature

Only enabled via bind_tools() parameter (consistent with other LangChain vendors):

from langchain_oci import ChatOCIGenAI

llm = ChatOCIGenAI(
    model_id="meta.llama-4-maverick-17b-128e-instruct-fp8",
    service_endpoint="https://inference.generativeai.us-chicago-1.oci.oraclecloud.com",
    compartment_id="MY_COMPARTMENT_ID",
)

# Enable parallel tool calling (Llama 4+ only)
llm_with_tools = llm.bind_tools(
    [get_weather, calculate_tip, get_population],
    parallel_tool_calls=True
)

Validation ensures:

  • Llama 3.x models raise ValueError if parallel_tool_calls=True
  • Only Llama 4+ models can use parallel tool calls
  • Clear error message guides users to supported models

Test Plan

  • Unit tests pass (47/47)
  • Integration tests with real OCI inference
  • LangChain 1.x compatibility verified
  • LangChain 0.3.x backwards compatibility verified
  • Multi-model vendor testing (Meta, Cohere, xAI, OpenAI)
  • Parallel tool calling validation tests

- Add parallel_tool_calls parameter to bind_tools() method
- Validate Llama 3.x models don't support parallel tool calls
- Cohere models raise error when parallel_tool_calls is used
- Add unit tests and integration tests
- Update README with usage example
## Test Summary

Total tests: 144 (47 unit + 97 integration)

### New Integration Test Files:

1. test_langchain_compatibility.py (18 tests)
   - Basic invoke, streaming, async
   - Tool calling (single, multiple, parallel)
   - Structured output (function calling, JSON mode)
   - Response format tests
   - LangChain 1.x specific tests

2. test_chat_features.py (20 tests)
   - LCEL chain tests (simple, with history, batch)
   - Async chain invocation
   - Streaming through chains
   - Advanced tool calling with execution
   - Structured output (complex schemas, extraction)
   - Model configuration (temperature, max_tokens, stop)
   - Error handling
   - Conversation patterns

3. test_multi_model.py (30+ tests)
   - Meta Llama models (4-scout, 4-maverick, 3.3-70b, 3.1-70b)
   - Cohere models (command-a, command-r-plus)
   - xAI Grok models (grok-3-70b, grok-3-mini-8b)
   - OpenAI models (gpt-oss-20b, gpt-oss-120b)

4. test_tool_calling.py (modified)
   - Fixed import for LangChain 1.x compatibility
   - Changed `from langchain.tools` to `from langchain_core.tools`

## Test Results (Real OCI Inference)

### LangChain 1.1.0:
- Unit tests: 47/47 passed (100%)
- Integration tests: All core functionality verified

### LangChain 0.3.x (Backwards Compatibility):
- Unit tests: 47/47 passed (100%)
- Verified with langchain-core 0.3.80, langchain 0.3.27

## Models Tested (OCI Chicago Region)

### Meta Llama:
- meta.llama-4-scout-17b-16e-instruct
- meta.llama-4-maverick-17b-128e-instruct-fp8
- meta.llama-3.3-70b-instruct
- meta.llama-3.1-70b-instruct

### Cohere:
- cohere.command-a-03-2025
- cohere.command-r-plus-08-2024

### xAI Grok:
- xai.grok-3-70b
- xai.grok-3-mini-8b

### OpenAI:
- openai.gpt-oss-20b
- openai.gpt-oss-120b
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Nov 26, 2025
@YouNeedCryDear
Copy link
Member

Duplicate of #59 ?

@fede-kamel fede-kamel closed this Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants