The sentence a refused or failed turn shows instead of an answer.
(turn: ChatTurn)
| 130 | |
| 131 | /** The sentence a refused or failed turn shows instead of an answer. */ |
| 132 | function messageOf(turn: ChatTurn): string { |
| 133 | switch (turn.status) { |
| 134 | case 'compiling': |
| 135 | return CHAT_COMPILING; |
| 136 | case 'asking': |
| 137 | return CHAT_ASKING; |
| 138 | case 'refused': |
| 139 | return turn.refusal === 'policy' |
| 140 | ? CHAT_POLICY_MESSAGE |
| 141 | : turn.refusal === 'not-running' |
| 142 | ? CHAT_NOT_RUNNING_MESSAGE |
| 143 | : CHAT_OFF_MESSAGE; |
| 144 | case 'failed': |
| 145 | return chatFailed(turn.message); |
| 146 | case 'no-cards': |
| 147 | return CHAT_NO_CARDS_HINT; |
| 148 | // The candidate list says it better than a sentence beside it could. |
| 149 | case 'needs-choice': |
| 150 | return ''; |
| 151 | default: { |
| 152 | const unavailable = /^model-(off|not-running|policy)$/.exec(turn.message); |
| 153 | return turn.message === 'thought-only' ? CHAT_THOUGHT_ONLY |
| 154 | : unavailable === null ? '' |
| 155 | : chatBuiltUnavailableMessage(unavailable[1] as 'off' | 'not-running' | 'policy'); |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | /** One card, as the fold shows it. */ |
| 161 | function CardRow(props: { card: Card; onOpen: (source: CardSource) => void }): JSX.Element { |
no test coverage detected