Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions core/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5677,7 +5677,8 @@ const docTemplate = `{
55,
56,
57,
58
58,
59
],
"type": "integer",
"description": "Channel type",
Expand Down Expand Up @@ -12029,7 +12030,8 @@ const docTemplate = `{
55,
56,
57,
58
58,
59
],
"x-enum-varnames": [
"ChannelTypeOpenAI",
Expand Down Expand Up @@ -12077,7 +12079,8 @@ const docTemplate = `{
"ChannelTypeFakeError",
"ChannelTypeQwenCloud",
"ChannelTypeAIProxyHZH",
"ChannelTypeAIProxyUSW1"
"ChannelTypeAIProxyUSW1",
"ChannelTypeTokenDance"
]
},
"model.ChartData": {
Expand Down
9 changes: 6 additions & 3 deletions core/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5668,7 +5668,8 @@
55,
56,
57,
58
58,
59
],
"type": "integer",
"description": "Channel type",
Expand Down Expand Up @@ -12020,7 +12021,8 @@
55,
56,
57,
58
58,
59
],
"x-enum-varnames": [
"ChannelTypeOpenAI",
Expand Down Expand Up @@ -12068,7 +12070,8 @@
"ChannelTypeFakeError",
"ChannelTypeQwenCloud",
"ChannelTypeAIProxyHZH",
"ChannelTypeAIProxyUSW1"
"ChannelTypeAIProxyUSW1",
"ChannelTypeTokenDance"
]
},
"model.ChartData": {
Expand Down
3 changes: 3 additions & 0 deletions core/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1474,6 +1474,7 @@ definitions:
- 56
- 57
- 58
- 59
type: integer
x-enum-varnames:
- ChannelTypeOpenAI
Expand Down Expand Up @@ -1522,6 +1523,7 @@ definitions:
- ChannelTypeQwenCloud
- ChannelTypeAIProxyHZH
- ChannelTypeAIProxyUSW1
- ChannelTypeTokenDance
model.ChartData:
properties:
audio_input_amount:
Expand Down Expand Up @@ -7376,6 +7378,7 @@ paths:
- 56
- 57
- 58
- 59
in: path
name: type
required: true
Expand Down
2 changes: 2 additions & 0 deletions core/model/chtype.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const (
ChannelTypeQwenCloud ChannelType = 56
ChannelTypeAIProxyHZH ChannelType = 57
ChannelTypeAIProxyUSW1 ChannelType = 58
ChannelTypeTokenDance ChannelType = 59
)

var channelTypeNames = map[ChannelType]string{
Expand Down Expand Up @@ -107,4 +108,5 @@ var channelTypeNames = map[ChannelType]string{
ChannelTypeQwenCloud: "QwenCloud",
ChannelTypeAIProxyHZH: "AIProxy HZH",
ChannelTypeAIProxyUSW1: "AIProxy USW-1",
ChannelTypeTokenDance: "TokenDance",
}
47 changes: 47 additions & 0 deletions core/relay/adaptor/tokendance/adaptor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package tokendance

import (
"github.com/labring/aiproxy/core/model"
"github.com/labring/aiproxy/core/relay/adaptor"
"github.com/labring/aiproxy/core/relay/adaptor/openai"
"github.com/labring/aiproxy/core/relay/adaptor/registry"
"github.com/labring/aiproxy/core/relay/meta"
"github.com/labring/aiproxy/core/relay/mode"
)

type Adaptor struct {
openai.Adaptor
}

func init() {
registry.Register(model.ChannelTypeTokenDance, &Adaptor{})
}

func (a *Adaptor) DefaultBaseURL() string {
return "https://tokendance.space/gateway/v1"
}

func (a *Adaptor) SupportMode(mt *meta.Meta) bool {
m := adaptor.ModeFromMeta(mt)

return m == mode.ChatCompletions ||
m == mode.Responses ||
m == mode.Embeddings ||
m == mode.ImagesGenerations ||
m == mode.ImagesEdits ||
m == mode.Anthropic ||
m == mode.Gemini
}

func (a *Adaptor) Metadata() adaptor.Metadata {
return adaptor.Metadata{
KeyHelp: "Create an API key at https://tokendance.space/keys",
Readme: "TokenDance OpenAI-compatible API\n" +
"Supports chat completions, Responses, embeddings, image generation and editing\n" +
"Anthropic/Gemini requests are converted to OpenAI-compatible requests\n" +
"Configure model IDs with the corresponding OpenAI protocol in supported_protocols\n" +
"Model catalog: https://tokendance.space/gateway/v1/models\n" +
"Documentation: https://tokendance.space/docs/quickstart",
ConfigSchema: openai.ConfigSchema(),
}
}
1 change: 1 addition & 0 deletions core/relay/adaptors/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
_ "github.com/labring/aiproxy/core/relay/adaptor/streamlake"
_ "github.com/labring/aiproxy/core/relay/adaptor/tencent"
_ "github.com/labring/aiproxy/core/relay/adaptor/text-embeddings-inference"
_ "github.com/labring/aiproxy/core/relay/adaptor/tokendance"
_ "github.com/labring/aiproxy/core/relay/adaptor/vertexai"
_ "github.com/labring/aiproxy/core/relay/adaptor/xai"
_ "github.com/labring/aiproxy/core/relay/adaptor/xunfei"
Expand Down
Loading