Below is the code which involves the use the langchain agents with the Titan model provided by the AWS Bedrock.
But I am facing issue in this, normal RAG chain is working fine , but when I use the agents with the tools and Titan model as the LLM for them , then the code stops executing and it fails.
Things which I am using :
- AWS Bedrock (Titan Express Model and Llama3 70 B instruct)
- Langchain
- Langchain Agents & Tools
4 Lambda Function (To execute the code)
Code :
rag_chain = (
{"context": retriever , "question": RunnablePassthrough()}
| PROMPT
| llm
| StrOutputParser()
)
ans = rag_chain.invoke(query)
print( "Rag_Chain", ans)
agent = initialize_agent(tools=tools, llm = llm, agent="zero-shot-react-description", verbose=True)
agentAns = agent.run(query)
print("Agent Answer: ", agentAns)
In the above code rag_chain.invoke is working fine, but the agent this is failing with the below output as shown:
Cloudwatch Logs
In above cloudwatch logs the rag chain gives the output but agents doen’t.
Surprisingly when I used the LLama 3 70 B instruct through GROQ then the agent are working fine.
Help me to get out of this weird problem.
I am expecting the solution for this problem , want to know whether there is the error with the code part or with the AWS bedrock Models