Open Victorvexcel opened 3 months ago
I am having the same issue using the following code:
const tools = [new TavilySearchResults({ maxResults: 1 })]
const prompt = await pull<ChatPromptTemplate>(
'hwchase17/openai-tools-agent',
)
const llm = new ChatOpenAI({
model: 'gpt-4o',
temperature: 0,
apiKey: process.env.OPENAPI_KEY,
})
const agent = createToolCallingAgent({
llm,
tools,
// streamRunnable: true,
prompt,
})
const agentExecutor = new AgentExecutor({
agent,
tools,
// returnIntermediateSteps: true,
// verbose: true,
})
const input = `...`
const result = await agentExecutor.stream(
{ input },
{ maxConcurrency: 100 }
)
The input length is in my example: 43046
characters and the output gets truncated after around 20500
characters (sometimes more sometimes less, e.g. 20389
, 21373
or 20443`). Any feedback would be appreciated.
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
No response
Description
I am building a chat langchain agent powered by openai models. The agent is part of the backend of a web app that has a frontend where the user can interact with the agent.
The goal of this agent is to do some tool calling when the user message requires to do so. Some of the tools require to download images and send them to frontend so the user can visualize them. This process is done by encoding the images with base64, so that they are displayed correctly to the user.
The problem I am facing is that base64 image gets truncated when the agent finishes the chain and returns the answer. As an example, the base64 image that is downloaded by
download_image
has a length of 54443, while the answer returned by the agent has a length of 5762. This means that the image gets truncated by the agent. I am not completely sure why this happens, but maybe it is related with the maximum number of tokens that the agent can handle.Some alternatives that I have tried, but failed to make this work:
max_iteration
parameter inAgentExecutor
but the problems persistsI guess I could get into more low level stuff and try to override some default configuration of the agent, but first I wanted to ask for help to solve this problem.
System Info
langchain==0.1.20 langchain-community==0.0.38 langchain-core==0.1.52 langchain-openai==0.1.6 langchain-text-splitters==0.0.1
platform: Distributor ID: Ubuntu Description: Ubuntu 20.04.6 LTS Release: 20.04 Codename: focal
Python 3.8.10