Download packages/core/src/github-copilot/responses/map-openai-responses-finish-reason.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 656 Bytes
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/core/src/github-copilot/responses/map-openai-responses-finish-reason.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/core/src/github-copilot/responses/map-openai-responses-finish-reason.ts
-
curl -L -o map-openai-responses-finish-reason.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/core/src/github-copilot/responses/map-openai-responses-finish-reason.ts
656 Bytes
| import type { LanguageModelV3FinishReason } from "@ai-sdk/provider" | |
| export function mapOpenAIResponseFinishReason({ | |
| finishReason, | |
| hasFunctionCall, | |
| }: { | |
| finishReason: string | null | undefined | |
| // flag that checks if there have been client-side tool calls (not executed by openai) | |
| hasFunctionCall: boolean | |
| }): LanguageModelV3FinishReason["unified"] { | |
| switch (finishReason) { | |
| case undefined: | |
| case null: | |
| return hasFunctionCall ? "tool-calls" : "stop" | |
| case "max_output_tokens": | |
| return "length" | |
| case "content_filter": | |
| return "content-filter" | |
| default: | |
| return hasFunctionCall ? "tool-calls" : "other" | |
| } | |
| } | |