cogview3

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: MulanPSL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

智谱 CogView-3 系列模型 SDK

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

CogView-3 Client 客户端

func NewClient

func NewClient(timeOutSeconds int, key string, tokenExpireSeconds int) (*Client, error)

新建 CogView-3 访问客户端

@param key API Key
@param tokenExpireSeconds Token 有效秒数,当值小于等于 0 时,表示使用 API Key 鉴权,而非 Token 鉴权
@param timeOutSeconds 超时秒数
@return Client 客户端实例
@return error 错误信息

func (*Client) SyncCall

func (r *Client) SyncCall(reqBody *Request) (*Response, error)

发送同步请求

RestFul 协议实现
@param reqBody 请求体
@return *Response 返回数据
@return error 错误信息

type ContentFilter

type ContentFilter struct {
	// 安全生效环节,包括
	//  role = assistant 模型推理,
	//  role = user 用户输入,
	//  role = history 历史上下文
	Role  public.ContentFilterRole  `json:"role"`
	Level public.ContentFilterLevel `json:"level"` // 严重程度 level 0-3,level 0表示最严重,3表示轻微
}

返回内容安全的相关信息

type Data

type Data struct {
	URL string `json:"url"` // 图片链接。图片的临时链接有效期为 30天,请及时转存图片
}

模型生成的图片

type Request

type Request struct {
	Model  public.Model `json:"model"`  // 要调用的模型编码
	Prompt string       `json:"prompt"` // 所需图像的文本描述
	// 图片尺寸, cogview-3-plus 、cogview-3-flash支持该参数。
	//   可选范围:[1024x1024,768x1344,864x1152,1344x768,1152x864,1440x720,720x1440],默认是1024x1024
	Size public.GenerateImageSize `json:"size,omitempty"`
	// 终端用户的唯一 ID
	//   帮助平台对终端用户的非法活动、生成非法不当信息或其他滥用行为进行干预;
	//   ID 长度要求:至少 6 个字符,最多 128 个字符
	UserID string `json:"user_id,omitempty"`
}

请求对象

func (*Request) Valid

func (r *Request) Valid() error

请求对象有效性验证

type Response

type Response struct {
	Created       uint64           `json:"created"`        // 请求创建时间,为 Unix 时间戳,单位为秒
	Data          []*Data          `json:"data"`           // 数组,包含生成的图片 URL。目前数组中只包含一张图片
	ContentFilter []*ContentFilter `json:"content_filter"` // 返回内容安全的相关信息
}

同步响应对象

Jump to

Keyboard shortcuts

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