Issue:
When AWS Bedrock is used as the LLM provider, the inference works without any problems.
But when the LLM is applied to a RequirementAgent, the agent fails with the following error:
{"message":"You invoked an unsupported model or your request did not allow prompt caching. ..."}
I have tried several Bedrock models, and have run into the same error. Would explicit prompt caching instructions need to be added to the message? If yes, how do I add them?
This works
Using AmazonBedrockChatModel or ChatModel works when inferencing with an LLM.
import asyncio
import sys
import traceback
import os
from dotenv import load_dotenv
from beeai_framework.agents.react import ReActAgent
from beeai_framework.agents.requirement import RequirementAgent
from beeai_framework.agents.requirement.requirements.conditional import ConditionalRequirement
from beeai_framework.backend import ChatModel
from beeai_framework.adapters.amazon_bedrock import AmazonBedrockChatModel
from beeai_framework.errors import FrameworkError
from beeai_framework.middleware.trajectory import GlobalTrajectoryMiddleware
from beeai_framework.memory import UnconstrainedMemory
from beeai_framework.tools.think import ThinkTool
from beeai_framework.tools.tool import Tool
from beeai_framework.tools.weather import OpenMeteoTool
from beeai_framework.tools.search.duckduckgo import DuckDuckGoSearchTool
from beeai_framework.backend.message import MessageToolResultContent, UserMessage,SystemMessage,MessageTextContent
from beeai_framework.backend import ChatModelParameters
from beeai_framework.cache import NullCache, SlidingCache, UnconstrainedCache
from beeai_framework_starter.helpers.io import ConsoleReader
llm = AmazonBedrockChatModel(
model_id="us.meta.llama3-3-70b-instruct-v1:0",
secret_access_key=os.environ.get("AWS_SECRET_ACCESS_KEY", None),
access_key_id=os.environ.get("AWS_ACCESS_KEY_ID", None),
region=os.environ.get("AWS_REGION", "us-east-1"),
)
# llm = ChatModel.from_name("amazon_bedrock:us.meta.llama3-3-70b-instruct-v1:0")
user_message = UserMessage("what states are part of New England?")
response = await llm.run([user_message])
print(response.get_text_content())
This Fails
async def main() -> None:
agent = RequirementAgent(
llm = AmazonBedrockChatModel(
model_id="us.meta.llama3-3-70b-instruct-v1:0",
secret_access_key=os.environ.get("AWS_SECRET_ACCESS_KEY", None),
access_key_id=os.environ.get("AWS_ACCESS_KEY_ID", None),
region=os.environ.get("AWS_REGION", "us-east-1"),
),
tools=[ThinkTool(), OpenMeteoTool(), DuckDuckGoSearchTool()],
instructions="Plan activities for a given destination based on current weather and events.",
requirements=[
ConditionalRequirement(ThinkTool, force_at_step=1, max_invocations=3),
ConditionalRequirement(
DuckDuckGoSearchTool, only_after=[OpenMeteoTool], min_invocations=1, max_invocations=2
),
],
# Log intermediate steps to the console
middlewares=[GlobalTrajectoryMiddleware(included=[Tool])],
)
reader = ConsoleReader({"fallback": "Short snippets. What to do in Boston?"})
for prompt in reader:
response = await agent.run(prompt, max_iterations=8, max_retries_per_step=3, total_max_retries=10)
reader.write("Agent 🤖 : ", response.last_message.text)
if __name__ == "__main__":
try:
asyncio.run(main())
except FrameworkError as e:
traceback.print_exc()
sys.exit(e.explain())
I hope I haven't missed anything or configured anything incorrectly.
Thank you!
Andy
Issue:
When AWS Bedrock is used as the LLM provider, the inference works without any problems.
But when the LLM is applied to a RequirementAgent, the agent fails with the following error:
{"message":"You invoked an unsupported model or your request did not allow prompt caching. ..."}I have tried several Bedrock models, and have run into the same error. Would explicit prompt caching instructions need to be added to the message? If yes, how do I add them?
This works
Using AmazonBedrockChatModel or ChatModel works when inferencing with an LLM.
This Fails
I hope I haven't missed anything or configured anything incorrectly.
Thank you!
Andy