Closed codematters-pl closed 6 months ago
🤖
Hello @codematters-pl!
I'm Dosu, a helpful bot here to assist you while we wait for a human maintainer. I can help you solve bugs, answer questions, and if you're interested, I can guide you on how to become a contributor too. Remember, while I strive to provide accurate information, I'm a bot and my knowledge is limited. Thank you for your understanding.
Based on the information I found in the langchainjs repository, it is indeed possible to use a predefined AWS Bedrock agent with Langchainjs. This is achieved through the createAWSSfnAgent
function, which is designed to create an agent that interacts with AWS Step Functions. This function takes in a language model, a toolkit, and optional arguments. The toolkit is an instance of AWSSfnToolkit
, which presumably contains the necessary tools for interacting with AWS Step Functions.
Here is the relevant code:
export function createAWSSfnAgent(
llm: BaseLanguageModel,
toolkit: AWSSfnToolkit,
args?: AWSSfnCreatePromptArgs
) {
const {
prefix = SFN_PREFIX,
suffix = SFN_SUFFIX,
inputVariables = ["input", "agent_scratchpad"],
} = args ?? {};
const { tools } = toolkit;
const formattedPrefix = renderTemplate(prefix, "f-string", {});
const prompt = ZeroShotAgent.createPrompt(tools, {
prefix: formattedPrefix,
suffix,
inputVariables,
});
const chain = new LLMChain({ prompt, llm });
const agent = new ZeroShotAgent({
llmChain: chain,
allowedTools: tools.map((t) => t.name),
});
return AgentExecutor.fromAgentAndTools({
agent,
tools,
returnIntermediateSteps: true,
});
}
(Source: langchain/src/agents/toolkits/aws_sfn.ts)
However, the context does not provide information about setting an agentAliasId
. This might be done elsewhere in the code or might not be necessary for this specific use case.
Regarding your question about AWS Bedrock agent support, I found two similar solved issues in the repository:
Bedrock: support for custom endpoints which was last updated on September 14, 2023. The suggested solution is: The issue has been fixed by the update #2614 and will be live in the next release (0.0.149).
Support for Amazon Bedrock which was last updated on August 15, 2023. This issue was closed by a pull request: Add Amazon Bedrock LLM endpoint integration on August 15, 2023.
I hope this information helps! If you need further clarification or have more questions, feel free to ask.
Best, Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
Any updates on this issue? I am also trying to bind bedrock built-in agents with my chatbot using langchain, but seems it is not supported in the latest release yet.
Any updates on this issue? I am also trying to bind bedrock built-in agents with my chatbot using langchain, but seems it is not supported in the latest release yet.
As far as I know, currently there is no wrapping around AWS Bedrock as an agent like OpenAIAgent. Since Bedrock uses XML for function calling (OpenAI uses JSON), some prompting logic need to be changed in order to enable that.
Hi, @codematters-pl,
I'm helping the langchainjs team manage their backlog and am marking this issue as stale. From what I understand, you inquired about support for the AWS Bedrock agent within Langchain and whether it's possible to use a predefined agent in Langchain with the AWS Bedrock agent's API. I provided information on using a predefined AWS Bedrock agent with Langchainjs and referenced relevant code. Additionally, xiaodiiii and monkeyboiii expressed interest in updates and discussed the current lack of support for binding bedrock built-in agents with Langchain.
Could you please confirm if this issue is still relevant to the latest version of the langchainjs repository? If it is, please let the langchainjs team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days. Thank you!
Hello,
I couldn't find any information about it, so it is the right place to ask about support for the AWS Bedrock agent. Not every region in AWS supports it (I'm using it within us-east-1)
Is there any possibility of using a predefined agent in Langchain? I can set up the endpoint https://docs.aws.amazon.com/bedrock/latest/userguide/api-agent-invoke.html
But still, I have to set
agentAliasId
. API for the Bedrock Agent looks different, so I'm unsure if the current implementation will allow me to use it there.Thank you in advance!