跳至正文

模型配置与候选路由 ​

本页阅读位置

完成第一轮对话后,按当前业务需求深入。Spring 常规声明优先使用 RegistrationManifest 与注解;本页的底层 register / publish 或直连方法供协议细化与兼容集成参考。

SDK 示例 ​

java
var profile = ModelProfile.builder("primary", "1.0.0")
    .fallback("backup", "1.0.0")
    .maxOutputTokens(1024)
    .strategy(ModelProfile.Strategy.ORDERED)
    .maxAttempts(2).attemptTimeoutSeconds(10)
    .fallbackOn(List.of(ModelProfile.TransientFailure.MODEL_UNAVAILABLE,
        ModelProfile.TransientFailure.MODEL_TIMED_OUT,
        ModelProfile.TransientFailure.MODEL_RATE_LIMITED,
        ModelProfile.TransientFailure.MODEL_CIRCUIT_OPEN))
    .temperature(0.2).topP(0.8).seed(42).build();
// client 是使用应用管理凭据构造的 PlatformClient。
client.register("model-profiles", "resilient", "1.0.0", profile.definition());
kotlin
val profile = modelProfile {
    binding("primary", "1.0.0")
    fallback("backup", "1.0.0")
    maxOutputTokens = 1024
    strategy = ModelProfile.Strategy.ORDERED
    maxAttempts = 2
    attemptTimeoutSeconds = 10
    temperature = 0.2
    topP = 0.8
    seed = 42
}
client.register("model-profiles", "resilient", "1.0.0", profile.definition())

Java 示例说明:

build 得到不可变快照,之后修改构建器不影响该版本。候选身份必须为精确版本,最多 8 个且不能重复;maxAttempts 不超过候选数。服务端仍重新检查权限、版本、模型能力与价目。

Kotlin 示例说明:

导入 dev.sparktide.sdk.ModelProfile 与 dev.sparktide.sdk.kotlin.modelProfile。SDK 不自动重发 chat,不重新执行工具;故障切换在平台当前模型步骤内完成。省略 fallbackOn 使用平台瞬时错误默认值,空列表关闭错误切换。

Spring Starter ​

yaml
sparktide:
  definitions:
    - kind: model-profiles
      id: resilient
      version: 1.0.0
      definition:
        binding: {id: primary, version: 1.0.0}
        fallbackBindings: [{id: backup, version: 1.0.0}]
        maxOutputTokens: 1024
        routing:
          strategy: ORDERED
          maxAttempts: 2
          attemptTimeoutSeconds: 10
          fallbackOn: [MODEL_UNAVAILABLE, MODEL_TIMED_OUT, MODEL_RATE_LIMITED, MODEL_CIRCUIT_OPEN]
        parameters: {temperature: 0.2, topP: 0.8, seed: 42}

启动的注册/预检/发布流程见声明式注册。主绑定和候选绑定必须在同一应用,模型来源可为已授权 global。LOWEST_COST 要求全部候选价目完整且币种一致;估算排序不代表账单。认证、参数拒绝、无效响应,以及已开始文字或工具参数输出时禁止切换;每次实际尝试消耗根任务预算。旧平台回滚使用无新增字段的旧 Profile 链。

文档来源与验证记录
字段内容
状态已确认
日期2026-09-30
来源ModelProfile、ModelProfileDsl、DeclarativeDefinitions
责任人项目维护者
关联任务M02
结论Java、Kotlin 和 YAML 使用同一平台配置合同
证据不可变快照、Java/Kotlin 一致性和真实 YAML 绑定测试
适用版本:0.1 发布线 · 最近核对:2026-10-09 · SparkTide 产品文档

汇聚智能,驱动涌现。