aws-samples/bedrock-access-gateway

When calling the claude-3 API through the Bedrock Access Gateway, the 'system' parameter does not take effect.

lishiyu opened this issue · 1 comments

When calling the claude-3 API through the Bedrock Access Gateway, the 'system' parameter does not take effect.

request demo 'curl /chat/completions
-H "Content-Type: application/json"
-H "Authorization: Bearer "
-d '{
"system":"我是一个中文用户,你的任何回答必须使用中文回答",
"max_tokens":100000,
"model": "anthropic.claude-3-haiku-20240307-v1:0",
"messages": [
{
"role": "user",
"content": "hi!"
}
]
}''

response json :

{
"id": "",
"created": "",
"model": "anthropic.claude-3-haiku-20240307-v1:0",
"system_fingerprint": "fp",
"choices": [
{
"index": 0,
"finish_reason": "end_turn",
"message": {
"role": "assistant",
"content": "Hello! How can I assist you today?"
}
}
],
"object": "chat.completion",
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21
}
}

Hi @lishiyu, the system parameter does not exist in chat/completions. This is something particular to Anthropic Claude Messages API.

image

You must pass the system prompt directly in the messages attribute

curl $OPENAI_BASE_URL/chat/completions \
	-H "Content-Type: application/json" \
	-H "Authorization: Bearer $OPENAI_API_KEY" \
	-d '{"max_tokens": 100000, "model": "anthropic.claude-3-haiku-20240307-v1:0", "messages": [{ "role": "system", "content": "我是一个中文用户,你的任何回答必须使用中文回答" }, { "role": "user", "content": "hi!" }]}'

Output:

{
	"id":"msg_019rYFNCKYh7Q8JJFodq5Dnu",
	"created":1713967410,
	"model":"anthropic.claude-3-haiku-20240307-v1:0",
	"system_fingerprint":"fp",
	"choices":[{
		"index":0,
		"finish_reason":"stop",
		"message":{
			"role":"assistant",
			"content":"你好!很高兴能和你交谈。作为一个以中文为主要语言 的人工智能助手,我会尽量用中文与你进行流畅的对话交流。如果有什么需要帮助的,欢迎随时告诉我。"
		}
	}],
	"object":"chat.completion",
	"usage":{
		"prompt_tokens":32,
		"completion_tokens":82,
		"total_tokens":113
	}
}