-
Couldn't load subscription status.
- Fork 228
Description
throughout the SDK, metadata is commonly represented by a shared object
https://github.com/openai/openai-[go/blob/main/shared/shared.go#L746](https://www.golinks.io/blob/main/shared/shared.go#L746?trackSource=github)
And other places. This provides strict typing, shared usage and easy consumption of the SDK.
However in the conversation API, metadata is listed as any
https://github.com/openai/openai-[go/blob/main/conversations/conversation.go#L124](https://www.golinks.io/blob/main/conversations/conversation.go#L124?trackSource=github)
Ironically, the comment defines the exact type, but the code allows any forcing me to do type conversions like this
func toStringMap(metadata any) map[string]string {
if metadata == nil {
return nil
}
if m, ok := metadata.(map[string]string); ok {
return m
}
m := map[string]string{}
if vals, ok := metadata.(map[string]any); ok {
for k, v := range vals {
if s, ok := v.(string); ok {
m[k] = s
}
}
}
if len(m) == 0 {
return nil
}
return m
}