Skip to content

Commit

Permalink
Allow empty Content and Role
Browse files Browse the repository at this point in the history
These fields are required. Content is allowed to be empty. This behavior
can be observed by trying to include a FunctionCall Message (see also rakyll#25)
which has no Content. The API will reject it.

The OpenAPI specification for this type
(https://github.com/openai/openai-openapi/blob/e6277eabbbb5df1e90620e3657bb02da28dce460/openapi.yaml#L2195-L2197)
shows the following:

```yaml
    ChatCompletionRequestMessage:
      properties:
        ...

        content:
          type: string
          nullable: true
          description: The contents of the message. `content` is required for all messages, and may be null for assistant messages with function calls.

      ...
      required:
        - role
        - content
```

I've confirmed experimentally it accepts empty strings as well.
  • Loading branch information
rhettg committed Aug 21, 2023
1 parent a24dddc commit 4114b02
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions chat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ type Choice struct {
}

type Message struct {
Role string `json:"role,omitempty"`
Content string `json:"content,omitempty"`
Role string `json:"role"`
Content string `json:"content"`
Name string `json:"name,omitempty"`
}

Expand Down

0 comments on commit 4114b02

Please sign in to comment.