Repository navigation
[bugfix] providers: keep each model's capability check on one line #604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Zhangbo-cn
wants to merge
17
commits into
ThinkFlowLab:main
Choose a base branch
from
Zhangbo-cn:feat/model-capability-row
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+537
−100
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
4a9f643
feat(models): keep service capability detail folded in the service form
Zhangbo-cn 62174e8
[bugfix] providers: keep each model's capability check on one line
Zhangbo-cn 7510d13
refactor(providers): drop the unused draft check wrapper and its dead…
Zhangbo-cn 532c527
Merge remote-tracking branch 'origin/main' into feat/model-capability…
Zhangbo-cn fe1e912
ci: retrigger after a publication-lock timeout in the python lane
Zhangbo-cn 22030fb
Merge remote-tracking branch 'origin/main' into feat/model-capability…
Zhangbo-cn 19f0789
Merge remote-tracking branch 'origin/main' into feat/model-capability…
Zhangbo-cn a17a9d6
fix(providers): fold the capability detail and keep one check entry p…
Zhangbo-cn 9a1a14a
test(providers): target the row summary, not the card's inner summary
Zhangbo-cn 896a191
test(providers): open the row fold before reading the capability card
Zhangbo-cn e7974b3
ci: retrigger the real-CLI worker after a timeout
Zhangbo-cn 420f32f
fix(models): report the folded row outcome, duration and expiry
Zhangbo-cn ff7e556
fix(models): show the row outcome as a compact mark with its duration
Zhangbo-cn 49ad4d0
chore: drop the local dependency symlink
Zhangbo-cn a8ea5a0
Merge remote-tracking branch 'origin/main' into pr-604
Zhangbo-cn ec5e395
[ci] python: list the test modules main added without a shard
Zhangbo-cn 7889c0f
[bugfix] providers: report a failed capability check with its own dur…
Zhangbo-cn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| import { useEffect, useState, type ReactNode } from "react"; | ||
| import { | ||
| availabilityDelay, | ||
| availabilityReason, | ||
| currentAvailability, | ||
| type ModelAvailability, | ||
| } from "../backend/availability.ts"; | ||
| import type { ModelConfigInput } from "../backend/models.ts"; | ||
| import { useT, type Translate } from "../i18n/I18nProvider"; | ||
| import { availabilityNotice } from "./availabilityPresentation"; | ||
| import { useDraftAvailability } from "./DraftAvailabilityCheck"; | ||
| import { ModelAvailabilityCard } from "./ModelAvailabilityCard"; | ||
|
|
||
| type RowOutcome = "passed" | "unsupported" | "unknown" | "expired"; | ||
|
|
||
| const UNSUPPORTED_REASONS = new Set([ | ||
| "operation_unsupported", | ||
| "profile_unsupported", | ||
| "output_unsupported", | ||
| "route_disabled", | ||
| "operation_disabled", | ||
| ]); | ||
|
|
||
| function rowOutcome( | ||
| value: ModelAvailability, | ||
| notice: string | null, | ||
| t: Translate, | ||
| ): { kind: RowOutcome; text: string } { | ||
| if (notice === "observation_expired" || notice === "stale_declaration") | ||
| return { kind: "expired", text: t("availability.rowExpired") }; | ||
| if (notice) | ||
| return { | ||
| kind: UNSUPPORTED_REASONS.has(notice) ? "unsupported" : "unknown", | ||
| text: availabilityReason(notice), | ||
| }; | ||
| const states = new Set(value.operations.map((item) => item.status)); | ||
| if (states.size === 1 && states.has("available")) | ||
| return { kind: "passed", text: t("availability.rowOutcome.passed") }; | ||
| if (states.has("unavailable")) | ||
| return { | ||
| kind: "unsupported", | ||
| text: t("availability.rowOutcome.unsupported"), | ||
| }; | ||
| return { kind: "unknown", text: t("availability.rowOutcome.unknown") }; | ||
| } | ||
|
|
||
| const rowMark: Record<RowOutcome, string> = { | ||
| passed: "✓", | ||
| unsupported: "✕", | ||
| unknown: "?", | ||
| expired: "", | ||
| }; | ||
|
|
||
| function elapsed(ms: number) { | ||
| return ms < 1000 ? `${ms}ms` : `${(ms / 1000).toFixed(1)}s`; | ||
| } | ||
|
|
||
| export function ModelRowDetails({ | ||
| modelId, | ||
| connection, | ||
| configId, | ||
| children, | ||
| }: { | ||
| modelId: string; | ||
| connection: ModelConfigInput; | ||
| configId?: string; | ||
| children: ReactNode; | ||
| }) { | ||
| const t = useT(); | ||
| const draft = useDraftAvailability({ connection, configId, modelId }); | ||
| const [tick, setTick] = useState(0); | ||
| useEffect(() => { | ||
| const delay = draft.value ? availabilityDelay(draft.value) : null; | ||
| if (delay === null) return; | ||
| const timer = setTimeout( | ||
| () => setTick((previous) => previous + 1), | ||
| Math.max(1, delay + 1), | ||
| ); | ||
| return () => clearTimeout(timer); | ||
| }, [draft.value, tick]); | ||
| const current = draft.value ? currentAvailability(draft.value) : null; | ||
| const notice = availabilityNotice(current); | ||
| const outcome = current ? rowOutcome(current, notice, t) : null; | ||
| const duration = | ||
| draft.durationMs === undefined ? "" : elapsed(draft.durationMs); | ||
| const rowLabel = outcome | ||
| ? outcome.kind === "expired" | ||
| ? outcome.text | ||
| : `${rowMark[outcome.kind]}${duration}` | ||
| : undefined; | ||
| const rowTitle = outcome | ||
| ? `${outcome.kind === "expired" && notice ? availabilityReason(notice) : outcome.text}${duration && ` · ${duration}`}` | ||
| : undefined; | ||
| const failureLabel = draft.error | ||
| ? `${t("availability.reason.query_failed")}${duration && ` · ${duration}`}` | ||
| : undefined; | ||
| const showTest = connection.kind !== "agent"; | ||
| return ( | ||
| <> | ||
| {showTest && ( | ||
| <button | ||
| type="button" | ||
| className="cw-settings-button cw-settings-button-quiet cw-model-row-test" | ||
| disabled={draft.checking} | ||
| aria-busy={draft.checking || undefined} | ||
| aria-label={failureLabel ?? rowTitle} | ||
| title={failureLabel ?? rowTitle} | ||
| data-outcome={failureLabel ? "failed" : outcome?.kind} | ||
| onClick={draft.check} | ||
| > | ||
| {draft.checking | ||
| ? t("availability.checking") | ||
| : failureLabel ?? rowLabel ?? t("availability.rowTest")} | ||
| </button> | ||
| )} | ||
| <details className="cw-model-row-details"> | ||
| <summary>{t("models.service.capabilityDetails")}</summary> | ||
| <ModelAvailabilityCard | ||
| value={draft.value} | ||
| checking={draft.checking} | ||
| error={draft.error} | ||
| actions={false} | ||
| /> | ||
| {children} | ||
| </details> | ||
| </> | ||
| ); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里插入的是旧版显式
core列表,main 的 #700 已经把整段换成默认 core。GitHub 现在报dirty。解决时保留default_shard: core,Ark/trace 让默认规则收集就行;不要恢复整份 core 清单。