LangChain All In One
LangChain All In One
LangChainis aframeworkfor buildingagentsandLLM-poweredapplications. It helps youchaintogetherinteroperable componentsandthird-party integrationstosimplifyAI application development – all while future-proofing decisions as the underlying technology evolves.
LangChain 是一个用于构建智能体和基于 LLM 的应用程序的框架。它可以帮助您将可互操作的组件和第三方集成连接起来,从而简化 AI 应用程序的开发——同时还能随着底层技术的演进,确保您的决策能够面向未来。
# Python pip
$ pip install langchain
https://github.com/langchain-ai/langchain

# pip install -qU langchain "langchain[anthropic]"
from langchain.agents import create_agent
def get_weather(city: str) -> str:
"""Get weather for a given city."""
return f"It's always sunny in {city}!"
agent = create_agent(
model="claude-sonnet-4-5-20250929",
tools=[get_weather],
system_prompt="You are a helpful assistant",
)
# Run the agent
agent.invoke(
{"messages": [{"role": "user", "content": "what is the weather in sf"}]}
)
https://docs.langchain.com/oss/python/langchain/overview
demos
import * as z from "zod";
// npm install @langchain/anthropic to call the model
import { createAgent, tool } from "langchain";
const getWeather = tool(
({ city }) => `It's always sunny in ${city}!`,
{
name: "get_weather",
description: "Get the weather for a given city",
schema: z.object({
city: z.string(),
}),
},
);
const agent = createAgent({
model: "claude-sonnet-4-5-20250929",
tools: [getWeather],
});
console.log(
await agent.invoke({
messages: [{ role: "user", content: "What's the weather in Tokyo?" }],
})
);
(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!
wiki
LangChain is a software framework that helps facilitate the integration of large language models (LLMs) into applications. As a language model integration framework, LangChain's use-cases largely overlap with those of language models in general, including document analysis and summarization, chatbots, and code analysis.
LangChain 是一个软件框架,有助于将大型语言模型 (LLM) 集成到应用程序中。作为一个语言模型集成框架,LangChain 的用例与一般语言模型的用例大体重叠,包括文档分析和摘要、聊天机器人和代码分析。

https://en.wikipedia.org/wiki/LangChain
LangGraph

https://docs.langchain.com/oss/javascript/langgraph/overview
refs

©xgqfrms 2012-2021
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/19345585
未经授权禁止转载,违者必究!

浙公网安备 33010602011771号