Skip to content

Conversation

ccurme
Copy link
Collaborator

@ccurme ccurme commented Aug 20, 2025

Can plumb through ChatGeneration, LLMResult, etc. if we want.

This is a minimal change, impact looks small and will fix more issues than it introduces.

Current state of things:

def get_weather(location: str) -> str:
    """Get the weather at a location."""
    ...

llm = init_chat_model("openai:gpt-5")
llm_with_tools = llm.bind_tools([get_weather])

response = llm_with_tools.invoke("query")
response.tool_calls  # Cannot access attribute "tool_calls" for class "BaseMessage"

Integration packages should update return type of bind_tools to Runnable[LanguageModelInput, AIMessage].

@ccurme ccurme requested a review from eyurtsev as a code owner August 20, 2025 20:12
Copy link

vercel bot commented Aug 20, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
langchain Ignored Ignored Preview Aug 21, 2025 5:51pm

Copy link

codspeed-hq bot commented Aug 20, 2025

CodSpeed WallTime Performance Report

Merging #32626 will not alter performance

Comparing cc/chat_model_return_type (b0a39b4) with wip-v1.0 (dbc5a3b)

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

✅ 13 untouched benchmarks

@ccurme ccurme changed the title fix(core): (v1) update BaseChatModel return type fix(core): (v1) update BaseChatModel return type to AIMessage Aug 20, 2025
Copy link

codspeed-hq bot commented Aug 20, 2025

CodSpeed Instrumentation Performance Report

Merging #32626 will not alter performance

Comparing cc/chat_model_return_type (b0a39b4) with wip-v1.0 (dbc5a3b)

Summary

✅ 14 untouched benchmarks

@mdrxy mdrxy added this to the v1 milestone Aug 20, 2025
@mdrxy mdrxy added the core Related to the package `langchain-core` label Aug 20, 2025
@ccurme ccurme merged commit 6f058e7 into wip-v1.0 Aug 21, 2025
169 checks passed
@ccurme ccurme deleted the cc/chat_model_return_type branch August 21, 2025 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to the package `langchain-core`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants