botocore.eventstream.InvalidHeadersLength

问题描述 投票:0回答:1

我尝试使用 boto3 调用 Bedrock 代理,但收到以下错误:

botocore.eventstream.InvalidHeadersLength: Header length of 1953527156 exceeded the maximum of 131072

这是我正在使用的代码:

import boto3
import uuid

bedrock = boto3.client('bedrock-agent-runtime', 
    aws_access_key_id=AWS_ACCESS_KEY_ID, 
    aws_secret_access_key=AWS_SECRET_ACCESS_KEY, 
    region_name=REGION
)

response = bedrock.invoke_agent(
    agentId=AGENT_ID,
    sessionId=str(uuid.uuid4()),
    inputText=INPUT_TEXT,
    agentAliasId="",
    enableTrace=False,
    endSession=False
)

stream = response.get("completion")
if stream:
    for event in stream:
        chunk = event.get('chunk')
        print(f"Agent Chunks: {chunk}")

可能是什么问题?

python amazon-web-services boto3 botocore amazon-bedrock
1个回答
0
投票

添加

TSTALIASID
作为 agentAliasId 以调用您的工作草案。用户指南中的详细信息 - https://docs.aws.amazon.com/bedrock/latest/userguide/agents-test.html

response = bedrock.invoke_agent(
    agentId=AGENT_ID,
    sessionId=session_id,  # you may want to save this ID for multi-turn conversation
    inputText=INPUT_TEXT,
    agentAliasId="TSTALIASID",
    enableTrace=False,
    endSession=False
)
© www.soinside.com 2019 - 2024. All rights reserved.