ernievilg

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package ernievilg 百度文心AI画图

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildWork

func BuildWork(token, keyword, picType, picSize string) (taskID int, err error)

BuildWork 创建画图任务

token:GetToken函数获取,

keyword:图片描述,长度不超过64个字,prompt指南:https://wenxin.baidu.com/wenxin/docs#Ol7ece95m

picType:图片风格,目前支持风格有:油画、水彩画、卡通、粉笔画、儿童画、蜡笔画

picSize:图片尺寸,目前支持的有:1024*1024 方图、1024*1536 长图、1536*1024 横图。 传入的是尺寸数值,非文字。

taskID:任务ID,用于查询结果

func GetToken

func GetToken(clientID, clientSecret string) (token string, err error)

GetToken 获取当天的token

申请账号链接:https://wenxin.baidu.com/moduleApi/key

clientID为API key,clientSecret为Secret key

token有效时间为24小时

Types

type PicURL

type PicURL struct {
	Image string      `json:"image"`
	Score interface{} `json:"score"`
}

PicURL ...

func GetPic

func GetPic(token string, taskID int) (picurls []PicURL, status string, err error)

GetPic 获取图片内容

token由GetToken函数获取,taskID由BuildWork函数获取

PicURL:[x]struct{Image:图片链接,Score:评分}

API会返回x张图片,数量不确定的,随机的。

评分目前都是null,我不知道有什么用,既然API预留了,我也预留吧

stauts:结果状态,"30s"代表还在排队生成,"0"表示结果OK

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL