Skip to content

Conversation

padambengani
Copy link
Member

This PR is for fixing the following issue - #37

Fix can be tested by running the following code (this fails with "array schema missing items" error without the fix and works fine with the fix proposed in this PR) -

from langchain_oci import ChatOCIGenAI
from langchain_core.tools import tool
from typing import Any, Dict, List, Literal, Optional
import json

llm = ChatOCIGenAI(
    service_endpoint=SERVICE_ENDPOINT,
    auth_file_location=AUTH_FILE_LOCATION,
    auth_profile=AUTH_PROFILE,
    compartment_id=COMPARTMENT_OCID,
    model_id="openai.gpt-5",
)

@tool
def get_weather_m(cities: list[str], unit: Literal["C", "F"] = None) -> str:
        """
        Get the weather of list of cities.

        Args:
            cities (list[str]): List of cities (maximum 2 cities)
        """

        return f"It is Sunny in all these {cities}"


@tool
def get_weather(city: str) -> str:
        """
        Get the weather of a city.
        """

        return f"It is Sunny in {city}"


print("Actual tool schema:")
print(json.dumps(get_weather_m.tool_call_schema.model_json_schema(), indent=4))

llm_with_tools = llm.bind_tools([get_weather_m])
print(llm_with_tools.invoke("How's the weather in these cities: New York City, London?"))

…sing convert_to_openai_function for any callable tool

Signed-off-by: Padam Prakash Bengani <[email protected]>
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Oct 4, 2025
@YouNeedCryDear
Copy link
Member

@padambengani Could you add unit test for the change?

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