mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-26 01:22:24 +02:00
This PR improves standard integration tests in prebuilt to ensure logical equivalence between the Python and JavaScript implementations of `create_agent`. * Cleans up `test_responses_int` test harness * Adds new test utils to dynamically load JSON test specs * Adds `test_return_direct_int` test harness to validate model behavior when `return_direct` tool property is set * Adds support for when the user instantiates `ToolOutput` with multiple JSON schemas unified by the `oneOf` keyword Failing tests: * `test_inference_to_native_output`: there is some odd behavior where the model makes a second call to `get_weather` despite having just received the tool message, so there are 6 messages instead of the 4 expected. * `test_responses_integration_matrix[asking for information that does not fit into the response format]`: `XFAIL`, currently failing due to undefined behavior when the model cannot conform to any of the structured response formats. TODO in future PRs: * Add exception handling to pass `test_responses_integration_matrix`.
23 lines
595 B
Python
23 lines
595 B
Python
import json
|
|
from pathlib import Path
|
|
from typing import Type
|
|
|
|
from pydantic import BaseModel, ConfigDict
|
|
from pydantic.alias_generators import to_camel
|
|
|
|
|
|
class BaseSchema(BaseModel):
|
|
model_config = ConfigDict(
|
|
alias_generator=to_camel,
|
|
populate_by_name=True,
|
|
from_attributes=True,
|
|
)
|
|
|
|
|
|
def load_spec(spec_name: str, as_model: Type[BaseModel]) -> list[BaseModel]:
|
|
with (Path(__file__).parent / "specifications" / f"{spec_name}.json").open(
|
|
"r", encoding="utf-8"
|
|
) as f:
|
|
data = json.load(f)
|
|
return [as_model(**item) for item in data]
|