+
82
-

回答

role分为user和model,contents如果是多条消息,例如历史消息,可以是数组,代码如下:

 "contents": [
        {
            "role": "user",
            "parts": [
                {"text":"你哈"}
            ]
        },
      {
            "role": "model",
            "parts": [
                {"text":"你好,我是gemini,你的人工智能ai助手"}
            ]
        }
    ],
    "generationConfig": {
        "maxOutputTokens": 8192,
        "temperature":  0,
        "topP": 1,
    },

网友回复

我知道答案,我要回答