xunfei

package
v0.0.0-...-d3d3e8a Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ModelList = []string{
	"SparkDesk",
	"SparkDesk-v1.1",
	"SparkDesk-v2.1",
	"SparkDesk-v3.1",
	"SparkDesk-v3.1-128K",
	"SparkDesk-v3.5",
	"SparkDesk-v3.5-32K",
	"SparkDesk-v4.0",
}

Functions

func Handler

func Handler(c *gin.Context, meta *meta.Meta, textRequest model.GeneralOpenAIRequest, appId string, apiSecret string, apiKey string) (*model.ErrorWithStatusCode, *model.Usage)

func StreamHandler

func StreamHandler(c *gin.Context, meta *meta.Meta, textRequest model.GeneralOpenAIRequest, appId string, apiSecret string, apiKey string) (*model.ErrorWithStatusCode, *model.Usage)

Types

type Adaptor

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

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 {
	Header struct {
		AppId string `json:"app_id"`
	} `json:"header"`
	Parameter struct {
		Chat struct {
			Domain      string   `json:"domain,omitempty"`
			Temperature *float64 `json:"temperature,omitempty"`
			TopK        int      `json:"top_k,omitempty"`
			MaxTokens   int      `json:"max_tokens,omitempty"`
			Auditing    bool     `json:"auditing,omitempty"`
		} `json:"chat"`
	} `json:"parameter"`
	Payload struct {
		Message struct {
			Text []Message `json:"text"`
		} `json:"message"`
		Functions *Functions `json:"functions,omitempty"`
	} `json:"payload"`
}

type ChatResponse

type ChatResponse struct {
	Header struct {
		Code    int    `json:"code"`
		Message string `json:"message"`
		Sid     string `json:"sid"`
		Status  int    `json:"status"`
	} `json:"header"`
	Payload struct {
		Choices struct {
			Status int                    `json:"status"`
			Seq    int                    `json:"seq"`
			Text   []ChatResponseTextItem `json:"text"`
		} `json:"choices"`
		Usage struct {
			//Text struct {
			//	QuestionTokens   string `json:"question_tokens"`
			//	PromptTokens     string `json:"prompt_tokens"`
			//	CompletionTokens string `json:"completion_tokens"`
			//	TotalTokens      string `json:"total_tokens"`
			//} `json:"text"`
			Text model.Usage `json:"text"`
		} `json:"usage"`
	} `json:"payload"`
}

type ChatResponseTextItem

type ChatResponseTextItem struct {
	Content      string          `json:"content"`
	Role         string          `json:"role"`
	Index        int             `json:"index"`
	ContentType  string          `json:"content_type"`
	FunctionCall *model.Function `json:"function_call"`
}

type Functions

type Functions struct {
	Text []model.Function `json:"text,omitempty"`
}

type Message

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

Jump to

Keyboard shortcuts

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