Код: Выделить всё
def invoke_agent(prompt: str):
"""
Sends a prompt for the agent to process and respond to.
:param agent_id: The unique identifier of the agent to use.
:param agent_alias_id: The alias of the agent to use.
:param session_id: The unique identifier of the session. Use the same value across requests
to continue the same conversation.
:param prompt: The prompt that you want Claude to complete.
:return: Inference response from the model.
"""
agents_runtime_client = boto3.client('bedrock-agent-runtime',
aws_access_key_id=all_values['aws_access_key_id'],
aws_secret_access_key=all_values['aws_secret_access_key'],
region_name="us-east-1")
try:
# Note: The execution time depends on the foundation model, complexity of the agent,
# and the length of the prompt. In some cases, it can take up to a minute or more to
# generate a response.
response = agents_runtime_client.invoke_agent(
agentId='**********',
agentAliasId='**********',
sessionId='session_id',
inputText=prompt,
)
completion = ""
for event in response.get("completion"):
chunk = event["chunk"]
completion = completion + chunk["bytes"].decode()
except ClientError as e:
logger.error(f"Couldn't invoke agent. {e}")
raise e
return completion
Код: Выделить всё
File "/opt/homebrew/lib/python3.11/site-packages/botocore/eventstream.py", line 619, in _parse_event
raise EventStreamError(parsed_response, self._operation_name)
botocore.exceptions.EventStreamError: An error occurred (resourceNotFoundException) when calling the InvokeAgent operation: Knowledge Base with id 7M7ACWA9BQ does not exist
Что я делаю не так и как это исправить?
Подробнее здесь: https://stackoverflow.com/questions/793 ... ng-the-inv
Мобильная версия