messages = [
{"role": "user", "content": "Hello there."},
{"role": "assistant", "content": "Hi, I'm Claude. How can I help?"},
{"role": "user", "content": "Can you explain Glycolysis to me?"},
]role和content。\n\nHuman:和\n\nAssistant:轮次,但消息 API 需要user和assistant角色。您可能会看到文档中提到”human”或”user”轮次。这些指的是同一个角色,今后将使用”user”。completion值中返回:content值,它是一个内容块列表:assistant来实现相同的结果:content将从最后一个输入消息的content继续:{
"role": "assistant",
"content": [{"type": "text", "text": " Claude. How can I assist you today?" }],
...
}\n\nHuman:轮次之前添加文本来指定的:system参数指定系统提示:claude-3-opus-20240229)。claude-2),这会导致自动升级到次要版本。但是,我们不再推荐这种集成模式,消息也不支持它。stop_reason之一:"stop_sequence":模型要么自然结束其轮次,要么生成了您的自定义停止序列之一。"max_tokens":模型要么生成了您指定的max_tokens内容,要么达到了其绝对最大值。stop_reason值之一:"end_turn":对话轮次自然结束。"stop_sequence":生成了您指定的自定义停止序列之一。"max_tokens":(保持不变)max_tokens_to_sample参数。无验证,但每个模型都有上限值。max_tokens参数。如果传递的值高于模型支持的值,则返回验证错误。"stream": true时,响应包含任何completion、ping和error服务器发送事件。详见文本补全流式处理。