wip: optional IDs in api (#1128)

This commit is contained in:
Dax
2025-07-18 13:42:50 -04:00
committed by GitHub
parent c952e9ae3d
commit d56dec4ba7
12 changed files with 145 additions and 99 deletions

View File

@@ -481,21 +481,33 @@ func (r FilePartType) IsKnown() bool {
return false
}
type FilePartParam struct {
ID param.Field[string] `json:"id,required"`
MessageID param.Field[string] `json:"messageID,required"`
Mime param.Field[string] `json:"mime,required"`
SessionID param.Field[string] `json:"sessionID,required"`
Type param.Field[FilePartType] `json:"type,required"`
URL param.Field[string] `json:"url,required"`
Filename param.Field[string] `json:"filename"`
type FilePartInputParam struct {
Mime param.Field[string] `json:"mime,required"`
Type param.Field[FilePartInputType] `json:"type,required"`
URL param.Field[string] `json:"url,required"`
ID param.Field[string] `json:"id"`
Filename param.Field[string] `json:"filename"`
}
func (r FilePartParam) MarshalJSON() (data []byte, err error) {
func (r FilePartInputParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
func (r FilePartParam) implementsSessionChatParamsPartUnion() {}
func (r FilePartInputParam) implementsSessionChatParamsPartUnion() {}
type FilePartInputType string
const (
FilePartInputTypeFile FilePartInputType = "file"
)
func (r FilePartInputType) IsKnown() bool {
switch r {
case FilePartInputTypeFile:
return true
}
return false
}
type Message struct {
ID string `json:"id,required"`
@@ -1076,28 +1088,40 @@ func (r textPartTimeJSON) RawJSON() string {
return r.raw
}
type TextPartParam struct {
ID param.Field[string] `json:"id,required"`
MessageID param.Field[string] `json:"messageID,required"`
SessionID param.Field[string] `json:"sessionID,required"`
Text param.Field[string] `json:"text,required"`
Type param.Field[TextPartType] `json:"type,required"`
Synthetic param.Field[bool] `json:"synthetic"`
Time param.Field[TextPartTimeParam] `json:"time"`
type TextPartInputParam struct {
Text param.Field[string] `json:"text,required"`
Type param.Field[TextPartInputType] `json:"type,required"`
ID param.Field[string] `json:"id"`
Synthetic param.Field[bool] `json:"synthetic"`
Time param.Field[TextPartInputTimeParam] `json:"time"`
}
func (r TextPartParam) MarshalJSON() (data []byte, err error) {
func (r TextPartInputParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
func (r TextPartParam) implementsSessionChatParamsPartUnion() {}
func (r TextPartInputParam) implementsSessionChatParamsPartUnion() {}
type TextPartTimeParam struct {
type TextPartInputType string
const (
TextPartInputTypeText TextPartInputType = "text"
)
func (r TextPartInputType) IsKnown() bool {
switch r {
case TextPartInputTypeText:
return true
}
return false
}
type TextPartInputTimeParam struct {
Start param.Field[float64] `json:"start,required"`
End param.Field[float64] `json:"end"`
}
func (r TextPartTimeParam) MarshalJSON() (data []byte, err error) {
func (r TextPartInputTimeParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
@@ -1574,11 +1598,11 @@ func (r sessionMessagesResponseJSON) RawJSON() string {
}
type SessionChatParams struct {
MessageID param.Field[string] `json:"messageID,required"`
Mode param.Field[string] `json:"mode,required"`
ModelID param.Field[string] `json:"modelID,required"`
Parts param.Field[[]SessionChatParamsPartUnion] `json:"parts,required"`
ProviderID param.Field[string] `json:"providerID,required"`
MessageID param.Field[string] `json:"messageID"`
Mode param.Field[string] `json:"mode"`
}
func (r SessionChatParams) MarshalJSON() (data []byte, err error) {
@@ -1586,10 +1610,8 @@ func (r SessionChatParams) MarshalJSON() (data []byte, err error) {
}
type SessionChatParamsPart struct {
ID param.Field[string] `json:"id,required"`
MessageID param.Field[string] `json:"messageID,required"`
SessionID param.Field[string] `json:"sessionID,required"`
Type param.Field[SessionChatParamsPartsType] `json:"type,required"`
ID param.Field[string] `json:"id"`
Filename param.Field[string] `json:"filename"`
Mime param.Field[string] `json:"mime"`
Synthetic param.Field[bool] `json:"synthetic"`
@@ -1604,7 +1626,8 @@ func (r SessionChatParamsPart) MarshalJSON() (data []byte, err error) {
func (r SessionChatParamsPart) implementsSessionChatParamsPartUnion() {}
// Satisfied by [FilePartParam], [TextPartParam], [SessionChatParamsPart].
// Satisfied by [TextPartInputParam], [FilePartInputParam],
// [SessionChatParamsPart].
type SessionChatParamsPartUnion interface {
implementsSessionChatParamsPartUnion()
}
@@ -1612,13 +1635,13 @@ type SessionChatParamsPartUnion interface {
type SessionChatParamsPartsType string
const (
SessionChatParamsPartsTypeFile SessionChatParamsPartsType = "file"
SessionChatParamsPartsTypeText SessionChatParamsPartsType = "text"
SessionChatParamsPartsTypeFile SessionChatParamsPartsType = "file"
)
func (r SessionChatParamsPartsType) IsKnown() bool {
switch r {
case SessionChatParamsPartsTypeFile, SessionChatParamsPartsTypeText:
case SessionChatParamsPartsTypeText, SessionChatParamsPartsTypeFile:
return true
}
return false