

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# Mistral AI 채팅 완성
<a name="model-parameters-mistral-chat-completion"></a>

Mistral AI 채팅 완성 API를 사용하면 대화형 애플리케이션을 만들 수 있습니다.

**작은 정보**  
Mistral AI 채팅 완성 API를 기본 추론 작업([InvokeModel](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html) 또는 [InvokeModelWithResponseStream](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModelWithResponseStream.html)과 함께 사용할 수 있습니다. 하지만 애플리케이션에서 메시지를 구현할 때는 Converse API를 사용하는 것이 좋습니다. Converse API는 메시지를 지원하는 모든 모델에서 작동하는 통합 파라미터 세트를 제공합니다. 자세한 내용은 [Converse API 작업과 대화 수행](conversation-inference.md) 섹션을 참조하세요.

Mistral AI 모델은 [Apache 2.0 라이선스](https://www.apache.org/licenses/LICENSE-2.0.txt)에서 사용할 수 있습니다. Mistral AI 모델 사용에 대한 자세한 내용은 [Mistral AI 설명서](https://docs.mistral.ai/)를 참조하세요.

**Topics**
+ [지원되는 모델](#mistral-supported-models-chat-completion)
+ [요청 및 응답](#model-parameters-mistral-chat-completion-request-response)

## 지원되는 모델
<a name="mistral-supported-models-chat-completion"></a>

다음 Mistral AI 모델을 사용할 수 있습니다.
+ Mistral Large

사용하려는 모델의 모델 ID가 필요합니다. 모델 ID를 가져오려면 [Amazon Bedrock에서 지원되는 파운데이션 모델](models-supported.md) 섹션을 참조하세요.

## 요청 및 응답
<a name="model-parameters-mistral-chat-completion-request-response"></a>

------
#### [ Request ]

Mistral AI 모델에는 다음과 같은 추론 파라미터가 있습니다.

```
{
    "messages": [
        {
            "role": "system"|"user"|"assistant",
            "content": str
        },
        {
            "role": "assistant",
            "content": "",
            "tool_calls": [
                {
                    "id": str,
                    "function": {
                        "name": str,
                        "arguments": str
                    }
                }
            ]
        },
        {
            "role": "tool",
            "tool_call_id": str,
            "content": str
        }
    ],
    "tools": [
        {
            "type": "function",
            "function": {
                "name": str,
                "description": str,
                "parameters": dict
            }
        }
    ],
    "tool_choice": "auto"|"any"|"none",
    "max_tokens": int,
    "top_p": float,
    "temperature": float
}
```

다음은 필수 파라미터입니다.
+  **messages** - (필수) 모델에 전달하려는 메시지입니다.
  + **role** - 메시지의 역할입니다. 유효한 값은 다음과 같습니다.
    + **system** - 대화에서 모델의 동작과 컨텍스트를 설정합니다.
    + **user** - 모델에 전송할 사용자 메시지입니다.
    + **assistant** - 모델의 응답입니다.
  + **content** - 메시지의 콘텐츠입니다.

  ```
  [
      {
          "role": "user",
          "content": "What is the most popular song on WZPZ?"
      }
  ]
  ```

  도구 결과를 전달하려면 다음 필드가 있는 JSON을 사용합니다.
  + **role** - 메시지의 역할입니다. 값은 `tool`여야 합니다.
  + **tool\_call\_id** - 도구 요청의 ID입니다. 이전 요청의 응답에 있는 `tool_calls` 필드에서 ID를 가져옵니다.
  + **content** - 도구의 결과입니다.

  다음 예제는 라디오 방송국에서 가장 인기 있는 노래를 가져오는 도구의 결과입니다.

  ```
  {
      "role": "tool",
      "tool_call_id": "v6RMMiRlT7ygYkT4uULjtg",
      "content": "{\"song\": \"Elemental Hotel\", \"artist\": \"8 Storey Hike\"}"
  }
  ```

다음 파라미터는 선택 사항입니다.
+  **tools** - 모델이 사용할 수 있는 도구의 정의입니다.

  요청에 `tools`를 포함하면 모델이 메시지에서 해당 도구의 사용을 나타내는 `tool_calls` 필드를 반환할 수 있습니다. 그런 다음 모델에서 생성된 도구 입력을 사용하여 이러한 도구를 실행한 다음, 선택적으로 `tool_result` 콘텐츠 블록을 사용하여 결과를 모델로 반환할 수 있습니다.

  다음 예제는 라디오 방송국에서 가장 인기 있는 노래를 가져오는 도구입니다.

  ```
  [
      {
          "type": "function",
          "function": {
              "name": "top_song",
              "description": "Get the most popular song played on a radio station.",
              "parameters": {
                  "type": "object",
                  "properties": {
                      "sign": {
                          "type": "string",
                          "description": "The call sign for the radio station for which you want the most popular song. Example calls signs are WZPZ and WKRP."
                      }
                  },
                  "required": [
                      "sign"
                  ]
              }
          }
      }
  ]
  ```
+  **tool\_choice** - 함수를 직접 호출하는 방법을 지정합니다. `none`으로 설정하면 모델이 함수를 직접 호출하지 않고 대신 메시지가 생성됩니다. `auto`로 설정하면 모델이 메시지를 생성하거나 함수를 직접 호출하도록 선택할 수 있습니다. `any`로 설정하면 모델은 함수를 직접 호출해야 합니다.
+ **max\_tokens** - 생성된 응답에서 사용할 최대 토큰 수를 지정합니다. 생성된 텍스트가 `max_tokens`을 초과하면 모델은 응답을 잘라냅니다.    
[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/bedrock/latest/userguide/model-parameters-mistral-chat-completion.html)
+ **temperature** - 모델이 수행한 예측의 무작위성을 제어합니다. 자세한 내용은 [추론 파라미터를 사용하여 응답 생성에 영향을 주는 방법](inference-parameters.md) 섹션을 참조하세요.    
[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/bedrock/latest/userguide/model-parameters-mistral-chat-completion.html)
+ **top\_p** - 모델이 다음번 토큰에 대해 고려하는 가장 가능성이 높은 후보의 백분율을 설정하여 모델이 생성하는 텍스트의 다양성을 제어합니다. 자세한 내용은 [추론 파라미터를 사용하여 응답 생성에 영향을 주는 방법](inference-parameters.md) 섹션을 참조하세요.    
[See the AWS documentation website for more details](http://docs.aws.amazon.com/ko_kr/bedrock/latest/userguide/model-parameters-mistral-chat-completion.html)

------
#### [ Response ]

`InvokeModel`에 대한 직접 호출의 `body` 응답은 다음과 같습니다.

```
{
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": str,
                "tool_calls": [...]
            },
            "stop_reason": "stop"|"length"|"tool_calls"
        }
    ]
}
```

`body` 응답에는 다음과 같은 필드가 포함됩니다.
+ **choices** - 모델이 출력하는 필드를 나타냅니다.
  + **index** - 메시지의 인덱스입니다.
  + **message** - 모델의 메시지입니다.
    + **role** - 메시지의 역할입니다.
    + **content** - 메시지의 콘텐츠입니다.
    + **tool\_calls** - `stop_reason` 값이 `tool_calls`인 경우, 이 필드에는 모델이 실행하려는 도구 요청 목록이 포함됩니다.
      + **id** - 도구 요청의 ID입니다.
      + **function** - 모델이 요청하는 함수입니다.
        + **name** - 함수의 이름입니다.
        + **arguments** - 도구에 전달할 인수입니다.

      다음은 라디오 방송국에서 인기 노래를 가져오는 도구에 대한 예제 요청입니다.

      ```
      [
                          {
                              "id": "v6RMMiRlT7ygYkT4uULjtg",
                              "function": {
                                  "name": "top_song",
                                  "arguments": "{\"sign\": \"WZPZ\"}"
                              }
                          }
                      ]
      ```
  + **stop\_reason** – 응답이 텍스트 생성을 중지한 이유입니다. 가능한 값은 다음과 같습니다.
    + **중지** - 모델이 입력 프롬프트에 대한 텍스트 생성을 완료했습니다. 생성할 콘텐츠가 더 이상 없거나 모델이 `stop` 요청 파라미터에서 정의한 중지 시퀀스 중 하나를 생성하는 경우 모델이 중지됩니다.
    + **length** - 생성된 텍스트의 토큰 길이가 `max_tokens` 값을 초과합니다. 응답은 `max_tokens` 토큰 수로 잘립니다.
    + **tool\_calls** - 모델이 도구 실행을 요청하고 있습니다.

------