client

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GatewayBase = "https://console.echojoy.cn/gateway"
	FileService = "https://file.echojoy.cn"
	// MaxUploadBytes matches the guaranteed single-file capacity of the
	// pre-signed cloud-storage upload path.
	MaxUploadBytes int64 = 1024 * 1024 * 1024
)

Variables

This section is empty.

Functions

func ExtractResultURLs

func ExtractResultURLs(body []byte) ([]string, error)

ExtractResultURLs returns media URLs from a Gateway task envelope. Gateway providers use slightly different result shapes, so URLs are collected from conventional URL-named fields recursively and de-duplicated in encounter order.

Types

type ChatMessage

type ChatMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

type Client

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

func New

func New(token string) *Client

func NewWithBaseURL

func NewWithBaseURL(token, baseURL string) *Client

NewWithBaseURL creates a client for an alternate Gateway endpoint. It keeps HTTP integration tests isolated and is also useful for self-hosted gateways.

func NewWithEndpoints

func NewWithEndpoints(token, baseURL, fileServiceURL string) *Client

NewWithEndpoints creates a client with explicit Gateway and file-service URLs. It exists for self-hosted deployments and HTTP integration tests.

func (*Client) Chat

func (c *Client) Chat(ctx context.Context, modelID string, apiFormat string, messages []ChatMessage, params map[string]any) (string, error)

func (*Client) Download

func (c *Client) Download(ctx context.Context, url, path string) error

func (*Client) GetTask

func (c *Client) GetTask(ctx context.Context, taskID string) ([]byte, error)

GetTask returns the Gateway task envelope without submitting new work.

func (*Client) ListModels

func (c *Client) ListModels(ctx context.Context) ([]GatewayModel, error)

func (*Client) MediaEndpoint

func (c *Client) MediaEndpoint(path string) string

func (*Client) PollTask

func (c *Client) PollTask(ctx context.Context, taskID string, interval, maxSeconds int) ([]byte, error)

func (*Client) SubmitTask

func (c *Client) SubmitTask(ctx context.Context, endpoint, modelID string, inputData map[string]any) (string, error)

func (*Client) UploadFile

func (c *Client) UploadFile(ctx context.Context, name, localPath string) (string, error)

UploadFile 通过 AssetHub 预签名流程上传本地文件并返回下载直链: init →(未命中去重时)PUT 预签名 URL → completion → link。

type ErrorDetail

type ErrorDetail struct {
	Code      string
	Message   string
	RequestID string
}

func ErrorDetails

func ErrorDetails(err error) ErrorDetail

ErrorDetails exposes only safe, user-actionable upstream error fields.

type Feature

type Feature struct {
	MatchFields []string `json:"match_fields"`
}

type GatewayError

type GatewayError struct {
	Status int
	ErrorDetail
}

func (*GatewayError) Error

func (e *GatewayError) Error() string

type GatewayModel

type GatewayModel struct {
	ID           string             `json:"id"`
	Object       string             `json:"object"`
	ModelType    string             `json:"model_type"`
	ModelID      string             `json:"model_id"`
	DisplayName  string             `json:"display_name"`
	APIFormat    string             `json:"api_format,omitempty"`
	InputSchema  json.RawMessage    `json:"input_schema,omitempty"`
	FeatureTypes map[string]Feature `json:"feature_types,omitempty"`
}

type ModelListResponse

type ModelListResponse struct {
	Object  string         `json:"object"`
	Data    []GatewayModel `json:"data"`
	HasMore bool           `json:"has_more"`
}

Jump to

Keyboard shortcuts

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