MCPcopy Create free account
hub / github.com/Noumena-Network/code / mapStopReason

Function mapStopReason

src/services/api/openAICompatInferenceClient.ts:284–299  ·  view source on GitHub ↗
(
  finishReason: string | null | undefined,
)

Source from the content-addressed store, hash-verified

282}
283
284function mapStopReason(
285 finishReason: string | null | undefined,
286): BetaMessage['stop_reason'] {
287 switch (finishReason) {
288 case 'stop':
289 return 'end_turn'
290 case 'length':
291 return 'max_tokens'
292 case 'tool_calls':
293 return 'tool_use'
294 case 'content_filter':
295 return 'stop_sequence'
296 default:
297 return null
298 }
299}
300
301function normalizeStopSequence(matchedStop: unknown): string | null {
302 if (typeof matchedStop !== 'string') {

Calls

no outgoing calls

Tested by

no test coverage detected