diff --git a/components/model/callback_extra.go b/components/model/callback_extra.go index 8334c056..be8260bb 100644 --- a/components/model/callback_extra.go +++ b/components/model/callback_extra.go @@ -44,7 +44,9 @@ type CompletionTokensDetails struct { type PromptTokenDetails struct { // Cached tokens present in the prompt. - CachedTokens int + CachedTokens int + CacheCreationInputTokens int + CacheReadInputTokens int } // Config is the config for the model. diff --git a/go.sum b/go.sum index 52cfaa3d..686fa6bc 100644 --- a/go.sum +++ b/go.sum @@ -21,8 +21,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/eino-contrib/jsonschema v1.0.2 h1:HaxruBMUdnXa7Lg/lX8g0Hk71ZIfdTZXmBQz0e3esr8= -github.com/eino-contrib/jsonschema v1.0.2/go.mod h1:cpnX4SyKjWjGC7iN2EbhxaTdLqGjCi0e9DxpLYxddD4= github.com/eino-contrib/jsonschema v1.0.3 h1:2Kfsm1xlMV0ssY2nuxshS4AwbLFuqmPmzIjLVJ1Fsp0= github.com/eino-contrib/jsonschema v1.0.3/go.mod h1:cpnX4SyKjWjGC7iN2EbhxaTdLqGjCi0e9DxpLYxddD4= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= diff --git a/schema/message.go b/schema/message.go index 4aefc440..30d615a4 100644 --- a/schema/message.go +++ b/schema/message.go @@ -264,6 +264,8 @@ type ChatMessageImageURL struct { // Detail is the quality of the image url. Detail ImageURLDetail `json:"detail,omitempty"` + Base64Data string `json:"base64data,omitempty"` + // MIMEType is the mime type of the image, eg. "image/png". MIMEType string `json:"mime_type,omitempty"` // Extra is used to store extra information for the image url. @@ -505,7 +507,9 @@ type CompletionTokensDetails struct { type PromptTokenDetails struct { // Cached tokens present in the prompt. - CachedTokens int `json:"cached_tokens"` + CachedTokens int `json:"cached_tokens"` + CacheCreationInputTokens int `json:"cache_creation_input_tokens"` + CacheReadInputTokens int `json:"cache_read_input_tokens"` } var _ MessagesTemplate = &Message{} @@ -1211,6 +1215,12 @@ func ConcatMessages(msgs []*Message) (*Message, error) { if msg.ResponseMeta.Usage.PromptTokenDetails.CachedTokens > ret.ResponseMeta.Usage.PromptTokenDetails.CachedTokens { ret.ResponseMeta.Usage.PromptTokenDetails.CachedTokens = msg.ResponseMeta.Usage.PromptTokenDetails.CachedTokens } + if msg.ResponseMeta.Usage.PromptTokenDetails.CacheCreationInputTokens > ret.ResponseMeta.Usage.PromptTokenDetails.CacheCreationInputTokens { + ret.ResponseMeta.Usage.PromptTokenDetails.CacheCreationInputTokens = msg.ResponseMeta.Usage.PromptTokenDetails.CacheCreationInputTokens + } + if msg.ResponseMeta.Usage.PromptTokenDetails.CacheReadInputTokens > ret.ResponseMeta.Usage.PromptTokenDetails.CacheReadInputTokens { + ret.ResponseMeta.Usage.PromptTokenDetails.CacheReadInputTokens = msg.ResponseMeta.Usage.PromptTokenDetails.CacheReadInputTokens + } } if msg.ResponseMeta.LogProbs != nil { diff --git a/schema/tool.go b/schema/tool.go index 44dc0e99..b36770e6 100644 --- a/schema/tool.go +++ b/schema/tool.go @@ -64,6 +64,8 @@ type ToolInfo struct { // Extra is the extra information for the tool. Extra map[string]any + Type string + // The parameters the functions accepts (different models may require different parameter types). // can be described in two ways: // - use params: schema.NewParamsOneOfByParams(params) @@ -83,6 +85,7 @@ type ParameterInfo struct { SubParams map[string]*ParameterInfo // The description of the parameter. Desc string + // The enum values of the parameter, only for string. Enum []string // Whether the parameter is required.