Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

standard-tests: structured output tests assume ls_structured_output_format implementation #30249

Closed
5 tasks done
mattf opened this issue Mar 12, 2025 · 2 comments
Closed
5 tasks done
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature investigate Flagged for investigation.

Comments

@mattf
Copy link
Contributor

mattf commented Mar 12, 2025

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

n/a

Error Message and Stack Trace (if applicable)

FAILED tests/integration_tests/test_chat_models.py::TestChatIntegration::test_structured_output[pydantic] - KeyError: 'ls_structured_output_format'
FAILED tests/integration_tests/test_chat_models.py::TestChatIntegration::test_structured_output[typeddict] - KeyError: 'ls_structured_output_format'
FAILED tests/integration_tests/test_chat_models.py::TestChatIntegration::test_structured_output[json_schema] - KeyError: 'ls_structured_output_format'
FAILED tests/integration_tests/test_chat_models.py::TestChatIntegration::test_structured_output_async[pydantic] - KeyError: 'ls_structured_output_format'
FAILED tests/integration_tests/test_chat_models.py::TestChatIntegration::test_structured_output_async[typeddict] - KeyError: 'ls_structured_output_format'
FAILED tests/integration_tests/test_chat_models.py::TestChatIntegration::test_structured_output_async[json_schema] - KeyError: 'ls_structured_output_format'

Description

while building a ChatModel integration with structured output support, i'm running into these failures -

FAILED tests/integration_tests/test_chat_models.py::TestChatIntegration::test_structured_output[pydantic] - KeyError: 'ls_structured_output_format'
FAILED tests/integration_tests/test_chat_models.py::TestChatIntegration::test_structured_output[typeddict] - KeyError: 'ls_structured_output_format'
FAILED tests/integration_tests/test_chat_models.py::TestChatIntegration::test_structured_output[json_schema] - KeyError: 'ls_structured_output_format'
FAILED tests/integration_tests/test_chat_models.py::TestChatIntegration::test_structured_output_async[pydantic] - KeyError: 'ls_structured_output_format'
FAILED tests/integration_tests/test_chat_models.py::TestChatIntegration::test_structured_output_async[typeddict] - KeyError: 'ls_structured_output_format'
FAILED tests/integration_tests/test_chat_models.py::TestChatIntegration::test_structured_output_async[json_schema] - KeyError: 'ls_structured_output_format'

the issue appears to be that the tests assume implementation details, specifically that a ls_structured_output_format param is present.

System Info

n/a

@langcarl langcarl bot added the investigate Flagged for investigation. label Mar 12, 2025
@dosubot dosubot bot added the 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature label Mar 12, 2025
@ccurme
Copy link
Collaborator

ccurme commented Mar 12, 2025

Hi @mattf, this is deliberate (we should pin langchain-tests in test dependencies if we aren't already). When we call .bind() in with_structured_output, we just need to pass in the schema and method. Are you working here? https://github.com/langchain-ai/langchain-nvidia/blob/49357d84d53ca29a8093e6a2732a147ff8545c09/libs/ai-endpoints/langchain_nvidia_ai_endpoints/chat_models.py#L880

You can see an example here: langchain-ai/langchain-google@16f4e81

Schema can be Pydantic model, TypedDict, JSON schema. You can call this function on the schema when passing it in to be safe:

from langchain_core.utils.function_calling import convert_to_openai_tool

convert_to_openai_tool(schema)

@mattf
Copy link
Contributor Author

mattf commented Mar 13, 2025

@ccurme understood. thanks for the pointers.

@mattf mattf closed this as completed Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature investigate Flagged for investigation.
Projects
None yet
Development

No branches or pull requests

2 participants