mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-16 06:53:16 +00:00
core[patch]: Add pydantic metadata to subset model (#25032)
- **Description:** This includes Pydantic field metadata in `_create_subset_model_v2` so that it gets included in the final serialized form that get sent out. - **Issue:** #25031 - **Dependencies:** n/a - **Twitter handle:** @gramliu --------- Co-authored-by: Bagatur <baskaryan@gmail.com> Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com>
This commit is contained in:
@@ -18,6 +18,8 @@ from langchain_core.output_parsers import StrOutputParser
|
||||
from langchain_core.prompts import ChatPromptTemplate
|
||||
from langchain_core.pydantic_v1 import BaseModel, Field
|
||||
from langchain_core.tools import tool
|
||||
from pydantic import BaseModel as RawBaseModel
|
||||
from pydantic import Field as RawField
|
||||
|
||||
from langchain_standard_tests.unit_tests.chat_models import (
|
||||
ChatModelTests,
|
||||
@@ -26,7 +28,11 @@ from langchain_standard_tests.unit_tests.chat_models import (
|
||||
from langchain_standard_tests.utils.pydantic import PYDANTIC_MAJOR_VERSION
|
||||
|
||||
|
||||
@tool
|
||||
class MagicFunctionSchema(RawBaseModel):
|
||||
input: int = RawField(..., gt=-1000, lt=1000)
|
||||
|
||||
|
||||
@tool(args_schema=MagicFunctionSchema)
|
||||
def magic_function(input: int) -> int:
|
||||
"""Applies a magic function to an input."""
|
||||
return input + 2
|
||||
|
Reference in New Issue
Block a user