From e4f24307296a52d306a751f414e8bf28a0a99b71 Mon Sep 17 00:00:00 2001 From: "sati.ac" Date: Thu, 31 Aug 2023 18:49:27 +0300 Subject: [PATCH] feat(ImageToText): add ImageToText task support --- tasks.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tasks.go b/tasks.go index e9f158a..14d69c0 100644 --- a/tasks.go +++ b/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]string{ + "image": base64.RawStdEncoding.EncodeToString(t.Image), + "type": t.Type, + }, + } +} + +func (t *ImageToTextTask) Result() any { + return &ImageToTextResult{} +} + +type ImageToTextResult struct { + Result string `json:"result"` +}