Spaces:
Paused
Paused
Download src/lib/server/textGeneration/utils/routing.ts from Mike0021/chat-ui-agent-demo: direct link, hf CLI and curl.
- Browser
- Download file 693 Bytes
-
https://huggingface.co/spaces/Mike0021/chat-ui-agent-demo/resolve/main/src/lib/server/textGeneration/utils/routing.ts
- Command line
-
hf download hf://spaces/Mike0021/chat-ui-agent-demo/src/lib/server/textGeneration/utils/routing.ts
-
curl -L -o routing.ts https://huggingface.co/spaces/Mike0021/chat-ui-agent-demo/resolve/main/src/lib/server/textGeneration/utils/routing.ts
693 Bytes
| import type { EndpointMessage } from "../../endpoints/endpoints"; | |
| const ROUTER_REASONING_REGEX = /<think>[\s\S]*?(?:<\/think>|$)/g; | |
| export function stripReasoningBlocks(text: string): string { | |
| const stripped = text.replace(ROUTER_REASONING_REGEX, ""); | |
| return stripped === text ? text : stripped.trim(); | |
| } | |
| export function stripReasoningFromMessageForRouting(message: EndpointMessage): EndpointMessage { | |
| const clone = { ...message } as EndpointMessage & { reasoning?: string }; | |
| if ("reasoning" in clone) { | |
| delete clone.reasoning; | |
| } | |
| const content = | |
| typeof message.content === "string" ? stripReasoningBlocks(message.content) : message.content; | |
| return { | |
| ...clone, | |
| content, | |
| }; | |
| } | |