Skip to content

Langserve & AgentExecutor Output on streaming events using beta API #25201

Answered by dosubot bot
rhlarora84 asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, you can control the output and remove history and agent_scratchpad from AgentExecutor when using the astream_events method in Langserve by customizing the prompt and the agent's behavior. Here is an example of how you can achieve this:

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

model = ChatOpenAI(model="gpt-4o")

prompt = ChatPromptTemplate.from_messages(
    [
        ("system", "You are a helpful assistant."),
        ("human", "{input}"),
        # Remove the placeholder for agent_scratchpad
    ]
)

@tool
def magic_function(

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rhlarora84
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant