-
Notifications
You must be signed in to change notification settings - Fork 148
Support for raw JSON objects in system message content #383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The current way to do this is to use For example for the ChatCompletionMessageParamUnion
Full disclosure: we're likely going to change the name of |
@jacobzim-stl Thanks !! Using sysMsg := param.OverrideObj[openai.ChatCompletionSystemMessageParam](map[string]interface{}{
"content": []map[string]interface{}{
{"assistant_name": "Alfred Pennyworth"},
},
"role": "system",
}) However, when using func main() {
customData := CustomStruct{
City: "paradeep",
}
systemMsg := param.OverrideObj[openai.ChatCompletionMessageParamUnion](customData)
userMsg := openai.UserMessage("Hello")
messages := []openai.ChatCompletionMessageParamUnion{
systemMsg,
userMsg,
}
jsonBytes, err := json.Marshal(messages)
fmt.Println(string(jsonBytes))
fmt.Println(err)
} output:
Moreover, using sysmsg := openai.SystemMessage(name)
sysmsg.OfSystem.WithExtraFields(
map[string]any{
"content": []any{
map[string]any{"assistant_name": name},
},
},
) |
@jacobzim-stl regarding changing the name of |
I'm using the OpenAI Go SDK with a custom endpoint that hosts a model. According to the model’s JSON schema, the system message must include a JSON object like this:
{ "assistant_name": "Alfred Pennyworth"}
In the Python SDK, I can pass the system message as follows:
{"role": "system", "content": [{"assistant_name": "Alfred Pennyworth"}]}.
And this correctly satisfies the models requirement.
However, in the Go SDK, the current union type for message content only accepts plain strings or an array of text parts. Is there an existing workaround or a suggested solution to pass raw JSON objects in system message
The text was updated successfully, but these errors were encountered: