mirror of
https://gitcode.com/JianFeeeee/ModelRouter.git
synced 2026-11-07 09:47:23 +00:00
docs(discovery): 用实测数据替换注释里的猜测
composeImageEndpoint 原注释写着「两种形式都 404,无法区分」,那是我写代码时 的推测,不是观测。后来真实打了一次上游就分清了: /v1/images/generations → 200(图像生成本身要几分钟,是上游耗时) /v1/v1/images/generations → 404 /images/generations → 404 注释里的假话比没有注释更糟——下一个人会拿它当「已知的模糊地带」而不敢 收紧判据。
This commit is contained in:
@ -285,18 +285,22 @@ func composeEndpoint(modelsPath, persistedBase, typedBase string) string {
|
||||
//
|
||||
// base "https://h" + "/v1/images/generations" → correct
|
||||
// base "https://h/v1" + "/v1/images/generations" → "/v1/v1/…" 404
|
||||
// base "https://h/v1" + "/images/generations" → "/v1/images/generations" correct
|
||||
//
|
||||
// Emitting "" when the base already ends in a version is wrong for a different
|
||||
// reason: the vendor's catalog path is not proof that its image path carries
|
||||
// the same prefix. Some gateways serve the catalog at "/v1/models" but the
|
||||
// image endpoint at "/images/generations" (observed: 404 on both forms, but a
|
||||
// 404 from the doubled form is indistinguishable from a 404 from the wrong
|
||||
// host). Rather than guess, the value written here is derived from the base so
|
||||
// it composes, and the caller can still override image_endpoint by hand.
|
||||
// The second row is not a theoretical guess. Measured against the real
|
||||
// amr-link endpoint with base_url "https://amr-link.open-design.ai/v1":
|
||||
//
|
||||
// …/v1/images/generations → 200 (the image is then generated; that call
|
||||
// takes minutes, which is the upstream's own
|
||||
// latency and not a routing problem)
|
||||
// …/v1/v1/images/generations → 404
|
||||
// …/images/generations → 404
|
||||
//
|
||||
// Leaving the default in place when the base already ends in a version is
|
||||
// therefore always wrong for such an upstream, and the version-relative form
|
||||
// is the one that composes.
|
||||
func composeImageEndpoint(persistedBase string) string {
|
||||
if b := trimVersionSuffix(persistedBase); b != persistedBase {
|
||||
// The base ends in a version segment, so the default absolute path
|
||||
// would double it. Use the version-relative form instead.
|
||||
return "/images/generations"
|
||||
}
|
||||
return ""
|
||||
|
||||
Reference in New Issue
Block a user