":{"message":"InvokeModelWithResponseStream: operation error Bedrock Runtime: In...
🚨 错误信息
{"error":{"message":"InvokeModelWithResponseStream: operation error Bedrock Runtime: InvokeModelWithResponseStream, https response error StatusCode: 400, RequestID: ce38b411-0e60-4b6b-b496-f4339c4081a4, ValidationException: `temperature` and `top_p` cannot both be specified for this model. Please use only one.","type":"aws_invoke_error","param":"","code":"aws_invoke_error"}}
🤖 AI解决方案
报错分析报告
1.错误翻译
``
原文:temperature and top_p cannot both be specified for this model. Please use only one.
译文:temperature(温度)和top_p(核采样率)参数不能同时为该模型指定,请仅使用其中一个。
`2.原因分析
根本原因:调用Bedrock模型时,同时传入了互斥参数 temperature和top_p,违反模型约束。
发生位置: InvokeModelWithResponseStream`操作的参数配置中,两个参数被同时指定。3.解决方案
以Python boto3调用为例,移除其中一个参数(二选一):
python
import boto3client = boto3.client("bedrock-runtime")
response = client.invoke_model_with_response_stream(
modelId="your-model-id",
body={
"prompt": "你的输入",
"max_tokens": 200,
# 仅保留temperature 或 top_p 中的一个
"temperature": 0.7, # 示例:保留temperature
# "top_p": 0.9, # 注释或删除top_p
},
contentType="application/json",
accept="application/json"
)
4. 预防措施
---
如需进一步分析其他报错,请提供具体错误信息。