huggingface

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: Apache-2.0 Imports: 3 Imported by: 7

Documentation

Overview

Package huggingface ai界的github, 常用参数

Index

Constants

View Source
const (
	// HuggingfaceSpaceHTTPS huggingface space https api
	HuggingfaceSpaceHTTPS = "https://hf.space"
	// Embed huggingface space api embed
	Embed = HuggingfaceSpaceHTTPS + "/embed"
	// HTTPSPushPath 推送队列
	HTTPSPushPath = Embed + "/%v/api/queue/push/"
	// HTTPSStatusPath 状态队列
	HTTPSStatusPath = Embed + "/%v/api/queue/status/"
	// HuggingfaceSpaceWss huggingface space wss api
	HuggingfaceSpaceWss = "wss://spaces.huggingface.tech"
	// WssJoinPath 推送队列2
	WssJoinPath = HuggingfaceSpaceWss + "/%v/queue/join"
	// HTTPSPredictPath 推送队列3
	HTTPSPredictPath = Embed + "/%v/api/predict/"
	// DefaultAction 默认动作
	DefaultAction = "predict"
	// CompleteStatus 完成状态
	CompleteStatus = "COMPLETE"
	// WssCompleteStatus 完成状态2
	WssCompleteStatus = "process_completed"
	// TimeoutMax 超时时间
	TimeoutMax = 300
)

Variables

This section is empty.

Functions

func Status

func Status(statusURL string, statusReq StatusRequest) (data []byte, err error)

Status 状态请求

Types

type PushRequest

type PushRequest struct {
	Action      string        `json:"action,omitempty"`
	FnIndex     int           `json:"fn_index"`
	Data        []interface{} `json:"data"`
	SessionHash string        `json:"session_hash"`
}

PushRequest 推送默认请求

type PushResponse

type PushResponse struct {
	Hash          string `json:"hash"`
	QueuePosition int    `json:"queue_position"`
}

PushResponse 推送默认响应

func Push

func Push(pushURL string, pushReq PushRequest) (pushRes PushResponse, err error)

Push 推送请求

type StatusRequest

type StatusRequest struct {
	Hash string `json:"hash"`
}

StatusRequest 状态默认请求

type StatusResponse

type StatusResponse struct {
	Status string `json:"status"`
	Data   struct {
		Data            []interface{} `json:"data"`
		Duration        float64       `json:"duration"`
		AverageDuration float64       `json:"average_duration"`
	}
}

StatusResponse 状态默认响应

Jump to

Keyboard shortcuts

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