tencent

package
v1.0.4-preview.3 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: AGPL-3.0 Imports: 21 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChannelName = "tencent"
View Source
var ModelList = []string{
	"hunyuan-lite",
	"hunyuan-standard",
	"hunyuan-standard-256K",
	"hunyuan-pro",
}

Functions

This section is empty.

Types

type Adaptor

type Adaptor struct {
	Sign      string
	AppID     int64
	Action    string
	Version   string
	Timestamp int64
}

func (*Adaptor) ConvertAudioRequest

func (a *Adaptor) ConvertAudioRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.AudioRequest) (io.Reader, error)

func (*Adaptor) ConvertClaudeRequest

func (a *Adaptor) ConvertClaudeRequest(*gin.Context, *relaycommon.RelayInfo, *dto.ClaudeRequest) (any, error)

func (*Adaptor) ConvertEmbeddingRequest

func (a *Adaptor) ConvertEmbeddingRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.EmbeddingRequest) (any, error)

func (*Adaptor) ConvertGeminiRequest

func (a *Adaptor) ConvertGeminiRequest(*gin.Context, *relaycommon.RelayInfo, *dto.GeminiChatRequest) (any, error)

func (*Adaptor) ConvertImageRequest

func (a *Adaptor) ConvertImageRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.ImageRequest) (any, error)

func (*Adaptor) ConvertOpenAIRequest

func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayInfo, request *dto.GeneralOpenAIRequest) (any, error)

func (*Adaptor) ConvertOpenAIResponsesRequest

func (a *Adaptor) ConvertOpenAIResponsesRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.OpenAIResponsesRequest) (any, error)

func (*Adaptor) ConvertRerankRequest

func (a *Adaptor) ConvertRerankRequest(c *gin.Context, relayMode int, request dto.RerankRequest) (any, error)

func (*Adaptor) DoRequest

func (a *Adaptor) DoRequest(c *gin.Context, info *relaycommon.RelayInfo, requestBody io.Reader) (any, error)

func (*Adaptor) DoResponse

func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, info *relaycommon.RelayInfo) (usage any, err *types.MaxAPIError)

func (*Adaptor) GetChannelName

func (a *Adaptor) GetChannelName() string

func (*Adaptor) GetModelList

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

func (*Adaptor) GetRequestURL

func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error)

func (*Adaptor) Init

func (a *Adaptor) Init(info *relaycommon.RelayInfo)

func (*Adaptor) SetupRequestHeader

func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Header, info *relaycommon.RelayInfo) error

type TencentChatRequest

type TencentChatRequest struct {
	// 模型名称,可选值包括 hunyuan-lite、hunyuan-standard、hunyuan-standard-256K、hunyuan-pro。
	// 各模型介绍请阅读 [产品概述](https://cloud.tencent.com/document/product/1729/104753) 中的说明。
	//
	// 注意:
	// 不同的模型计费不同,请根据 [购买指南](https://cloud.tencent.com/document/product/1729/97731) 按需调用。
	Model *string `json:"Model"`
	// 聊天上下文信息。
	// 说明:
	// 1. 长度最多为 40,按对话时间从旧到新在数组中排列。
	// 2. Message.Role 可选值:system、user、assistant。
	// 其中,system 角色可选,如存在则必须位于列表的最开始。user 和 assistant 需交替出现(一问一答),以 user 提问开始和结束,且 Content 不能为空。Role 的顺序示例:[system(可选) user assistant user assistant user ...]。
	// 3. Messages 中 Content 总长度不能超过模型输入长度上限(可参考 [产品概述](https://cloud.tencent.com/document/product/1729/104753) 文档),超过则会截断最前面的内容,只保留尾部内容。
	Messages []*TencentMessage `json:"Messages"`
	// 流式调用开关。
	// 说明:
	// 1. 未传值时默认为非流式调用(false)。
	// 2. 流式调用时以 SSE 协议增量返回结果(返回值取 Choices[n].Delta 中的值,需要拼接增量数据才能获得完整结果)。
	// 3. 非流式调用时:
	// 调用方式与普通 HTTP 请求无异。
	// 接口响应耗时较长,**如需更低时延建议设置为 true**。
	// 只返回一次最终结果(返回值取 Choices[n].Message 中的值)。
	//
	// 注意:
	// 通过 SDK 调用时,流式和非流式调用需用**不同的方式**获取返回值,具体参考 SDK 中的注释或示例(在各语言 SDK 代码仓库的 examples/hunyuan/v20230901/ 目录中)。
	Stream *bool `json:"Stream,omitempty"`
	// 说明:
	// 1. 影响输出文本的多样性,取值越大,生成文本的多样性越强。
	// 2. 取值区间为 [0.0, 1.0],未传值时使用各模型推荐值。
	// 3. 非必要不建议使用,不合理的取值会影响效果。
	TopP *float64 `json:"TopP,omitempty"`
	// 说明:
	// 1. 较高的数值会使输出更加随机,而较低的数值会使其更加集中和确定。
	// 2. 取值区间为 [0.0, 2.0],未传值时使用各模型推荐值。
	// 3. 非必要不建议使用,不合理的取值会影响效果。
	Temperature *float64 `json:"Temperature,omitempty"`
}

type TencentChatResponse

type TencentChatResponse struct {
	Choices []TencentResponseChoices `json:"Choices,omitempty"` // 结果
	Created int64                    `json:"Created,omitempty"` // unix 时间戳的字符串
	Id      string                   `json:"Id,omitempty"`      // 会话 id
	Usage   TencentUsage             `json:"Usage,omitempty"`   // token 数量
	Error   TencentError             `json:"Error,omitempty"`   // 错误信息 注意:此字段可能返回 null,表示取不到有效值
	Note    string                   `json:"Note,omitempty"`    // 注释
	ReqID   string                   `json:"Req_id,omitempty"`  // 唯一请求 Id,每次请求都会返回。用于反馈接口入参
}

type TencentChatResponseSB

type TencentChatResponseSB struct {
	Response TencentChatResponse `json:"Response,omitempty"`
}

type TencentError

type TencentError struct {
	Code    int    `json:"Code"`
	Message string `json:"Message"`
}

type TencentMessage

type TencentMessage struct {
	Role    string `json:"Role"`
	Content string `json:"Content"`
}

type TencentResponseChoices

type TencentResponseChoices struct {
	FinishReason string         `json:"FinishReason,omitempty"` // 流式结束标志位,为 stop 则表示尾包
	Messages     TencentMessage `json:"Message,omitempty"`      // 内容,同步模式返回内容,流模式为 null 输出 content 内容总数最多支持 1024token。
	Delta        TencentMessage `json:"Delta,omitempty"`        // 内容,流模式返回内容,同步模式为 null 输出 content 内容总数最多支持 1024token。
}

type TencentUsage

type TencentUsage struct {
	PromptTokens     int `json:"PromptTokens"`
	CompletionTokens int `json:"CompletionTokens"`
	TotalTokens      int `json:"TotalTokens"`
}

Jump to

Keyboard shortcuts

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