zhipu

package
v0.0.0-...-d98d1a9 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ModelList = []string{
	"chatglm_turbo", "chatglm_pro", "chatglm_std", "chatglm_lite",
	"glm-4", "glm-4v", "glm-3-turbo", "embedding-2",
	"cogview-3",
}

Functions

func EmbeddingsHandler

func EmbeddingsHandler(c *gin.Context, resp *http.Response) (*model.ErrorWithStatusCode, *model.Usage)

func GetToken

func GetToken(apikey string) string

func Handler

func Handler(c *gin.Context, resp *http.Response) (*model.ErrorWithStatusCode, *model.Usage)

func StreamHandler

func StreamHandler(c *gin.Context, resp *http.Response) (*model.ErrorWithStatusCode, *model.Usage)

Types

type Adaptor

type Adaptor struct {
	APIVersion string
}

func (*Adaptor) ConvertImageRequest

func (a *Adaptor) ConvertImageRequest(request *model.ImageRequest) (any, error)

func (*Adaptor) ConvertRequest

func (a *Adaptor) ConvertRequest(_ *gin.Context, relayMode int, request *model.GeneralOpenAIRequest) (any, error)

func (*Adaptor) ConvertSTTRequest

func (a *Adaptor) ConvertSTTRequest(*http.Request) (io.ReadCloser, error)

func (*Adaptor) ConvertTTSRequest

func (a *Adaptor) ConvertTTSRequest(*model.TextToSpeechRequest) (any, error)

func (*Adaptor) DoRequest

func (a *Adaptor) DoRequest(c *gin.Context, meta *meta.Meta, requestBody io.Reader) (*http.Response, error)

func (*Adaptor) DoResponse

func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, meta *meta.Meta) (usage *model.Usage, err *model.ErrorWithStatusCode)

func (*Adaptor) DoResponseV4

func (a *Adaptor) DoResponseV4(c *gin.Context, resp *http.Response, meta *meta.Meta) (usage *model.Usage, err *model.ErrorWithStatusCode)

func (*Adaptor) GetChannelName

func (a *Adaptor) GetChannelName() string

func (*Adaptor) GetModelList

func (a *Adaptor) GetModelList() []string

func (*Adaptor) GetRequestURL

func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error)

func (*Adaptor) Init

func (a *Adaptor) Init(_ *meta.Meta)

func (*Adaptor) SetVersionByModeName

func (a *Adaptor) SetVersionByModeName(modelName string)

func (*Adaptor) SetupRequestHeader

func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Request, meta *meta.Meta) error

type EmbeddingData

type EmbeddingData struct {
	Object    string    `json:"object"`
	Embedding []float64 `json:"embedding"`
	Index     int       `json:"index"`
}

type EmbeddingRequest

type EmbeddingRequest struct {
	Input any    `json:"input"`
	Model string `json:"model"`
}

func ConvertEmbeddingRequest

func ConvertEmbeddingRequest(request model.GeneralOpenAIRequest) (*EmbeddingRequest, error)

type EmbeddingResponse

type EmbeddingResponse struct {
	Model       string          `json:"model"`
	Object      string          `json:"object"`
	Embeddings  []EmbeddingData `json:"data"`
	model.Usage `json:"usage"`
}

type ImageRequest

type ImageRequest struct {
	Model  string `json:"model"`
	Prompt string `json:"prompt"`
	UserID string `json:"user_id,omitempty"`
}

type Request

type Request struct {
	Temperature *float64        `json:"temperature,omitempty"`
	TopP        *float64        `json:"top_p,omitempty"`
	RequestID   string          `json:"request_id,omitempty"`
	Prompt      []model.Message `json:"prompt"`
	Incremental bool            `json:"incremental,omitempty"`
}

func ConvertRequest

func ConvertRequest(request *model.GeneralOpenAIRequest) *Request

type Response

type Response struct {
	Msg     string       `json:"msg"`
	Data    ResponseData `json:"data"`
	Code    int          `json:"code"`
	Success bool         `json:"success"`
}

type ResponseData

type ResponseData struct {
	TaskID      string          `json:"task_id"`
	RequestID   string          `json:"request_id"`
	TaskStatus  string          `json:"task_status"`
	Choices     []model.Message `json:"choices"`
	model.Usage `json:"usage"`
}

type StreamMetaResponse

type StreamMetaResponse struct {
	RequestID   string `json:"request_id"`
	TaskID      string `json:"task_id"`
	TaskStatus  string `json:"task_status"`
	model.Usage `json:"usage"`
}

Jump to

Keyboard shortcuts

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