mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-04-27 22:58:38 +00:00
1. Async task model redirection (aligned with sync tasks):
- Integrate ModelMappedHelper in RelayTaskSubmit after model name
determination, populating OriginModelName / UpstreamModelName on RelayInfo.
- All task adaptors now send UpstreamModelName to upstream providers:
- Gemini & Vertex: BuildRequestURL uses UpstreamModelName.
- Doubao & Ali: BuildRequestBody conditionally overwrites body.Model.
- Vidu, Kling, Hailuo, Jimeng: convertToRequestPayload accepts RelayInfo
and unconditionally uses info.UpstreamModelName.
- Sora: BuildRequestBody parses JSON and multipart bodies to replace
the "model" field with UpstreamModelName.
- Frontend log visibility: LogTaskConsumption and taskBillingOther now
emit is_model_mapped / upstream_model_name in the "other" JSON field.
- Billing safety: RecalculateTaskQuotaByTokens reads model name from
BillingContext.OriginModelName (via taskModelName) instead of
task.Data["model"], preventing billing leaks from upstream model names.
2. Per-call billing (TaskPricePatches lifecycle):
- Rename TaskBillingContext.ModelName → OriginModelName; add PerCallBilling
bool field, populated from TaskPricePatches at submission time.
- settleTaskBillingOnComplete short-circuits when PerCallBilling is true,
skipping both adaptor adjustments and token-based recalculation.
- Remove ModelName from TaskSubmitResult; use relayInfo.OriginModelName
consistently in controller/relay.go for billing context and logging.
3. Multipart retry boundary mismatch fix:
- Root cause: after Sora (or OpenAI audio) rebuilds a multipart body with a
new boundary and overwrites c.Request.Header["Content-Type"], subsequent
calls to ParseMultipartFormReusable on retry would parse the cached
original body with the wrong boundary, causing "NextPart: EOF".
- Fix: ParseMultipartFormReusable now caches the original Content-Type in
gin context key "_original_multipart_ct" on first call and reuses it for
all subsequent parses, making multipart parsing retry-safe globally.
- Sora adaptor reverted to the standard pattern (direct header set/get),
which is now safe thanks to the root fix.
4. Tests:
- task_billing_test.go: update makeTask to use OriginModelName; add
PerCallBilling settlement tests (skip adaptor adjust, skip token recalc);
add non-per-call adaptor adjustment test with refund verification.
73 lines
2.5 KiB
JavaScript
73 lines
2.5 KiB
JavaScript
/*
|
|
Copyright (C) 2025 QuantumNous
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as
|
|
published by the Free Software Foundation, either version 3 of the
|
|
License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
For commercial licensing, please contact support@quantumnous.com
|
|
*/
|
|
|
|
import React from 'react';
|
|
import { Layout } from '@douyinfe/semi-ui';
|
|
import CardPro from '../../common/ui/CardPro';
|
|
import TaskLogsTable from './TaskLogsTable';
|
|
import TaskLogsActions from './TaskLogsActions';
|
|
import TaskLogsFilters from './TaskLogsFilters';
|
|
import ColumnSelectorModal from './modals/ColumnSelectorModal';
|
|
import ContentModal from './modals/ContentModal';
|
|
import { useTaskLogsData } from '../../../hooks/task-logs/useTaskLogsData';
|
|
import { useIsMobile } from '../../../hooks/common/useIsMobile';
|
|
import { createCardProPagination } from '../../../helpers/utils';
|
|
|
|
const TaskLogsPage = () => {
|
|
const taskLogsData = useTaskLogsData();
|
|
const isMobile = useIsMobile();
|
|
|
|
return (
|
|
<>
|
|
{/* Modals */}
|
|
<ColumnSelectorModal {...taskLogsData} />
|
|
<ContentModal {...taskLogsData} isVideo={false} />
|
|
{/* 新增:视频预览弹窗 */}
|
|
<ContentModal
|
|
isModalOpen={taskLogsData.isVideoModalOpen}
|
|
setIsModalOpen={taskLogsData.setIsVideoModalOpen}
|
|
modalContent={taskLogsData.videoUrl}
|
|
isVideo={true}
|
|
/>
|
|
|
|
<Layout>
|
|
<CardPro
|
|
type='type2'
|
|
statsArea={<TaskLogsActions {...taskLogsData} />}
|
|
searchArea={<TaskLogsFilters {...taskLogsData} />}
|
|
paginationArea={createCardProPagination({
|
|
currentPage: taskLogsData.activePage,
|
|
pageSize: taskLogsData.pageSize,
|
|
total: taskLogsData.logCount,
|
|
onPageChange: taskLogsData.handlePageChange,
|
|
onPageSizeChange: taskLogsData.handlePageSizeChange,
|
|
isMobile: isMobile,
|
|
t: taskLogsData.t,
|
|
})}
|
|
t={taskLogsData.t}
|
|
>
|
|
<TaskLogsTable {...taskLogsData} />
|
|
</CardPro>
|
|
</Layout>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default TaskLogsPage;
|