mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-06 16:53:42 +08:00
Compare commits
6 Commits
v0.4.5-alp
...
v0.4.5-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6536a7be62 | ||
|
|
1b5c628e66 | ||
|
|
e398f470a1 | ||
|
|
634099e592 | ||
|
|
868f0474a9 | ||
|
|
ced9f060c7 |
13
README.md
13
README.md
@@ -71,17 +71,18 @@ _✨ All in one 的 OpenAI 接口,整合各种 API 访问方式,开箱即用
|
|||||||
9. 支持渠道**设置模型列表**。
|
9. 支持渠道**设置模型列表**。
|
||||||
10. 支持**查看额度明细**。
|
10. 支持**查看额度明细**。
|
||||||
11. 支持**用户邀请奖励**。
|
11. 支持**用户邀请奖励**。
|
||||||
12. 支持发布公告,设置充值链接,设置新用户初始额度。
|
12. 支持以美元为单位显示额度。
|
||||||
13. 支持丰富的**自定义**设置,
|
13. 支持发布公告,设置充值链接,设置新用户初始额度。
|
||||||
|
14. 支持丰富的**自定义**设置,
|
||||||
1. 支持自定义系统名称,logo 以及页脚。
|
1. 支持自定义系统名称,logo 以及页脚。
|
||||||
2. 支持自定义首页和关于页面,可以选择使用 HTML & Markdown 代码进行自定义,或者使用一个单独的网页通过 iframe 嵌入。
|
2. 支持自定义首页和关于页面,可以选择使用 HTML & Markdown 代码进行自定义,或者使用一个单独的网页通过 iframe 嵌入。
|
||||||
14. 支持通过系统访问令牌访问管理 API。
|
15. 支持通过系统访问令牌访问管理 API。
|
||||||
15. 支持 Cloudflare Turnstile 用户校验。
|
16. 支持 Cloudflare Turnstile 用户校验。
|
||||||
16. 支持用户管理,支持**多种用户登录注册方式**:
|
17. 支持用户管理,支持**多种用户登录注册方式**:
|
||||||
+ 邮箱登录注册以及通过邮箱进行密码重置。
|
+ 邮箱登录注册以及通过邮箱进行密码重置。
|
||||||
+ [GitHub 开放授权](https://github.com/settings/applications/new)。
|
+ [GitHub 开放授权](https://github.com/settings/applications/new)。
|
||||||
+ 微信公众号授权(需要额外部署 [WeChat Server](https://github.com/songquanpeng/wechat-server))。
|
+ 微信公众号授权(需要额外部署 [WeChat Server](https://github.com/songquanpeng/wechat-server))。
|
||||||
17. 未来其他大模型开放 API 后,将第一时间支持,并将其封装成同样的 API 访问方式。
|
18. 未来其他大模型开放 API 后,将第一时间支持,并将其封装成同样的 API 访问方式。
|
||||||
|
|
||||||
## 部署
|
## 部署
|
||||||
### 基于 Docker 进行部署
|
### 基于 Docker 进行部署
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ func GetUsage(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
amount := float64(quota)
|
amount := float64(quota)
|
||||||
|
if common.DisplayInCurrencyEnabled {
|
||||||
|
amount /= common.QuotaPerUnit
|
||||||
|
}
|
||||||
usage := OpenAIUsageResponse{
|
usage := OpenAIUsageResponse{
|
||||||
Object: "list",
|
Object: "list",
|
||||||
TotalUsage: amount,
|
TotalUsage: amount,
|
||||||
|
|||||||
@@ -25,9 +25,7 @@ func testChannel(channel *model.Channel, request ChatRequest) error {
|
|||||||
if channel.Type == common.ChannelTypeAzure {
|
if channel.Type == common.ChannelTypeAzure {
|
||||||
requestURL = fmt.Sprintf("%s/openai/deployments/%s/chat/completions?api-version=2023-03-15-preview", channel.BaseURL, request.Model)
|
requestURL = fmt.Sprintf("%s/openai/deployments/%s/chat/completions?api-version=2023-03-15-preview", channel.BaseURL, request.Model)
|
||||||
} else {
|
} else {
|
||||||
if channel.Type == common.ChannelTypeCustom {
|
if channel.BaseURL != "" {
|
||||||
requestURL = channel.BaseURL
|
|
||||||
} else if channel.Type == common.ChannelTypeOpenAI && channel.BaseURL != "" {
|
|
||||||
requestURL = channel.BaseURL
|
requestURL = channel.BaseURL
|
||||||
}
|
}
|
||||||
requestURL += "/v1/chat/completions"
|
requestURL += "/v1/chat/completions"
|
||||||
|
|||||||
@@ -30,12 +30,8 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
|
|||||||
}
|
}
|
||||||
baseURL := common.ChannelBaseURLs[channelType]
|
baseURL := common.ChannelBaseURLs[channelType]
|
||||||
requestURL := c.Request.URL.String()
|
requestURL := c.Request.URL.String()
|
||||||
if channelType == common.ChannelTypeCustom {
|
if c.GetString("base_url") != "" {
|
||||||
baseURL = c.GetString("base_url")
|
baseURL = c.GetString("base_url")
|
||||||
} else if channelType == common.ChannelTypeOpenAI {
|
|
||||||
if c.GetString("base_url") != "" {
|
|
||||||
baseURL = c.GetString("base_url")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fullRequestURL := fmt.Sprintf("%s%s", baseURL, requestURL)
|
fullRequestURL := fmt.Sprintf("%s%s", baseURL, requestURL)
|
||||||
if channelType == common.ChannelTypeAzure {
|
if channelType == common.ChannelTypeAzure {
|
||||||
|
|||||||
@@ -10,6 +10,6 @@ func CORS() gin.HandlerFunc {
|
|||||||
config.AllowAllOrigins = true
|
config.AllowAllOrigins = true
|
||||||
config.AllowCredentials = true
|
config.AllowCredentials = true
|
||||||
config.AllowMethods = []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}
|
config.AllowMethods = []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}
|
||||||
config.AllowHeaders = []string{"Origin", "Content-Length", "Content-Type", "Authorization", "Accept", "Connection", "x-requested-with"}
|
config.AllowHeaders = []string{"*"}
|
||||||
return cors.New(config)
|
return cors.New(config)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ const OperationSetting = () => {
|
|||||||
placeholder='例如 ChatGPT Next Web 的部署地址'
|
placeholder='例如 ChatGPT Next Web 的部署地址'
|
||||||
/>
|
/>
|
||||||
<Form.Input
|
<Form.Input
|
||||||
label='额度汇率'
|
label='单位美元额度'
|
||||||
name='QuotaPerUnit'
|
name='QuotaPerUnit'
|
||||||
onChange={handleInputChange}
|
onChange={handleInputChange}
|
||||||
autoComplete='new-password'
|
autoComplete='new-password'
|
||||||
|
|||||||
@@ -46,4 +46,13 @@ export function renderQuota(quota, digits = 2) {
|
|||||||
return '$' + (quota / quotaPerUnit).toFixed(digits);
|
return '$' + (quota / quotaPerUnit).toFixed(digits);
|
||||||
}
|
}
|
||||||
return renderNumber(quota);
|
return renderNumber(quota);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function renderQuotaWithPrompt(quota, digits) {
|
||||||
|
let displayInCurrency = localStorage.getItem('display_in_currency');
|
||||||
|
displayInCurrency = displayInCurrency === 'true';
|
||||||
|
if (displayInCurrency) {
|
||||||
|
return `(等价金额:${renderQuota(quota, digits)})`;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
@@ -177,6 +177,20 @@ const EditChannel = () => {
|
|||||||
</Form.Field>
|
</Form.Field>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
inputs.type !== 3 && inputs.type !== 8 && (
|
||||||
|
<Form.Field>
|
||||||
|
<Form.Input
|
||||||
|
label='Base URL'
|
||||||
|
name='base_url'
|
||||||
|
placeholder={'请输入自定义 Base URL,格式为:https://domain.com,可不填,不填使用渠道默认值'}
|
||||||
|
onChange={handleInputChange}
|
||||||
|
value={inputs.base_url}
|
||||||
|
autoComplete='new-password'
|
||||||
|
/>
|
||||||
|
</Form.Field>
|
||||||
|
)
|
||||||
|
}
|
||||||
<Form.Field>
|
<Form.Field>
|
||||||
<Form.Input
|
<Form.Input
|
||||||
label='名称'
|
label='名称'
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
|
|||||||
import { Button, Form, Header, Segment } from 'semantic-ui-react';
|
import { Button, Form, Header, Segment } from 'semantic-ui-react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { API, downloadTextAsFile, showError, showSuccess } from '../../helpers';
|
import { API, downloadTextAsFile, showError, showSuccess } from '../../helpers';
|
||||||
import { renderQuota } from '../../helpers/render';
|
import { renderQuota, renderQuotaWithPrompt } from '../../helpers/render';
|
||||||
|
|
||||||
const EditRedemption = () => {
|
const EditRedemption = () => {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
@@ -11,7 +11,7 @@ const EditRedemption = () => {
|
|||||||
const [loading, setLoading] = useState(isEdit);
|
const [loading, setLoading] = useState(isEdit);
|
||||||
const originInputs = {
|
const originInputs = {
|
||||||
name: '',
|
name: '',
|
||||||
quota: 100,
|
quota: 100000,
|
||||||
count: 1
|
count: 1
|
||||||
};
|
};
|
||||||
const [inputs, setInputs] = useState(originInputs);
|
const [inputs, setInputs] = useState(originInputs);
|
||||||
@@ -88,7 +88,7 @@ const EditRedemption = () => {
|
|||||||
</Form.Field>
|
</Form.Field>
|
||||||
<Form.Field>
|
<Form.Field>
|
||||||
<Form.Input
|
<Form.Input
|
||||||
label={`额度(等价金额 ${renderQuota(quota)})`}
|
label={`额度${renderQuotaWithPrompt(quota)}`}
|
||||||
name='quota'
|
name='quota'
|
||||||
placeholder={'请输入单个兑换码中包含的额度'}
|
placeholder={'请输入单个兑换码中包含的额度'}
|
||||||
onChange={handleInputChange}
|
onChange={handleInputChange}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
|
|||||||
import { Button, Form, Header, Message, Segment } from 'semantic-ui-react';
|
import { Button, Form, Header, Message, Segment } from 'semantic-ui-react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { API, showError, showSuccess, timestamp2string } from '../../helpers';
|
import { API, showError, showSuccess, timestamp2string } from '../../helpers';
|
||||||
import { renderQuota } from '../../helpers/render';
|
import { renderQuota, renderQuotaWithPrompt } from '../../helpers/render';
|
||||||
|
|
||||||
const EditToken = () => {
|
const EditToken = () => {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
@@ -138,7 +138,7 @@ const EditToken = () => {
|
|||||||
<Message>注意,令牌的额度仅用于限制令牌本身的最大额度使用量,实际的使用受到账户的剩余额度限制。</Message>
|
<Message>注意,令牌的额度仅用于限制令牌本身的最大额度使用量,实际的使用受到账户的剩余额度限制。</Message>
|
||||||
<Form.Field>
|
<Form.Field>
|
||||||
<Form.Input
|
<Form.Input
|
||||||
label={`额度(等价金额 ${renderQuota(remain_quota)})`}
|
label={`额度${renderQuotaWithPrompt(remain_quota)}`}
|
||||||
name='remain_quota'
|
name='remain_quota'
|
||||||
placeholder={'请输入额度'}
|
placeholder={'请输入额度'}
|
||||||
onChange={handleInputChange}
|
onChange={handleInputChange}
|
||||||
|
|||||||
Reference in New Issue
Block a user