feat(ImageToText): add ImageToText task support
This commit is contained in:
parent
286e5aa6e5
commit
c1233ea660
27
tasks.go
27
tasks.go
@ -1,5 +1,9 @@
|
||||
package sati
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
)
|
||||
|
||||
type AnyTask interface {
|
||||
serialize() task
|
||||
Result() any
|
||||
@ -101,3 +105,26 @@ type GeeTest3Result struct {
|
||||
Validate string `json:"validate"`
|
||||
Seccode string `json:"seccode"`
|
||||
}
|
||||
|
||||
type ImageToTextTask struct {
|
||||
Image []byte `json:"-"`
|
||||
Type *string `json:"type"`
|
||||
}
|
||||
|
||||
func (t *ImageToTextTask) serialize() task {
|
||||
return task{
|
||||
Type: "ImageToText",
|
||||
Data: map[string]any{
|
||||
"image": base64.RawStdEncoding.EncodeToString(t.Image),
|
||||
"type": t.Type,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (t *ImageToTextTask) Result() any {
|
||||
return &ImageToTextResult{}
|
||||
}
|
||||
|
||||
type ImageToTextResult struct {
|
||||
Result string `json:"result"`
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user