coze

package
v0.0.0-...-784514d Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ModelList = []string{}

Functions

func Handler

func Handler(c *gin.Context, resp *http.Response, promptTokens int, modelName string) (*model.ErrorWithStatusCode, *string)

func ResponseCoze2OpenAI

func ResponseCoze2OpenAI(cozeResponse *Response) *openai.TextResponse

func StreamHandler

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

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 ErrorInformation

type ErrorInformation struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

type Message

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

type Request

type Request struct {
	ConversationId string    `json:"conversation_id,omitempty"`
	BotId          string    `json:"bot_id"`
	User           string    `json:"user"`
	Query          string    `json:"query"`
	ChatHistory    []Message `json:"chat_history,omitempty"`
	Stream         bool      `json:"stream"`
}

func ConvertRequest

func ConvertRequest(textRequest model.GeneralOpenAIRequest) *Request

type Response

type Response struct {
	ConversationId string    `json:"conversation_id,omitempty"`
	Messages       []Message `json:"messages,omitempty"`
	Code           int       `json:"code,omitempty"`
	Msg            string    `json:"msg,omitempty"`
}

func StreamResponseCoze2OpenAI

func StreamResponseCoze2OpenAI(cozeResponse *StreamResponse) (*openai.ChatCompletionsStreamResponse, *Response)

type StreamResponse

type StreamResponse struct {
	Event            string            `json:"event,omitempty"`
	Message          *Message          `json:"message,omitempty"`
	IsFinish         bool              `json:"is_finish,omitempty"`
	Index            int               `json:"index,omitempty"`
	ConversationId   string            `json:"conversation_id,omitempty"`
	ErrorInformation *ErrorInformation `json:"error_information,omitempty"`
}

Directories

Path Synopsis
constant

Jump to

Keyboard shortcuts

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