mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-18 00:16:37 +08:00
Merge remote-tracking branch 'upstream/main'
This commit is contained in:
commit
bfe9e5d25a
@ -75,11 +75,20 @@ func OpenaiStreamHandler(c *gin.Context, resp *http.Response, relayMode int) (*d
|
|||||||
err := json.Unmarshal(common.StringToByteSlice(streamResp), &streamResponses)
|
err := json.Unmarshal(common.StringToByteSlice(streamResp), &streamResponses)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.SysError("error unmarshalling stream response: " + err.Error())
|
common.SysError("error unmarshalling stream response: " + err.Error())
|
||||||
return // just ignore the error
|
for _, item := range streamItems {
|
||||||
}
|
var streamResponse dto.ChatCompletionsStreamResponseSimple
|
||||||
for _, streamResponse := range streamResponses {
|
err := json.Unmarshal(common.StringToByteSlice(item), &streamResponse)
|
||||||
for _, choice := range streamResponse.Choices {
|
if err == nil {
|
||||||
responseTextBuilder.WriteString(choice.Delta.Content)
|
for _, choice := range streamResponse.Choices {
|
||||||
|
responseTextBuilder.WriteString(choice.Delta.Content)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for _, streamResponse := range streamResponses {
|
||||||
|
for _, choice := range streamResponse.Choices {
|
||||||
|
responseTextBuilder.WriteString(choice.Delta.Content)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case relayconstant.RelayModeCompletions:
|
case relayconstant.RelayModeCompletions:
|
||||||
@ -87,11 +96,20 @@ func OpenaiStreamHandler(c *gin.Context, resp *http.Response, relayMode int) (*d
|
|||||||
err := json.Unmarshal(common.StringToByteSlice(streamResp), &streamResponses)
|
err := json.Unmarshal(common.StringToByteSlice(streamResp), &streamResponses)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.SysError("error unmarshalling stream response: " + err.Error())
|
common.SysError("error unmarshalling stream response: " + err.Error())
|
||||||
return // just ignore the error
|
for _, item := range streamItems {
|
||||||
}
|
var streamResponse dto.CompletionsStreamResponse
|
||||||
for _, streamResponse := range streamResponses {
|
err := json.Unmarshal(common.StringToByteSlice(item), &streamResponse)
|
||||||
for _, choice := range streamResponse.Choices {
|
if err == nil {
|
||||||
responseTextBuilder.WriteString(choice.Text)
|
for _, choice := range streamResponse.Choices {
|
||||||
|
responseTextBuilder.WriteString(choice.Text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for _, streamResponse := range streamResponses {
|
||||||
|
for _, choice := range streamResponse.Choices {
|
||||||
|
responseTextBuilder.WriteString(choice.Text)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,6 +322,9 @@ const ChannelsTable = () => {
|
|||||||
const res = await API.get(
|
const res = await API.get(
|
||||||
`/api/channel/?p=${startIdx}&page_size=${pageSize}&id_sort=${idSort}`,
|
`/api/channel/?p=${startIdx}&page_size=${pageSize}&id_sort=${idSort}`,
|
||||||
);
|
);
|
||||||
|
if (res === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const { success, message, data } = res.data;
|
const { success, message, data } = res.data;
|
||||||
if (success) {
|
if (success) {
|
||||||
if (startIdx === 0) {
|
if (startIdx === 0) {
|
||||||
@ -608,6 +611,9 @@ const ChannelsTable = () => {
|
|||||||
let res = await API.get(`/api/group/`);
|
let res = await API.get(`/api/group/`);
|
||||||
// add 'all' option
|
// add 'all' option
|
||||||
// res.data.data.unshift('all');
|
// res.data.data.unshift('all');
|
||||||
|
if (res === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
setGroupOptions(
|
setGroupOptions(
|
||||||
res.data.data.map((group) => ({
|
res.data.data.map((group) => ({
|
||||||
label: group,
|
label: group,
|
||||||
|
@ -628,7 +628,7 @@ const PersonalSetting = () => {
|
|||||||
onCancel={() => setShowWeChatBindModal(false)}
|
onCancel={() => setShowWeChatBindModal(false)}
|
||||||
// onOpen={() => setShowWeChatBindModal(true)}
|
// onOpen={() => setShowWeChatBindModal(true)}
|
||||||
visible={showWeChatBindModal}
|
visible={showWeChatBindModal}
|
||||||
size={'mini'}
|
size={'small'}
|
||||||
>
|
>
|
||||||
<Image src={status.wechat_qrcode} />
|
<Image src={status.wechat_qrcode} />
|
||||||
<div style={{ textAlign: 'center' }}>
|
<div style={{ textAlign: 'center' }}>
|
||||||
@ -678,7 +678,7 @@ const PersonalSetting = () => {
|
|||||||
onClick={sendVerificationCode}
|
onClick={sendVerificationCode}
|
||||||
disabled={disableButton || loading}
|
disabled={disableButton || loading}
|
||||||
>
|
>
|
||||||
{disableButton ? `重新发送(${countdown})` : '获取验证码'}
|
{disableButton ? `重新发送 (${countdown})` : '获取验证码'}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ marginTop: 10 }}>
|
<div style={{ marginTop: 10 }}>
|
||||||
|
@ -156,6 +156,9 @@ const SiderBar = () => {
|
|||||||
|
|
||||||
const loadStatus = async () => {
|
const loadStatus = async () => {
|
||||||
const res = await API.get('/api/status');
|
const res = await API.get('/api/status');
|
||||||
|
if (res === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const { success, data } = res.data;
|
const { success, data } = res.data;
|
||||||
if (success) {
|
if (success) {
|
||||||
localStorage.setItem('status', JSON.stringify(data));
|
localStorage.setItem('status', JSON.stringify(data));
|
||||||
|
@ -46,7 +46,7 @@ const SystemSetting = () => {
|
|||||||
TurnstileSecretKey: '',
|
TurnstileSecretKey: '',
|
||||||
RegisterEnabled: '',
|
RegisterEnabled: '',
|
||||||
EmailDomainRestrictionEnabled: '',
|
EmailDomainRestrictionEnabled: '',
|
||||||
EmailDomainWhitelist: '',
|
EmailDomainWhitelist: [],
|
||||||
// telegram login
|
// telegram login
|
||||||
TelegramOAuthEnabled: '',
|
TelegramOAuthEnabled: '',
|
||||||
TelegramBotToken: '',
|
TelegramBotToken: '',
|
||||||
@ -89,6 +89,7 @@ const SystemSetting = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getOptions().then();
|
getOptions().then();
|
||||||
}, []);
|
}, []);
|
||||||
|
useEffect(() => {}, [inputs.EmailDomainWhitelist]);
|
||||||
|
|
||||||
const updateOption = async (key, value) => {
|
const updateOption = async (key, value) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
@ -188,6 +188,9 @@ const EditChannel = (props) => {
|
|||||||
const loadChannel = async () => {
|
const loadChannel = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
let res = await API.get(`/api/channel/${channelId}`);
|
let res = await API.get(`/api/channel/${channelId}`);
|
||||||
|
if (res === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const { success, message, data } = res.data;
|
const { success, message, data } = res.data;
|
||||||
if (success) {
|
if (success) {
|
||||||
if (data.models === '') {
|
if (data.models === '') {
|
||||||
@ -223,6 +226,9 @@ const EditChannel = (props) => {
|
|||||||
const fetchModels = async () => {
|
const fetchModels = async () => {
|
||||||
try {
|
try {
|
||||||
let res = await API.get(`/api/channel/models`);
|
let res = await API.get(`/api/channel/models`);
|
||||||
|
if (res === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let localModelOptions = res.data.data.map((model) => ({
|
let localModelOptions = res.data.data.map((model) => ({
|
||||||
label: model.id,
|
label: model.id,
|
||||||
value: model.id,
|
value: model.id,
|
||||||
@ -244,6 +250,9 @@ const EditChannel = (props) => {
|
|||||||
const fetchGroups = async () => {
|
const fetchGroups = async () => {
|
||||||
try {
|
try {
|
||||||
let res = await API.get(`/api/group/`);
|
let res = await API.get(`/api/group/`);
|
||||||
|
if (res === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
setGroupOptions(
|
setGroupOptions(
|
||||||
res.data.data.map((group) => ({
|
res.data.data.map((group) => ({
|
||||||
label: group,
|
label: group,
|
||||||
|
@ -39,7 +39,7 @@ const Setting = () => {
|
|||||||
<Layout.Content>
|
<Layout.Content>
|
||||||
<Tabs type='line' defaultActiveKey='1'>
|
<Tabs type='line' defaultActiveKey='1'>
|
||||||
{panes.map((pane) => (
|
{panes.map((pane) => (
|
||||||
<TabPane itemKey={pane.itemKey} tab={pane.tab}>
|
<TabPane itemKey={pane.itemKey} tab={pane.tab} key={pane.itemKey}>
|
||||||
{pane.content}
|
{pane.content}
|
||||||
</TabPane>
|
</TabPane>
|
||||||
))}
|
))}
|
||||||
|
Loading…
Reference in New Issue
Block a user