mirror of
https://github.com/songquanpeng/one-api.git
synced 2026-03-04 02:34:25 +08:00
Compare commits
13 Commits
b19a6d7cfe
...
d71dc3ca09
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d71dc3ca09 | ||
|
|
7e51b04221 | ||
|
|
f75a17f8eb | ||
|
|
6f13a3bb3c | ||
|
|
f092eed1db | ||
|
|
629378691b | ||
|
|
3716e1b0e6 | ||
|
|
a4d6e7a886 | ||
|
|
664f7ba676 | ||
|
|
a4c6ac8cf2 | ||
|
|
9fab3d00b4 | ||
|
|
0a49508f0f | ||
|
|
dc2cf8297a |
1
.computenest/.computenest_parameters.yaml
Normal file
1
.computenest/.computenest_parameters.yaml
Normal file
@@ -0,0 +1 @@
|
||||
{"ServicePort":"80","SecurityPorts":[80],"RepoName":"hanans426/one-api","Arch":"EcsSingle","RunCommand":"echo \"start run command\"\necho \"${AdminPassword}\"\n","SourceCodePath":".","CommandTimeout":3600,"ServiceType":"private","AllowedRegions":["cn-hangzhou","cn-shanghai","cn-beijing"],"ArtifactSourceType":"SourceCode","ImageId":"centos_7_9_x64_20G_alibase_20230613.vhd","RegionId":"cn-hangzhou","CustomParameters":[{"NoEcho":true,"Type":"String","AssociationProperty":"ALIYUN::ECS::Instance::Password","Label":"管理员密码","Name":"AdminPassword"}]}
|
||||
21
.computenest/README.md
Normal file
21
.computenest/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# 代码仓库结构
|
||||
|
||||
## 文档目录说明:
|
||||
```
|
||||
.
|
||||
├── README.md - README
|
||||
├── docs - 服务文档相关文件
|
||||
│ └── index.md
|
||||
├── resources - 服务资源文件
|
||||
│ ├── icons
|
||||
│ │ └── service_logo.png - 服务logo
|
||||
│ └── artifact_resources - 部署物相关资源文件
|
||||
├── ros_templates - 服务ROS模板目录,支持多模板
|
||||
│ └── template.yaml - ROS模板,ROS模板引擎根据该模板会自动创建出所有的资源
|
||||
├── config.yaml - 服务配置文件,服务构建过程中会使用计算巢命令行工具computenest-cli,computenest-cli会基于该配置文件构建服务
|
||||
├── preset_parameters.yaml - (该文件只有托管版有)服务商预设参数,如VpcId,VSwitchId等,该ros模板内容会渲染为表单方便服务商填写
|
||||
```
|
||||
|
||||
## 其他
|
||||
关于ROS模板,请参见 [资源编排](https://help.aliyun.com/zh/ros)。
|
||||
关于computenest-cli请参见 [computenest-cli](https://pypi.org/project/computenest-cli/)。
|
||||
28
.computenest/config.yaml
Normal file
28
.computenest/config.yaml
Normal file
@@ -0,0 +1,28 @@
|
||||
Service:
|
||||
RegionId: cn-hangzhou
|
||||
DeployType: ros
|
||||
DeployMetadata:
|
||||
SupplierDeployMetadata:
|
||||
FileArtifactRelation:
|
||||
'{{ computenest::file::hanans426_one-api }}':
|
||||
ArtifactId: ${Artifact.Artifact_1.ArtifactId}
|
||||
ArtifactVersion: ${Artifact.Artifact_1.ArtifactVersion}
|
||||
TemplateConfigs:
|
||||
- Name: 单机版
|
||||
Url: 'ros_templates/template.yaml'
|
||||
AllowedRegions:
|
||||
- cn-hangzhou
|
||||
- cn-shanghai
|
||||
- cn-beijing
|
||||
ServiceType: private
|
||||
ServiceInfo:
|
||||
Locale: zh-CN
|
||||
ShortDescription: demo
|
||||
Image: 'resources/icons/service_logo.png'
|
||||
Artifact:
|
||||
Artifact_1:
|
||||
ArtifactType: File
|
||||
ArtifactName: hanans426_one-api
|
||||
ArtifactProperty:
|
||||
RegionId: cn-hangzhou
|
||||
Url: 'resources/artifact_resources/file/hanans426_one-api.tar.gz'
|
||||
BIN
.computenest/docs/architecture_ecs_single.png
Normal file
BIN
.computenest/docs/architecture_ecs_single.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 280 KiB |
70
.computenest/docs/index_ecs_single.md
Normal file
70
.computenest/docs/index_ecs_single.md
Normal file
@@ -0,0 +1,70 @@
|
||||
# 服务模板说明文档
|
||||
|
||||
## 服务说明
|
||||
|
||||
**简单描述服务的功能和用途。**
|
||||
例如:
|
||||
_(服务功能描述,如“WordPress 是一款免费开源的 CMS,适用于创建和管理各种类型的网站。”)_
|
||||
|
||||
_(服务快速上手链接或文档,如果有的话)_
|
||||
|
||||
## 服务架构
|
||||
|
||||
此服务模板构建出的服务的部署架构为单机ecs部署。
|
||||
|
||||
<img src="architecture_ecs_single.png" width="600" height="400" align="bottom"/>
|
||||
|
||||
## 计费说明
|
||||
通过此服务模板构建服务不产生费用。
|
||||
用户部署构建出的服务时,资源费用主要涉及:
|
||||
- 所选ECS实例规格
|
||||
- 磁盘容量
|
||||
- 公网带宽
|
||||
|
||||
计费方式包括:
|
||||
- 按量付费(小时)
|
||||
- 包年包月
|
||||
|
||||
预估费用在部署前可实时看到。
|
||||
|
||||
## RAM账号所需权限
|
||||
|
||||
此服务模板构建出的服务需要对ECS、VPC等资源进行访问和创建操作,若使用RAM用户创建服务实例,需要在创建服务实例前,对使用的RAM用户的账号添加相应资源的权限。添加RAM权限的详细操作,请参见[为RAM用户授权](https://help.aliyun.com/document_detail/121945.html)。所需权限如下表所示:
|
||||
|
||||
| 权限策略名称 | 备注 |
|
||||
|-------------------------------------|-------------------------------|
|
||||
| AliyunECSFullAccess | 管理云服务器服务(ECS)的权限 |
|
||||
| AliyunVPCFullAccess | 管理专有网络(VPC)的权限 |
|
||||
| AliyunROSFullAccess | 管理资源编排服务(ROS)的权限 |
|
||||
| AliyunComputeNestUserFullAccess | 管理计算巢服务(ComputeNest)的用户侧权限 |
|
||||
| AliyunComputeNestSupplierFullAccess | 管理计算巢服务(ComputeNest)的服务商侧权限 | |
|
||||
|
||||
## 服务实例计费说明
|
||||
|
||||
**详细说明服务实例的计费方式。**
|
||||
_(描述费用构成,例如所选 vCPU 和内存规格,系统盘类型和容量等)_
|
||||
|
||||
_(列出计费方式,例如按量付费或包年包月)_
|
||||
|
||||
## 服务实例部署流程
|
||||
|
||||
### 部署参数说明
|
||||
|
||||
| 参数组 | 参数项 | 说明 |
|
||||
|---------------------------------|--------|-------------------------------------------------------------------------|
|
||||
| 服务实例 | 服务实例名称 | 长度不超过64个字符,必须以英文字母开头,可包含数字、英文字母、短划线(-)和下划线(_)。 |
|
||||
| | 地域 | 服务实例部署的地域。 |
|
||||
| | 付费类型 | 资源的计费类型:按量付费和包年包月。 |
|
||||
| ECS实例配置 | 实例类型 | ECS实例规格配置。 |
|
||||
| | 实例密码 | 长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*-+=|{}[]:;'<>,.?/ 中的特殊符号)。 |
|
||||
| 网络配置 | 可用区 | ECS实例所在可用区。 |
|
||||
|
||||
### 部署步骤
|
||||
|
||||
**简述如何一步步部署服务实例。**
|
||||
|
||||
1. _(步骤1描述和相关链接或图片,如果有的话)_
|
||||
2. _(步骤2描述和相关链接或图片,如果有的话)_
|
||||
...
|
||||
|
||||
[部署链接](部署链接地址)
|
||||
Binary file not shown.
BIN
.computenest/resources/icons/service_logo.png
Normal file
BIN
.computenest/resources/icons/service_logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
218
.computenest/ros_templates/template.yaml
Normal file
218
.computenest/ros_templates/template.yaml
Normal file
@@ -0,0 +1,218 @@
|
||||
ROSTemplateFormatVersion: '2015-09-01'
|
||||
Description:
|
||||
en: Source Code Service Ros Template
|
||||
zh-cn: 源代码服务模板
|
||||
Parameters:
|
||||
PayType:
|
||||
Type: String
|
||||
Label:
|
||||
en: ECS Instance Charge Type
|
||||
zh-cn: 付费类型
|
||||
Default: PostPaid
|
||||
AllowedValues:
|
||||
- PostPaid
|
||||
- PrePaid
|
||||
AssociationProperty: ChargeType
|
||||
AssociationPropertyMetadata:
|
||||
LocaleKey: InstanceChargeType
|
||||
PayPeriodUnit:
|
||||
Type: String
|
||||
Label:
|
||||
en: Pay Period Unit
|
||||
zh-cn: 购买资源时长周期
|
||||
Default: Month
|
||||
AllowedValues:
|
||||
- Month
|
||||
- Year
|
||||
AssociationProperty: PayPeriodUnit
|
||||
AssociationPropertyMetadata:
|
||||
Visible:
|
||||
Condition:
|
||||
Fn::Not:
|
||||
Fn::Equals:
|
||||
- ${PayType}
|
||||
- PostPaid
|
||||
PayPeriod:
|
||||
Type: Number
|
||||
Label:
|
||||
en: Period
|
||||
zh-cn: 购买资源时长
|
||||
Default: 1
|
||||
AllowedValues:
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
- 4
|
||||
- 5
|
||||
- 6
|
||||
- 7
|
||||
- 8
|
||||
- 9
|
||||
AssociationProperty: PayPeriod
|
||||
AssociationPropertyMetadata:
|
||||
Visible:
|
||||
Condition:
|
||||
Fn::Not:
|
||||
Fn::Equals:
|
||||
- ${PayType}
|
||||
- PostPaid
|
||||
EcsInstanceType:
|
||||
Type: String
|
||||
Label:
|
||||
en: Instance Type
|
||||
zh-cn: 实例类型
|
||||
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
|
||||
AssociationPropertyMetadata:
|
||||
InstanceChargeType: ${PayType}
|
||||
Constraints:
|
||||
InstanceTypeFamily:
|
||||
- ecs.u1
|
||||
- ecs.e
|
||||
InstancePassword:
|
||||
NoEcho: true
|
||||
Type: String
|
||||
Description:
|
||||
en: Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
|
||||
zh-cn: 服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)
|
||||
AllowedPattern: '^[a-zA-Z0-9-\(\)\`\~\!\@\#\$\%\^\&\*\_\-\+\=\|\{\}\[\]\:\;\<\>\,\.\?\/]*$'
|
||||
Label:
|
||||
en: Instance Password
|
||||
zh-cn: 实例密码
|
||||
ConstraintDescription:
|
||||
en: Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
|
||||
zh-cn: 长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)
|
||||
MinLength: 8
|
||||
MaxLength: 30
|
||||
AssociationProperty: ALIYUN::ECS::Instance::Password
|
||||
ZoneId:
|
||||
Type: String
|
||||
Label:
|
||||
en: Zone ID
|
||||
zh-cn: 可用区ID
|
||||
AssociationProperty: ALIYUN::ECS::Instance::ZoneId
|
||||
VpcId:
|
||||
Type: String
|
||||
Label:
|
||||
en: VPC ID
|
||||
zh-cn: 专有网络VPC实例ID
|
||||
AssociationProperty: 'ALIYUN::ECS::VPC::VPCId'
|
||||
VSwitchId:
|
||||
Type: String
|
||||
Label:
|
||||
en: VSwitch ID
|
||||
zh-cn: 交换机实例ID
|
||||
Default: ''
|
||||
AssociationProperty: 'ALIYUN::ECS::VSwitch::VSwitchId'
|
||||
AssociationPropertyMetadata:
|
||||
VpcId: VpcId
|
||||
ZoneId: ZoneId
|
||||
AdminPassword:
|
||||
Type: String
|
||||
AssociationProperty: ALIYUN::ECS::Instance::Password
|
||||
Label: 管理员密码
|
||||
NoEcho: True
|
||||
Resources:
|
||||
SecurityGroup:
|
||||
Type: ALIYUN::ECS::SecurityGroup
|
||||
Properties:
|
||||
SecurityGroupName:
|
||||
Ref: ALIYUN::StackName
|
||||
VpcId:
|
||||
Ref: VpcId
|
||||
SecurityGroupIngress:
|
||||
- PortRange: 80/80
|
||||
Priority: 1
|
||||
SourceCidrIp: 0.0.0.0/0
|
||||
IpProtocol: tcp
|
||||
NicType: internet
|
||||
InstanceGroup:
|
||||
Type: ALIYUN::ECS::InstanceGroup
|
||||
Properties:
|
||||
# 付费类型
|
||||
InstanceChargeType:
|
||||
Ref: PayType
|
||||
PeriodUnit:
|
||||
Ref: PayPeriodUnit
|
||||
Period:
|
||||
Ref: PayPeriod
|
||||
VpcId:
|
||||
Ref: VpcId
|
||||
VSwitchId:
|
||||
Ref: VSwitchId
|
||||
ZoneId:
|
||||
Ref: ZoneId
|
||||
SecurityGroupId:
|
||||
Ref: SecurityGroup
|
||||
ImageId: centos_7_9_x64_20G_alibase_20230613.vhd
|
||||
Password:
|
||||
Ref: InstancePassword
|
||||
InstanceType:
|
||||
Ref: EcsInstanceType
|
||||
SystemDiskCategory: cloud_essd
|
||||
SystemDiskSize: 200
|
||||
InternetMaxBandwidthOut: 5
|
||||
IoOptimized: optimized
|
||||
MaxAmount: 1
|
||||
RunInstallCommand:
|
||||
Type: ALIYUN::ECS::RunCommand
|
||||
Properties:
|
||||
InstanceIds:
|
||||
Fn::GetAtt:
|
||||
- InstanceGroup
|
||||
- InstanceIds
|
||||
Type: RunShellScript
|
||||
Sync: true
|
||||
Timeout: 3600
|
||||
CommandContent:
|
||||
Fn::Sub:
|
||||
- |
|
||||
#!/bin/bash
|
||||
# 源代码通过computenest-cli被打包为tar.gz包,并发布为部署物
|
||||
wget '{{ computenest::file::hanans426_one-api }}' -O hanans426_one-api.tar.gz > /var/log/download.log
|
||||
tar -zxvf hanans426_one-api.tar.gz && cd "$(tar -tzf hanans426_one-api.tar.gz | head -1 | awk -F'/' '{print $1}')"
|
||||
echo "start run command"
|
||||
echo "${AdminPassword}"
|
||||
|
||||
ARGUS_VERSION=3.5.7 /bin/bash -c "$(curl -sS https://cms-agent-${RegionId}.oss-${RegionId}-internal.aliyuncs.com/Argus/agent_install_ecs-1.7.sh)" >> /root/install_cms_agent.log 2>&1
|
||||
- RegionId:
|
||||
Ref: ALIYUN::Region
|
||||
Outputs:
|
||||
ServerAddress:
|
||||
Description:
|
||||
en: ServerAddress.
|
||||
zh-cn: 访问页面。
|
||||
Value:
|
||||
Fn::Sub:
|
||||
- 'http://${ServerAddress}:80'
|
||||
- ServerAddress:
|
||||
Fn::Select:
|
||||
- 0
|
||||
- Fn::GetAtt:
|
||||
- InstanceGroup
|
||||
- PublicIps
|
||||
Metadata:
|
||||
ALIYUN::ROS::Interface:
|
||||
ParameterGroups:
|
||||
- Parameters:
|
||||
- PayType
|
||||
- PayPeriodUnit
|
||||
- PayPeriod
|
||||
Label:
|
||||
default: 付费类型配置
|
||||
- Parameters:
|
||||
- EcsInstanceType
|
||||
- InstancePassword
|
||||
Label:
|
||||
default: 资源配置
|
||||
- Parameters:
|
||||
- ZoneId
|
||||
- VpcId
|
||||
- VSwitchId
|
||||
Label:
|
||||
default: 可用区配置
|
||||
- Parameters:
|
||||
- AdminPassword
|
||||
Label:
|
||||
en: Software Configuration
|
||||
zh-cn: 软件配置
|
||||
|
||||
11
README.en.md
11
README.en.md
@@ -204,6 +204,17 @@ If you encounter a blank page after deployment, refer to [#97](https://github.co
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>Deployment on Aliyun</strong></summary>
|
||||
<div>
|
||||
|
||||
> Aliyun support one-click deployment to a dedicated VPC.。
|
||||
|
||||
Aliyun support the fast deployment,[Deployment Link](https://computenest.console.aliyun.com/service/instance/create/default?type=user&ServiceName=One%20API%20%E7%A4%BE%E5%8C%BA%E7%89%88)
|
||||
|
||||
</div>
|
||||
</details>
|
||||
|
||||
## Configuration
|
||||
The system is ready to use out of the box.
|
||||
|
||||
|
||||
11
README.md
11
README.md
@@ -302,6 +302,17 @@ Render 可以直接部署 docker 镜像,不需要 fork 仓库:https://dashbo
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>部署到阿里云</strong></summary>
|
||||
<div>
|
||||
|
||||
> 阿里云支持一键部署到专属VPC。
|
||||
|
||||
阿里云支持快速一键部署,[部署链接](https://computenest.console.aliyun.com/service/instance/create/default?type=user&ServiceName=One%20API%20%E7%A4%BE%E5%8C%BA%E7%89%88)
|
||||
|
||||
</div>
|
||||
</details>
|
||||
|
||||
## 配置
|
||||
系统本身开箱即用。
|
||||
|
||||
|
||||
@@ -76,9 +76,9 @@ func testChannel(channel *model.Channel, request *relaymodel.GeneralOpenAIReques
|
||||
if len(modelNames) > 0 {
|
||||
modelName = modelNames[0]
|
||||
}
|
||||
if modelMap != nil && modelMap[modelName] != "" {
|
||||
modelName = modelMap[modelName]
|
||||
}
|
||||
}
|
||||
if modelMap != nil && modelMap[modelName] != "" {
|
||||
modelName = modelMap[modelName]
|
||||
}
|
||||
meta.OriginModelName, meta.ActualModelName = request.Model, modelName
|
||||
request.Model = modelName
|
||||
|
||||
@@ -6,4 +6,5 @@ var ModelList = []string{
|
||||
"claude-3-sonnet-20240229",
|
||||
"claude-3-opus-20240229",
|
||||
"claude-3-5-sonnet-20240620",
|
||||
"claude-3-5-sonnet-20241022",
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ var AwsModelIDMap = map[string]string{
|
||||
"claude-2.1": "anthropic.claude-v2:1",
|
||||
"claude-3-sonnet-20240229": "anthropic.claude-3-sonnet-20240229-v1:0",
|
||||
"claude-3-5-sonnet-20240620": "anthropic.claude-3-5-sonnet-20240620-v1:0",
|
||||
"claude-3-5-sonnet-20241022": "anthropic.claude-3-5-sonnet-20241022-v2:0",
|
||||
"claude-3-opus-20240229": "anthropic.claude-3-opus-20240229-v1:0",
|
||||
"claude-3-haiku-20240307": "anthropic.claude-3-haiku-20240307-v1:0",
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@ import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/songquanpeng/one-api/common/render"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/songquanpeng/one-api/common/render"
|
||||
|
||||
"github.com/songquanpeng/one-api/common"
|
||||
"github.com/songquanpeng/one-api/common/config"
|
||||
"github.com/songquanpeng/one-api/common/helper"
|
||||
@@ -28,6 +29,11 @@ const (
|
||||
VisionMaxImageNum = 16
|
||||
)
|
||||
|
||||
var mimeTypeMap = map[string]string{
|
||||
"json_object": "application/json",
|
||||
"text": "text/plain",
|
||||
}
|
||||
|
||||
// Setting safety to the lowest possible values since Gemini is already powerless enough
|
||||
func ConvertRequest(textRequest model.GeneralOpenAIRequest) *ChatRequest {
|
||||
geminiRequest := ChatRequest{
|
||||
@@ -56,6 +62,15 @@ func ConvertRequest(textRequest model.GeneralOpenAIRequest) *ChatRequest {
|
||||
MaxOutputTokens: textRequest.MaxTokens,
|
||||
},
|
||||
}
|
||||
if textRequest.ResponseFormat != nil {
|
||||
if mimeType, ok := mimeTypeMap[textRequest.ResponseFormat.Type]; ok {
|
||||
geminiRequest.GenerationConfig.ResponseMimeType = mimeType
|
||||
}
|
||||
if textRequest.ResponseFormat.JsonSchema != nil {
|
||||
geminiRequest.GenerationConfig.ResponseSchema = textRequest.ResponseFormat.JsonSchema.Schema
|
||||
geminiRequest.GenerationConfig.ResponseMimeType = mimeTypeMap["json_object"]
|
||||
}
|
||||
}
|
||||
if textRequest.Tools != nil {
|
||||
functions := make([]model.Function, 0, len(textRequest.Tools))
|
||||
for _, tool := range textRequest.Tools {
|
||||
|
||||
@@ -65,10 +65,12 @@ type ChatTools struct {
|
||||
}
|
||||
|
||||
type ChatGenerationConfig struct {
|
||||
Temperature float64 `json:"temperature,omitempty"`
|
||||
TopP float64 `json:"topP,omitempty"`
|
||||
TopK float64 `json:"topK,omitempty"`
|
||||
MaxOutputTokens int `json:"maxOutputTokens,omitempty"`
|
||||
CandidateCount int `json:"candidateCount,omitempty"`
|
||||
StopSequences []string `json:"stopSequences,omitempty"`
|
||||
ResponseMimeType string `json:"responseMimeType,omitempty"`
|
||||
ResponseSchema any `json:"responseSchema,omitempty"`
|
||||
Temperature float64 `json:"temperature,omitempty"`
|
||||
TopP float64 `json:"topP,omitempty"`
|
||||
TopK float64 `json:"topK,omitempty"`
|
||||
MaxOutputTokens int `json:"maxOutputTokens,omitempty"`
|
||||
CandidateCount int `json:"candidateCount,omitempty"`
|
||||
StopSequences []string `json:"stopSequences,omitempty"`
|
||||
}
|
||||
|
||||
@@ -4,14 +4,21 @@ package groq
|
||||
|
||||
var ModelList = []string{
|
||||
"gemma-7b-it",
|
||||
"mixtral-8x7b-32768",
|
||||
"llama3-8b-8192",
|
||||
"llama3-70b-8192",
|
||||
"gemma2-9b-it",
|
||||
"llama-3.1-405b-reasoning",
|
||||
"llama-3.1-70b-versatile",
|
||||
"llama-3.1-8b-instant",
|
||||
"llama-3.2-11b-text-preview",
|
||||
"llama-3.2-11b-vision-preview",
|
||||
"llama-3.2-1b-preview",
|
||||
"llama-3.2-3b-preview",
|
||||
"llama-3.2-90b-text-preview",
|
||||
"llama-guard-3-8b",
|
||||
"llama3-70b-8192",
|
||||
"llama3-8b-8192",
|
||||
"llama3-groq-70b-8192-tool-use-preview",
|
||||
"llama3-groq-8b-8192-tool-use-preview",
|
||||
"llava-v1.5-7b-4096-preview",
|
||||
"mixtral-8x7b-32768",
|
||||
"distil-whisper-large-v3-en",
|
||||
"whisper-large-v3",
|
||||
}
|
||||
|
||||
@@ -75,6 +75,13 @@ func (a *Adaptor) ConvertRequest(c *gin.Context, relayMode int, request *model.G
|
||||
if request == nil {
|
||||
return nil, errors.New("request is nil")
|
||||
}
|
||||
if request.Stream {
|
||||
// always return usage in stream mode
|
||||
if request.StreamOptions == nil {
|
||||
request.StreamOptions = &model.StreamOptions{}
|
||||
}
|
||||
request.StreamOptions.IncludeUsage = true
|
||||
}
|
||||
return request, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
var ModelList = []string{
|
||||
"gemini-1.5-pro-001", "gemini-1.5-flash-001", "gemini-pro", "gemini-pro-vision",
|
||||
"gemini-1.5-pro-001", "gemini-1.5-flash-001", "gemini-pro", "gemini-pro-vision", "gemini-1.5-pro-002", "gemini-1.5-flash-002",
|
||||
}
|
||||
|
||||
type Adaptor struct {
|
||||
|
||||
@@ -81,6 +81,7 @@ var ModelRatio = map[string]float64{
|
||||
"claude-3-haiku-20240307": 0.25 / 1000 * USD,
|
||||
"claude-3-sonnet-20240229": 3.0 / 1000 * USD,
|
||||
"claude-3-5-sonnet-20240620": 3.0 / 1000 * USD,
|
||||
"claude-3-5-sonnet-20241022": 3.0 / 1000 * USD,
|
||||
"claude-3-opus-20240229": 15.0 / 1000 * USD,
|
||||
// https://cloud.baidu.com/doc/WENXINWORKSHOP/s/hlrk4akp7
|
||||
"ERNIE-4.0-8K": 0.120 * RMB,
|
||||
@@ -162,15 +163,21 @@ var ModelRatio = map[string]float64{
|
||||
"mistral-embed": 0.1 / 1000 * USD,
|
||||
// https://wow.groq.com/#:~:text=inquiries%C2%A0here.-,Model,-Current%20Speed
|
||||
"gemma-7b-it": 0.07 / 1000000 * USD,
|
||||
"mixtral-8x7b-32768": 0.24 / 1000000 * USD,
|
||||
"llama3-8b-8192": 0.05 / 1000000 * USD,
|
||||
"llama3-70b-8192": 0.59 / 1000000 * USD,
|
||||
"gemma2-9b-it": 0.20 / 1000000 * USD,
|
||||
"llama-3.1-405b-reasoning": 0.89 / 1000000 * USD,
|
||||
"llama-3.1-70b-versatile": 0.59 / 1000000 * USD,
|
||||
"llama-3.1-8b-instant": 0.05 / 1000000 * USD,
|
||||
"llama-3.2-11b-text-preview": 0.05 / 1000000 * USD,
|
||||
"llama-3.2-11b-vision-preview": 0.05 / 1000000 * USD,
|
||||
"llama-3.2-1b-preview": 0.05 / 1000000 * USD,
|
||||
"llama-3.2-3b-preview": 0.05 / 1000000 * USD,
|
||||
"llama-3.2-90b-text-preview": 0.59 / 1000000 * USD,
|
||||
"llama-guard-3-8b": 0.05 / 1000000 * USD,
|
||||
"llama3-70b-8192": 0.59 / 1000000 * USD,
|
||||
"llama3-8b-8192": 0.05 / 1000000 * USD,
|
||||
"llama3-groq-70b-8192-tool-use-preview": 0.89 / 1000000 * USD,
|
||||
"llama3-groq-8b-8192-tool-use-preview": 0.19 / 1000000 * USD,
|
||||
"mixtral-8x7b-32768": 0.24 / 1000000 * USD,
|
||||
|
||||
// https://platform.lingyiwanwu.com/docs#-计费单元
|
||||
"yi-34b-chat-0205": 2.5 / 1000 * RMB,
|
||||
"yi-34b-chat-200k": 12.0 / 1000 * RMB,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package model
|
||||
|
||||
const (
|
||||
ContentTypeText = "text"
|
||||
ContentTypeImageURL = "image_url"
|
||||
ContentTypeText = "text"
|
||||
ContentTypeImageURL = "image_url"
|
||||
ContentTypeInputAudio = "input_audio"
|
||||
)
|
||||
|
||||
@@ -12,9 +12,20 @@ type JSONSchema struct {
|
||||
Strict *bool `json:"strict,omitempty"`
|
||||
}
|
||||
|
||||
type Audio struct {
|
||||
Voice string `json:"voice,omitempty"`
|
||||
Format string `json:"format,omitempty"`
|
||||
}
|
||||
|
||||
type StreamOptions struct {
|
||||
IncludeUsage bool `json:"include_usage,omitempty"`
|
||||
}
|
||||
|
||||
type GeneralOpenAIRequest struct {
|
||||
Messages []Message `json:"messages,omitempty"`
|
||||
Model string `json:"model,omitempty"`
|
||||
Modalities []string `json:"modalities,omitempty"`
|
||||
Audio *Audio `json:"audio,omitempty"`
|
||||
FrequencyPenalty float64 `json:"frequency_penalty,omitempty"`
|
||||
MaxTokens int `json:"max_tokens,omitempty"`
|
||||
N int `json:"n,omitempty"`
|
||||
@@ -23,6 +34,7 @@ type GeneralOpenAIRequest struct {
|
||||
Seed float64 `json:"seed,omitempty"`
|
||||
Stop any `json:"stop,omitempty"`
|
||||
Stream bool `json:"stream,omitempty"`
|
||||
StreamOptions *StreamOptions `json:"stream_options,omitempty"`
|
||||
Temperature float64 `json:"temperature,omitempty"`
|
||||
TopP float64 `json:"top_p,omitempty"`
|
||||
TopK int `json:"top_k,omitempty"`
|
||||
@@ -37,7 +49,7 @@ type GeneralOpenAIRequest struct {
|
||||
Dimensions int `json:"dimensions,omitempty"`
|
||||
Instruction string `json:"instruction,omitempty"`
|
||||
Size string `json:"size,omitempty"`
|
||||
NumCtx int `json:"num_ctx,omitempty"`
|
||||
NumCtx int `json:"num_ctx,omitempty"`
|
||||
}
|
||||
|
||||
func (r GeneralOpenAIRequest) ParseInput() []string {
|
||||
|
||||
@@ -63,7 +63,7 @@ const EditChannel = (props) => {
|
||||
let localModels = [];
|
||||
switch (value) {
|
||||
case 14:
|
||||
localModels = ["claude-instant-1.2", "claude-2", "claude-2.0", "claude-2.1", "claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-3-haiku-20240307", "claude-3-5-sonnet-20240620"];
|
||||
localModels = ["claude-instant-1.2", "claude-2", "claude-2.0", "claude-2.1", "claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-3-haiku-20240307", "claude-3-5-sonnet-20240620", "claude-3-5-sonnet-20241022"];
|
||||
break;
|
||||
case 11:
|
||||
localModels = ['PaLM-2'];
|
||||
|
||||
@@ -59,6 +59,12 @@ function renderBalance(type, balance) {
|
||||
}
|
||||
}
|
||||
|
||||
function isShowDetail() {
|
||||
return localStorage.getItem("show_detail") === "true";
|
||||
}
|
||||
|
||||
const promptID = "detail"
|
||||
|
||||
const ChannelsTable = () => {
|
||||
const [channels, setChannels] = useState([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
@@ -66,7 +72,8 @@ const ChannelsTable = () => {
|
||||
const [searchKeyword, setSearchKeyword] = useState('');
|
||||
const [searching, setSearching] = useState(false);
|
||||
const [updatingBalance, setUpdatingBalance] = useState(false);
|
||||
const [showPrompt, setShowPrompt] = useState(shouldShowPrompt("channel-test"));
|
||||
const [showPrompt, setShowPrompt] = useState(shouldShowPrompt(promptID));
|
||||
const [showDetail, setShowDetail] = useState(isShowDetail());
|
||||
|
||||
const loadChannels = async (startIdx) => {
|
||||
const res = await API.get(`/api/channel/?p=${startIdx}`);
|
||||
@@ -120,6 +127,11 @@ const ChannelsTable = () => {
|
||||
await loadChannels(activePage - 1);
|
||||
};
|
||||
|
||||
const toggleShowDetail = () => {
|
||||
setShowDetail(!showDetail);
|
||||
localStorage.setItem("show_detail", (!showDetail).toString());
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
loadChannels(0)
|
||||
.then()
|
||||
@@ -364,11 +376,13 @@ const ChannelsTable = () => {
|
||||
showPrompt && (
|
||||
<Message onDismiss={() => {
|
||||
setShowPrompt(false);
|
||||
setPromptShown("channel-test");
|
||||
setPromptShown(promptID);
|
||||
}}>
|
||||
OpenAI 渠道已经不再支持通过 key 获取余额,因此余额显示为 0。对于支持的渠道类型,请点击余额进行刷新。
|
||||
<br/>
|
||||
渠道测试仅支持 chat 模型,优先使用 gpt-3.5-turbo,如果该模型不可用则使用你所配置的模型列表中的第一个模型。
|
||||
<br/>
|
||||
点击下方详情按钮可以显示余额以及设置额外的测试模型。
|
||||
</Message>
|
||||
)
|
||||
}
|
||||
@@ -428,6 +442,7 @@ const ChannelsTable = () => {
|
||||
onClick={() => {
|
||||
sortChannel('balance');
|
||||
}}
|
||||
hidden={!showDetail}
|
||||
>
|
||||
余额
|
||||
</Table.HeaderCell>
|
||||
@@ -439,7 +454,7 @@ const ChannelsTable = () => {
|
||||
>
|
||||
优先级
|
||||
</Table.HeaderCell>
|
||||
<Table.HeaderCell>测试模型</Table.HeaderCell>
|
||||
<Table.HeaderCell hidden={!showDetail}>测试模型</Table.HeaderCell>
|
||||
<Table.HeaderCell>操作</Table.HeaderCell>
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
@@ -467,7 +482,7 @@ const ChannelsTable = () => {
|
||||
basic
|
||||
/>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<Table.Cell hidden={!showDetail}>
|
||||
<Popup
|
||||
trigger={<span onClick={() => {
|
||||
updateChannelBalance(channel.id, channel.name, idx);
|
||||
@@ -494,7 +509,7 @@ const ChannelsTable = () => {
|
||||
basic
|
||||
/>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<Table.Cell hidden={!showDetail}>
|
||||
<Dropdown
|
||||
placeholder='请选择测试模型'
|
||||
selection
|
||||
@@ -573,7 +588,7 @@ const ChannelsTable = () => {
|
||||
|
||||
<Table.Footer>
|
||||
<Table.Row>
|
||||
<Table.HeaderCell colSpan='9'>
|
||||
<Table.HeaderCell colSpan={showDetail ? "10" : "8"}>
|
||||
<Button size='small' as={Link} to='/channel/add' loading={loading}>
|
||||
添加新的渠道
|
||||
</Button>
|
||||
@@ -611,6 +626,7 @@ const ChannelsTable = () => {
|
||||
}
|
||||
/>
|
||||
<Button size='small' onClick={refresh} loading={loading}>刷新</Button>
|
||||
<Button size='small' onClick={toggleShowDetail}>{showDetail ? "隐藏详情" : "详情"}</Button>
|
||||
</Table.HeaderCell>
|
||||
</Table.Row>
|
||||
</Table.Footer>
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import { Header, Segment } from 'semantic-ui-react';
|
||||
import ChannelsTable from '../../components/ChannelsTable';
|
||||
|
||||
const File = () => (
|
||||
const Channel = () => (
|
||||
<>
|
||||
<Segment>
|
||||
<Header as='h3'>管理渠道</Header>
|
||||
@@ -11,4 +11,4 @@ const File = () => (
|
||||
</>
|
||||
);
|
||||
|
||||
export default File;
|
||||
export default Channel;
|
||||
|
||||
Reference in New Issue
Block a user