Spaces:
Running
Running
Download src/openai_patch.ts from Wauplin/responses.js: direct link, hf CLI and curl.
- Browser
- Download file 1.3 kB
-
https://huggingface.co/spaces/Wauplin/responses.js/resolve/refs%2Fpr%2F1/src/openai_patch.ts
- Command line
-
hf download hf://spaces/Wauplin/responses.js@refs/pr/1/src/openai_patch.ts
-
curl -L -o openai_patch.ts https://huggingface.co/spaces/Wauplin/responses.js/resolve/refs%2Fpr%2F1/src/openai_patch.ts
1.3 kB
| /* | |
| * This file is a patch to the openai library to add support for the reasoning parameter. | |
| * Once openai's official JS SDK supports sending back raw CoT, we will remove this file. | |
| */ | |
| import type { | |
| ResponseReasoningItem as OpenAIResponseReasoningItem, | |
| ResponseStreamEvent as OpenAIResponseStreamEvent, | |
| ResponseOutputRefusal, | |
| ResponseOutputText, | |
| } from "openai/resources/responses/responses"; | |
| export interface ReasoningTextContent { | |
| type: "reasoning_text"; | |
| text: string; | |
| } | |
| export type PatchedResponseReasoningItem = OpenAIResponseReasoningItem & { | |
| // Raw CoT returned in reasoning item (in addition to the summary) | |
| content: ReasoningTextContent[]; | |
| }; | |
| interface PatchedResponseReasoningTextDeltaEvent { | |
| type: "response.reasoning_text.delta"; | |
| sequence_number: number; | |
| item_id: string; | |
| output_index: number; | |
| content_index: number; | |
| delta: string; | |
| } | |
| interface PatchedResponseReasoningTextDoneEvent { | |
| type: "response.reasoning_text.done"; | |
| sequence_number: number; | |
| item_id: string; | |
| output_index: number; | |
| content_index: number; | |
| text: string; | |
| } | |
| export type PatchedResponseStreamEvent = | |
| | OpenAIResponseStreamEvent | |
| | PatchedResponseReasoningTextDeltaEvent | |
| | PatchedResponseReasoningTextDoneEvent; | |
| export type PatchedResponseContentPart = ResponseOutputText | ResponseOutputRefusal; | |