Coder Social home page Coder Social logo

Comments (4)

lucas-tucker avatar lucas-tucker commented on August 14, 2024

This seems to be fixed in langchain 0.2.2

from langchain.

archine avatar archine commented on August 14, 2024

This seems to be fixed in langchain 0.2.2

No, I upgraded to 0.2.3, and using the official example, assert generation is not None

from langchain.agents import create_tool_calling_agent,AgentExecutor
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.tools import tool
from langchain_openai import ChatOpenAI


if __name__ == '__main__':
    llm = ChatOpenAI(...)

    @tool
    def magic_function(input: int) -> int:
        """Applies a magic function to an input."""
        return input + 2


    tools = [magic_function]

    query = "what is the value of magic_function(3)?"

    prompt = ChatPromptTemplate.from_messages(
        [
            ("system", "You are a helpful assistant"),
            ("human", "{input}"),
            # Placeholders fill up a **list** of messages
            ("placeholder", "{agent_scratchpad}"),
        ]
    )

    agent = create_tool_calling_agent(llm, tools, prompt)
    agent_executor = AgentExecutor(agent=agent, tools=tools)

    agent_executor.invoke({"input": query})

Related version

langchain==0.2.3
langchain-community==0.2.3
langchain-core==0.2.3
langchain-openai==0.1.8

from langchain.

lucas-tucker avatar lucas-tucker commented on August 14, 2024

I cannot seem to replicate the error, even after upgrading to 0.2.3. How are you creating llm? Also could you please clarify what the "official example" is?

from langchain.

archine avatar archine commented on August 14, 2024

I cannot seem to replicate the error, even after upgrading to 0.2.3. How are you creating llm? Also could you please clarify what the "official example" is?

I re-edited the sample code in my last answer, which is a demo from the dependency library comments。
image

from langchain.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.