Versions of langchain libraries do not satisfy

I cannot import this libs

from langchain.agents import AgentExecutor, create_react_agent
from langchain_core.memory import ConversationBufferMemory

while these imports are quite well

from langchain_openai import ChatOpenAI
from langchain_core.callbacks import BaseCallbackHandler
from langchain_core.agents import AgentAction, AgentFinish
from langchain_core.prompts import PromptTemplate

What is the problem and how can I manage this problem?

P.S.
pip show langchain
Name: langchain
Version: 1.2.10
Summary: Building applications with LLMs through composability
Home-page: https://docs.langchain.com/

hi @Samir_AI

from langchain_classic.agents import AgentExecutor
from langchain_classic.memory import ConversationBufferMemory
from langgraph.prebuilt import create_react_agent

Huge favor - if it helps, please mark it Resolved for the others so they can make use of it too.

1 Like
agent = create_react_agent(
        model=llm,
        tools=tools,
        prompt=react_prompt
    )

@deprecated("create_react_agent has been moved to `langchain.agents`. Please update your import to `from langchain.agents import create_agent`.", category=LangGraphDeprecatedSinceV10)


TypeError: create_react_agent() missing 1 required positional argument: 'model'

I can’t understand what import is correct at last

TypeError: create_react_agent() missing 1 required positional argument: ‘model’

hmmm how do you define llm var?

This works fine:

agent1 = create_react_agent(model="openai:gpt", tools=[])
agent_executor = AgentExecutor(agent=agent1, tools=[])
memory = ConversationBufferMemory()
llm = ChatOpenAI(
    base_url="https://api-inference.huggingface.co/v1/",
    api_key=os.getenv("HUGGINGFACEHUB_API_TOKEN"),
    model="TinyLlama/TinyLlama-1.1B-Chat-v1.0",
    temperature=0.1,  # Низкая температура для более детерминированных вызовов инструментов
    streaming=True,    # Включаем стриминг для отладки
    callbacks=[StreamingCallback()]  # Вывод в консоль
)

agent = create_react_agent(
llm=llm,
tools=tools,
prompt=react_prompt
)

memory = ConversationBufferMemory(
memory_key=“chat_history”,
return_messages=True
)

agent_executor = AgentExecutor(
agent=agent,
tools=tools,
memory=memory,
verbose=True,
handle_parsing_errors=True,
max_iterations=5,
early_stopping_method=“generate”
)

agent = create_react_agent(
  model=llm,
  tools=tools,
  prompt=react_prompt
)

and ignore the type issue

1 Like

It does not work properly

LangGraphDeprecatedSinceV10: create_react_agent has been moved to langchain.agents. Please update your import to from langchain.agents import create_agent. Deprecated in LangGraph V1.0 to be removed in V2.0.
agent = create_react_agent(
LangChainDeprecationWarning: Please see the migration guide at: LangChain overview - Docs by LangChain
memory = ConversationBufferMemory(

This is ok?

yes, ignore the warnings. Only check whtether it works at runtime

Thank you very match!!

continue working…

or use create_agentfrom langchain.agents import create_agent

This is also ok, but it does not include prompt((

agent = create_agent(
model=llm,
tools=tools,
prompt=react_prompt
)

read the docs Agents | LangChain Reference