Commit 763e8dce by renyizhao

models-with-pricing接口新增字段

parent 4f0c132c
...@@ -171,6 +171,10 @@ public class AppAiModelController { ...@@ -171,6 +171,10 @@ public class AppAiModelController {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<Map<String, Object>> vendors = (List<Map<String, Object>>) pricingData.get("vendors"); List<Map<String, Object>> vendors = (List<Map<String, Object>>) pricingData.get("vendors");
// 3.5 提取顶级 supported_endpoint(端点 → URL 路径映射)
@SuppressWarnings("unchecked")
Map<String, Map<String, Object>> topEndpoints = (Map<String, Map<String, Object>>) pricingData.get("supported_endpoint");
// 4. 拉取所有模型元数据(分页循环,因 New API page_size 上限为 100) // 4. 拉取所有模型元数据(分页循环,因 New API page_size 上限为 100)
NewApiResponse<List<Map<String, Object>>> modelsResp = newApiClient.getAllModels(); NewApiResponse<List<Map<String, Object>>> modelsResp = newApiClient.getAllModels();
if (modelsResp.getSuccess() == null || !modelsResp.getSuccess() || modelsResp.getData() == null) { if (modelsResp.getSuccess() == null || !modelsResp.getSuccess() || modelsResp.getData() == null) {
...@@ -285,6 +289,57 @@ public class AppAiModelController { ...@@ -285,6 +289,57 @@ public class AppAiModelController {
// vendor 名称匹配(不主动推断 icon,New API 没配就保持 null) // vendor 名称匹配(不主动推断 icon,New API 没配就保持 null)
vo.setVendorName(resolveVendorName(modelName, vendors)); vo.setVendorName(resolveVendorName(modelName, vendors));
// endpoints:每个模型都带上顶级 supported_endpoint,前端按需取
if (topEndpoints != null) {
vo.setEndpoints(topEndpoints);
}
// 解析使用方式相关字段(来自 pricing.txt)
if (pricing != null) {
// api_examples:使用示例数组(每个含 endpoint/profile/providers/groups)
Object apiExamplesObj = pricing.get("api_examples");
if (apiExamplesObj instanceof List) {
@SuppressWarnings("unchecked")
List<Map<String, Object>> apiExamplesRaw = (List<Map<String, Object>>) apiExamplesObj;
List<AppModelPricingVO.ApiExampleVO> apiExamples = new ArrayList<>();
for (Map<String, Object> ae : apiExamplesRaw) {
AppModelPricingVO.ApiExampleVO aeVo = new AppModelPricingVO.ApiExampleVO();
aeVo.setEndpoint((String) ae.get("endpoint"));
aeVo.setProfile((String) ae.get("profile"));
Object providers = ae.get("providers");
if (providers instanceof List) {
@SuppressWarnings("unchecked")
List<String> ps = (List<String>) providers;
aeVo.setProviders(ps);
}
Object groups = ae.get("groups");
if (groups instanceof List) {
@SuppressWarnings("unchecked")
List<String> gs = (List<String>) groups;
aeVo.setGroups(gs);
}
apiExamples.add(aeVo);
}
vo.setApiExamples(apiExamples);
}
// billing_usage_schema:参数定义
Object schemaObj = pricing.get("billing_usage_schema");
if (schemaObj instanceof Map) {
@SuppressWarnings("unchecked")
Map<String, Object> schemaMap = (Map<String, Object>) schemaObj;
vo.setBillingUsageSchema(schemaMap);
}
// billing_usage_examples:示例数据
Object examplesObj = pricing.get("billing_usage_examples");
if (examplesObj instanceof List) {
@SuppressWarnings("unchecked")
List<Map<String, Object>> examples = (List<Map<String, Object>>) examplesObj;
vo.setBillingUsageExamples(examples);
}
}
result.add(vo); result.add(vo);
} }
......
...@@ -94,6 +94,34 @@ public class AppModelPricingVO { ...@@ -94,6 +94,34 @@ public class AppModelPricingVO {
@Schema(description = "条件乘数列表") @Schema(description = "条件乘数列表")
private List<ConditionMultiplierVO> conditionMultipliers; private List<ConditionMultiplierVO> conditionMultipliers;
@Schema(description = "API 使用示例(含 endpoint、profile、providers、groups)")
private List<ApiExampleVO> apiExamples;
@Schema(description = "端点 → URL 路径映射(来自 pricing.supported_endpoint,每个模型都带,便于前端按需取)")
private Map<String, Map<String, Object>> endpoints;
@Schema(description = "计费用法 schema(仅 openai-video 等模型有)")
private Map<String, Object> billingUsageSchema;
@Schema(description = "计费用法示例")
private List<Map<String, Object>> billingUsageExamples;
/**
* API 使用示例(来自 pricing.txt 的 api_examples 数组)
*/
@Data
@Schema(description = "API 使用示例")
public static class ApiExampleVO {
@Schema(description = "端点类型,如 openai、openai-video、embeddings")
private String endpoint;
@Schema(description = "调用配置,如 standard、seedance2、ctyun-seedream")
private String profile;
@Schema(description = "服务商列表")
private List<String> providers;
@Schema(description = "适用分组列表")
private List<String> groups;
}
/** /**
* 分档信息 VO * 分档信息 VO
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment