({ limit, automatic, chat, model, onChangeOutput }: LimitNote)
| 128 | * maximum a larger model stops at the same limit (W6). */ |
| 129 | interface LimitNote { limit: TokenLimits; automatic?: boolean; chat: TokenLimits; model: BrowserModel; onChangeOutput: () => void } |
| 130 | function TokenLimitNote({ limit, automatic, chat, model, onChangeOutput }: LimitNote): JSX.Element { |
| 131 | const larger = BROWSER_MODELS.filter(candidate => candidate.availability === 'available' && candidate.bytes > model.bytes); |
| 132 | const sameLimit = larger.every(candidate => candidate.maxOutputTokens <= model.maxOutputTokens); |
| 133 | const atMaximum = chat.outputTokens >= model.maxOutputTokens; |
| 134 | const raise = automatic ? chat.outputTokens < AUTO_OUTPUT_TOKENS : !atMaximum; |
| 135 | return <details className="cbm-chat-limit-note"> |
| 136 | <summary>{browserChatText.shortened}</summary> |
| 137 | <p>{automatic ? browserChatText.limitAutomatic(limit.inputTokens, limit.outputTokens, chat.inputTokens, chat.outputTokens, AUTO_OUTPUT_TOKENS) : browserChatText.limitReached(limit.inputTokens, limit.outputTokens)}</p> |
| 138 | {automatic ? raise && <p>{browserChatText.automaticRoom(AUTO_OUTPUT_TOKENS)}</p> : <p>{browserChatText.outputRoom(chat.outputTokens, model.maxOutputTokens)}</p>} |
| 139 | {!automatic && atMaximum && sameLimit && <p>{browserChatText.narrower(larger.length > 0)}</p>} |
| 140 | {/* At its maximum the limit cannot be raised, so there is nothing to change (C8). */} |
| 141 | {raise && <button type="button" onClick={onChangeOutput}>{browserChatText.changeOutputLimit}</button>} |
| 142 | {!automatic && larger.length > 0 && (!atMaximum || !sameLimit) && <><p>{browserChatText.largerModels(sameLimit)}</p> |
| 143 | <ul>{larger.map(candidate => <li key={candidate.id}>{browserChatText.modelDownload(candidate.displayName, sizeLabel(candidate.bytes))}</li>)}</ul></>} |
| 144 | </details>; |
| 145 | } |
| 146 | |
| 147 | /** How an answer was bounded: cut at the output limit, scope too large, history left out, |
| 148 | * and which of its names the model was not given. */ |
nothing calls this directly
no test coverage detected