mirror of
https://github.com/alibaba/higress.git
synced 2026-05-08 04:17:27 +08:00
add textin embedding for ai-cache (#1493)
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
const (
|
||||
PROVIDER_TYPE_DASHSCOPE = "dashscope"
|
||||
PROVIDER_TYPE_TEXTIN = "textin"
|
||||
)
|
||||
|
||||
type providerInitializer interface {
|
||||
@@ -19,6 +20,7 @@ type providerInitializer interface {
|
||||
var (
|
||||
providerInitializers = map[string]providerInitializer{
|
||||
PROVIDER_TYPE_DASHSCOPE: &dashScopeProviderInitializer{},
|
||||
PROVIDER_TYPE_TEXTIN: &textInProviderInitializer{},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -38,6 +40,15 @@ type ProviderConfig struct {
|
||||
// @Title zh-CN 文本特征提取服务 API Key
|
||||
// @Description zh-CN 文本特征提取服务 API Key
|
||||
apiKey string
|
||||
//@Title zh-CN TextIn x-ti-app-id
|
||||
// @Description zh-CN 仅适用于 TextIn 服务。参考 https://www.textin.com/document/acge_text_embedding
|
||||
textinAppId string
|
||||
//@Title zh-CN TextIn x-ti-secret-code
|
||||
// @Description zh-CN 仅适用于 TextIn 服务。参考 https://www.textin.com/document/acge_text_embedding
|
||||
textinSecretCode string
|
||||
//@Title zh-CN TextIn request matryoshka_dim
|
||||
// @Description zh-CN 仅适用于 TextIn 服务, 指定返回的向量维度。参考 https://www.textin.com/document/acge_text_embedding
|
||||
textinMatryoshkaDim int
|
||||
// @Title zh-CN 文本特征提取服务超时时间
|
||||
// @Description zh-CN 文本特征提取服务超时时间
|
||||
timeout uint32
|
||||
@@ -52,6 +63,9 @@ func (c *ProviderConfig) FromJson(json gjson.Result) {
|
||||
c.serviceHost = json.Get("serviceHost").String()
|
||||
c.servicePort = json.Get("servicePort").Int()
|
||||
c.apiKey = json.Get("apiKey").String()
|
||||
c.textinAppId = json.Get("textinAppId").String()
|
||||
c.textinSecretCode = json.Get("textinSecretCode").String()
|
||||
c.textinMatryoshkaDim = int(json.Get("textinMatryoshkaDim").Int())
|
||||
c.timeout = uint32(json.Get("timeout").Int())
|
||||
c.model = json.Get("model").String()
|
||||
if c.timeout == 0 {
|
||||
@@ -63,9 +77,6 @@ func (c *ProviderConfig) Validate() error {
|
||||
if c.serviceName == "" {
|
||||
return errors.New("embedding service name is required")
|
||||
}
|
||||
if c.apiKey == "" {
|
||||
return errors.New("embedding service API key is required")
|
||||
}
|
||||
if c.typ == "" {
|
||||
return errors.New("embedding service type is required")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user