LangChain agents का परिचय

LangChain के साथ LLM एप्लिकेशन विकसित करना

Jonathan Bennion

AI Engineer & LangChain Contributor

Agents क्या हैं?

 

Agents: LLMs का उपयोग कर actions लेते हैं

Tools: एजेंट द्वारा कॉल किए गए functions

 

  • अबReAct Agent

यूज़र इनपुट के आधार पर कौन-सा tool उपयोग करना है, यह तय करता एजेंट.

LangChain के साथ LLM एप्लिकेशन विकसित करना

ReAct agents

  • Reason + Act

 

Kingston, Jamaica में मौसम कैसा है?

Thought: मुझे Kingston, Jamaica का मौसम जानने के लिए
Weather() कॉल करना चाहिए.


Act: Weather("Kingston, Jamaica")
Observe: मौसम ज्यादातर धूप वाला है और तापमान 82°F है.

सोचना, कार्रवाई करना, और अवलोकन करने का एक लूप.

LangChain के साथ LLM एप्लिकेशन विकसित करना

LangGraph

LangGraph लोगो.

 

  • LangChain की शाखा, जो agent systems डिज़ाइन पर केंद्रित है
  • एकीकृत, tool-agnostic सिंटैक्स
  • pip install langgraph==0.2.74
LangChain के साथ LLM एप्लिकेशन विकसित करना

ReAct agent

from langgraph.prebuilt import create_react_agent
from langchain_community.agent_toolkits.load_tools import load_tools

llm = ChatOpenAI(model="gpt-4o-mini", api_key=openai_api_key) tools = load_tools(["llm-math"], llm=llm)
agent = create_react_agent(llm, tools)
messages = agent.invoke({"messages": [("human", "What is the square root of 101?")]})
print(messages)
LangChain के साथ LLM एप्लिकेशन विकसित करना

ReAct agent

{'messages': [
    HumanMessage(content='What is the square root of 101?', ...),
    AIMessage(content='', ..., tool_calls=[{'name': 'Calculator', 'args': {'__arg1': 'sqrt(101)'}, ...),
    ToolMessage(content='Answer: 10.04987562112089', ...),
    AIMessage(content='The square root of 101 is approximately 10.05.', ...)
]}
print(messages['messages'][-1].content)
101 का square root लगभग 10.05 है.
LangChain के साथ LLM एप्लिकेशन विकसित करना

अभ्यास करते हैं!

LangChain के साथ LLM एप्लिकेशन विकसित करना

Preparing Video For Download...