baidu

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ModelList = []string{
	"ERNIE-4.0-8K",
	"ERNIE-3.5-8K",
	"ERNIE-3.5-8K-0205",
	"ERNIE-3.5-8K-1222",
	"ERNIE-Bot-8K",
	"ERNIE-3.5-4K-0205",
	"ERNIE-Speed-8K",
	"ERNIE-Speed-128K",
	"ERNIE-Lite-8K-0922",
	"ERNIE-Lite-8K-0308",
	"ERNIE-Tiny-8K",
	"BLOOMZ-7B",
	"Embedding-V1",
	"bge-large-zh",
	"bge-large-en",
	"tao-8k",
}

Functions

func EmbeddingHandler

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

func GetAccessToken

func GetAccessToken(apiKey string) (string, error)

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 AccessToken

type AccessToken struct {
	AccessToken      string    `json:"access_token"`
	Error            string    `json:"error,omitempty"`
	ErrorDescription string    `json:"error_description,omitempty"`
	ExpiresIn        int64     `json:"expires_in,omitempty"`
	ExpiresAt        time.Time `json:"-"`
}

type Adaptor

type Adaptor struct {
}

func (*Adaptor) ConvertImageRequest

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

func (*Adaptor) ConvertRequest

func (a *Adaptor) ConvertRequest(c *gin.Context, relayMode int, request *model.GeneralOpenAIRequest) (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) 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.Meta)

func (*Adaptor) SetupRequestHeader

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

type ChatRequest

type ChatRequest struct {
	Messages        []Message `json:"messages"`
	Temperature     *float64  `json:"temperature,omitempty"`
	TopP            *float64  `json:"top_p,omitempty"`
	PenaltyScore    *float64  `json:"penalty_score,omitempty"`
	Stream          bool      `json:"stream,omitempty"`
	System          string    `json:"system,omitempty"`
	DisableSearch   bool      `json:"disable_search,omitempty"`
	EnableCitation  bool      `json:"enable_citation,omitempty"`
	MaxOutputTokens int       `json:"max_output_tokens,omitempty"`
	UserId          string    `json:"user_id,omitempty"`
}

func ConvertRequest

func ConvertRequest(request model.GeneralOpenAIRequest) *ChatRequest

type ChatResponse

type ChatResponse struct {
	Id               string      `json:"id"`
	Object           string      `json:"object"`
	Created          int64       `json:"created"`
	Result           string      `json:"result"`
	IsTruncated      bool        `json:"is_truncated"`
	NeedClearHistory bool        `json:"need_clear_history"`
	Usage            model.Usage `json:"usage"`
	Error
}

type ChatStreamResponse

type ChatStreamResponse struct {
	ChatResponse
	SentenceId int  `json:"sentence_id"`
	IsEnd      bool `json:"is_end"`
}

type EmbeddingData

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

type EmbeddingRequest

type EmbeddingRequest struct {
	Input []string `json:"input"`
}

func ConvertEmbeddingRequest

func ConvertEmbeddingRequest(request model.GeneralOpenAIRequest) *EmbeddingRequest

type EmbeddingResponse

type EmbeddingResponse struct {
	Id      string          `json:"id"`
	Object  string          `json:"object"`
	Created int64           `json:"created"`
	Data    []EmbeddingData `json:"data"`
	Usage   model.Usage     `json:"usage"`
	Error
}

type Error

type Error struct {
	ErrorCode int    `json:"error_code"`
	ErrorMsg  string `json:"error_msg"`
}

type Message

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

type TokenResponse

type TokenResponse struct {
	ExpiresIn   int    `json:"expires_in"`
	AccessToken string `json:"access_token"`
}

Jump to

Keyboard shortcuts

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