Skip to content
19 changes: 5 additions & 14 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
A similar PR may already be submitted!
Please search among the [Pull request](https://github.com/sashabaranov/go-openai/pulls) before creating one.

If your changes introduce breaking changes, please prefix the title of your pull request with "[BREAKING_CHANGES]". This allows for clear identification of such changes in the 'What's Changed' section on the release page, making it developer-friendly.

Thanks for submitting a pull request! Please provide enough information so that others can review your pull request.

**Describe the change**
Please provide a clear and concise description of the changes you're proposing. Explain what problem it solves or what feature it adds.
<!-- Please provide a clear and concise description of the changes you're proposing. Explain what problem it solves or what feature it adds. -->

**Provide OpenAI documentation link**
Provide a relevant API doc from https://platform.openai.com/docs/api-reference
<!-- Provide a relevant API doc from https://platform.openai.com/docs/api-reference -->

**Describe your solution**
Describe how your changes address the problem or how they add the feature. This should include a brief description of your approach and any new libraries or dependencies you're using.
<!-- Describe how your changes address the problem or how they add the feature. This should include a brief description of your approach and any new libraries or dependencies you're using. -->

**Tests**
Briefly describe how you have tested these changes. If possible — please add integration tests.
<!-- Briefly describe how you have tested these changes. If possible — please add integration tests. -->

**Additional context**
Add any other context or screenshots or logs about your pull request here. If the pull request relates to an open issue, please link to it.

Issue: #XXXX
<!-- Add any other context or screenshots or logs about your pull request here. If the pull request relates to an open issue, please link to it. -->
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Github Forked Branch Rules
`master` - kept in sync with main repository. Do not merge anything into this branch other than sync code.
`develop` - default branch of this forked repository. Merge all PRs into this branch.
`release` - only release from this branch. Merge the `develop` into `release` branch before doing a tagged release.

# Go OpenAI
[![Go Reference](https://pkg.go.dev/badge/github.com/sashabaranov/go-openai.svg)](https://pkg.go.dev/github.com/sashabaranov/go-openai)
[![Go Report Card](https://goreportcard.com/badge/github.com/sashabaranov/go-openai)](https://goreportcard.com/report/github.com/sashabaranov/go-openai)
Expand Down
8 changes: 8 additions & 0 deletions chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ type ChatCompletionMessage struct {

// For Role=tool prompts this should be set to the ID given in the assistant's prior request to call a tool.
ToolCallID string `json:"tool_call_id,omitempty"`

// Messari custom fields
Prefix bool `json:"prefix,omitempty"`
}

func (m ChatCompletionMessage) MarshalJSON() ([]byte, error) {
Expand All @@ -136,6 +139,7 @@ func (m ChatCompletionMessage) MarshalJSON() ([]byte, error) {
FunctionCall *FunctionCall `json:"function_call,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
Prefix bool `json:"prefix,omitempty"`
}(m)
return json.Marshal(msg)
}
Expand All @@ -150,6 +154,7 @@ func (m ChatCompletionMessage) MarshalJSON() ([]byte, error) {
FunctionCall *FunctionCall `json:"function_call,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
Prefix bool `json:"prefix,omitempty"`
}(m)
return json.Marshal(msg)
}
Expand All @@ -165,6 +170,7 @@ func (m *ChatCompletionMessage) UnmarshalJSON(bs []byte) error {
FunctionCall *FunctionCall `json:"function_call,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
Prefix bool `json:"prefix,omitempty"`
}{}

if err := json.Unmarshal(bs, &msg); err == nil {
Expand All @@ -181,6 +187,7 @@ func (m *ChatCompletionMessage) UnmarshalJSON(bs []byte) error {
FunctionCall *FunctionCall `json:"function_call,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
Prefix bool `json:"prefix,omitempty"`
}{}
if err := json.Unmarshal(bs, &multiMsg); err != nil {
return err
Expand All @@ -195,6 +202,7 @@ type ToolCall struct {
ID string `json:"id,omitempty"`
Type ToolType `json:"type"`
Function FunctionCall `json:"function"`
Name string `json:"name,omitempty"`
}

type FunctionCall struct {
Expand Down
3 changes: 3 additions & 0 deletions messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ type Message struct {
Metadata map[string]any `json:"metadata"`

httpHeader

// Messari custom fields
Prefix bool `json:"prefix,omitempty"`
}

type MessagesList struct {
Expand Down
Loading