@ahoo-wang/fetcher-openai 2.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +1223 -0
- package/README.zh-CN.md +1217 -0
- package/dist/chat/chatClient.d.ts +225 -0
- package/dist/chat/chatClient.d.ts.map +1 -0
- package/dist/chat/completionStreamResultExtractor.d.ts +67 -0
- package/dist/chat/completionStreamResultExtractor.d.ts.map +1 -0
- package/dist/chat/index.d.ts +4 -0
- package/dist/chat/index.d.ts.map +1 -0
- package/dist/chat/types.d.ts +114 -0
- package/dist/chat/types.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.es.js +128 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +2 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/openai.d.ts +82 -0
- package/dist/openai.d.ts.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/chat/completionStreamResultExtractor.ts","../src/chat/chatClient.ts","../src/openai.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FetchExchange, ResultExtractor } from '@ahoo-wang/fetcher';\nimport '@ahoo-wang/fetcher-eventstream';\nimport {\n JsonServerSentEventStream,\n ServerSentEvent,\n TerminateDetector,\n} from '@ahoo-wang/fetcher-eventstream';\nimport { ChatResponse } from './types';\n\n/**\n * A termination detector for OpenAI chat completion streams.\n *\n * This detector identifies when a chat completion stream has finished by checking\n * if the server-sent event data equals '[DONE]'. This is the standard completion\n * signal used by OpenAI's API for streaming chat completions.\n *\n * @param event - The server-sent event to evaluate for termination\n * @returns true if the event indicates stream completion, false otherwise\n *\n * @example\n * ```typescript\n * const event: ServerSentEvent = { data: '[DONE]', event: 'done' };\n * const isDone = DoneDetector(event); // returns true\n * ```\n */\nexport const DoneDetector: TerminateDetector = (event: ServerSentEvent) => {\n return event.data === '[DONE]';\n};\n\n/**\n * Result extractor for OpenAI chat completion streaming responses.\n *\n * This extractor processes HTTP responses from OpenAI's chat completion API endpoints\n * that return streaming responses. It converts the response into a JSON server-sent\n * event stream that automatically terminates when the completion is finished.\n *\n * The extractor uses the DoneDetector to identify completion signals and ensures\n * the response is properly formatted as a server-sent event stream with JSON data.\n *\n * @param exchange - The fetch exchange containing the HTTP response from OpenAI's API\n * @returns A JSON server-sent event stream of ChatResponse objects that terminates on completion\n * @throws {EventStreamConvertError} If the response is not a valid event stream or has incorrect content type\n *\n * @example\n * ```typescript\n * import { fetcher } from '@ahoo-wang/fetcher';\n * import { CompletionStreamResultExtractor } from '@ahoo-wang/fetcher-openai';\n *\n * const response = await fetcher.post('/chat/completions', {\n * model: 'gpt-3.5-turbo',\n * messages: [{ role: 'user', content: 'Hello!' }],\n * stream: true\n * });\n *\n * const stream = CompletionStreamResultExtractor(response);\n *\n * for await (const event of stream) {\n * console.log('Received:', event.data);\n * // Stream automatically terminates when '[DONE]' is received\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Using with fetcher configuration\n * const fetcherWithExtractor = fetcher.extend({\n * resultExtractor: CompletionStreamResultExtractor\n * });\n *\n * const stream = await fetcherWithExtractor.post('/chat/completions', {\n * // ... request options\n * });\n * ```\n */\nexport const CompletionStreamResultExtractor: ResultExtractor<\n JsonServerSentEventStream<ChatResponse>\n> = (exchange: FetchExchange) => {\n return exchange.requiredResponse.requiredJsonEventStream(DoneDetector);\n};\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n api,\n type ApiMetadata,\n ApiMetadataCapable,\n autoGeneratedError,\n body,\n ExecuteLifeCycle,\n post,\n} from '@ahoo-wang/fetcher-decorator';\nimport { JsonServerSentEventStream } from '@ahoo-wang/fetcher-eventstream';\nimport { FetchExchange } from '@ahoo-wang/fetcher';\nimport { ChatRequest, ChatResponse } from './types';\nimport { CompletionStreamResultExtractor } from './completionStreamResultExtractor';\n\n/**\n * OpenAI Chat API Client\n *\n * A comprehensive client for OpenAI's Chat Completions API that provides type-safe integration\n * with both streaming and non-streaming chat completion endpoints. This client leverages the\n * fetcher-decorator pattern to enable declarative API definitions and automatic request/response\n * handling.\n *\n * Key Features:\n * - Type-safe request/response handling with TypeScript generics\n * - Automatic streaming response processing for server-sent events\n * - Lifecycle hooks for request preprocessing and response transformation\n * - Support for all OpenAI Chat Completion API parameters\n * - Conditional return types based on streaming configuration\n *\n * @implements {ApiMetadataCapable} - Supports API metadata configuration\n * @implements {ExecuteLifeCycle} - Provides lifecycle hooks for request processing\n *\n * @example\n * ```typescript\n * import { ChatClient } from '@ahoo-wang/fetcher-openai';\n *\n * const client = new ChatClient({\n * baseURL: 'https://api.openai.com/v1',\n * headers: {\n * 'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`\n * }\n * });\n *\n * // Non-streaming completion\n * const response = await client.completions({\n * model: 'gpt-3.5-turbo',\n * messages: [{ role: 'user', content: 'Hello, world!' }]\n * });\n *\n * // Streaming completion\n * const stream = await client.completions({\n * model: 'gpt-3.5-turbo',\n * messages: [{ role: 'user', content: 'Tell me a story' }],\n * stream: true\n * });\n *\n * for await (const chunk of stream) {\n * console.log(chunk.choices[0]?.delta?.content || '');\n * }\n * ```\n */\n@api('chat')\nexport class ChatClient implements ApiMetadataCapable, ExecuteLifeCycle {\n /**\n * Creates a new ChatClient instance with optional API configuration.\n *\n * The API metadata allows customization of request behavior such as base URLs,\n * default headers, timeout settings, and other fetcher configuration options.\n * This enables flexible deployment scenarios (e.g., custom API endpoints, proxy configurations).\n *\n * @param apiMetadata - Optional configuration object for customizing API behavior.\n * Includes baseURL, headers, timeout, and other fetcher options.\n * If not provided, uses default fetcher configuration.\n *\n * @example\n * ```typescript\n * // Basic usage with default configuration\n * const client = new ChatClient();\n *\n * // With custom API endpoint and authentication\n * const client = new ChatClient({\n * baseURL: 'https://api.openai.com/v1',\n * headers: {\n * 'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`,\n * 'Content-Type': 'application/json'\n * },\n * timeout: 30000\n * });\n *\n * // With custom fetcher configuration\n * const client = new ChatClient({\n * baseURL: 'https://custom-openai-proxy.com/api',\n * interceptors: [customAuthInterceptor]\n * });\n * ```\n */\n constructor(public readonly apiMetadata?: ApiMetadata) {}\n\n /**\n * Lifecycle hook executed before request processing.\n *\n * This method implements the ExecuteLifeCycle interface and is automatically called by the\n * fetcher-decorator framework before each API request. It inspects the chat request to determine\n * whether streaming is requested and configures the appropriate result extractor accordingly.\n *\n * The method performs dynamic result extractor assignment:\n * - For streaming requests (`stream: true`): Assigns `CompletionStreamResultExtractor` to handle\n * server-sent event streams with automatic termination detection\n * - For non-streaming requests (`stream: false` or undefined): Uses the default JSON extractor\n * for standard JSON response parsing\n *\n * This approach enables type-safe conditional return types while maintaining clean API design.\n *\n * @param exchange - The fetch exchange object containing request details, response information,\n * and configuration that can be modified before execution\n *\n * @example\n * ```typescript\n * // This method is called automatically by the framework\n * // No manual invocation needed - shown for illustration:\n *\n * const exchange = {\n * request: { body: { stream: true, messages: [...] } },\n * resultExtractor: undefined // Will be set by beforeExecute\n * };\n *\n * client.beforeExecute(exchange);\n * // exchange.resultExtractor is now CompletionStreamResultExtractor\n * ```\n */\n beforeExecute(exchange: FetchExchange): void {\n const chatRequest = exchange.request.body as ChatRequest;\n if (chatRequest.stream) {\n exchange.resultExtractor = CompletionStreamResultExtractor;\n }\n }\n\n /**\n * Creates a chat completion using OpenAI's Chat Completions API.\n *\n * This is the primary method for interacting with OpenAI's chat completion models.\n * It supports both synchronous and streaming response modes, automatically handling\n * the appropriate response processing based on the `stream` parameter.\n *\n * The method uses advanced TypeScript conditional types to provide type-safe return values:\n * - When `stream: true`, returns a `JsonServerSentEventStream<ChatResponse>` for real-time streaming\n * - When `stream: false` or omitted, returns a standard `ChatResponse` object\n *\n * Streaming responses automatically terminate when the API sends a '[DONE]' signal,\n * eliminating the need for manual stream management.\n *\n * @template T - The chat request type, constrained to ChatRequest for type safety\n * @param chatRequest - Complete chat request configuration including:\n * - `model`: The model to use (e.g., 'gpt-3.5-turbo', 'gpt-4')\n * - `messages`: Array of chat messages with role/content pairs\n * - `stream`: Optional boolean to enable streaming responses\n * - `temperature`: Optional creativity control (0.0 to 2.0)\n * - `max_tokens`: Optional maximum response length\n * - `top_p`: Optional nucleus sampling parameter\n * - `frequency_penalty`: Optional repetition control (-2.0 to 2.0)\n * - `presence_penalty`: Optional topic diversity control (-2.0 to 2.0)\n * - `stop`: Optional stop sequences (string or string array)\n * - Additional OpenAI API parameters as needed\n * @returns Promise resolving to:\n * - `JsonServerSentEventStream<ChatResponse>` when `T['stream'] extends true`\n * - `ChatResponse` when streaming is disabled or undefined\n * @throws {Error} Network errors, authentication failures, or API errors\n * @throws {EventStreamConvertError} When streaming response cannot be processed\n *\n * @example\n * ```typescript\n * // Basic non-streaming completion\n * const response = await client.completions({\n * model: 'gpt-3.5-turbo',\n * messages: [\n * { role: 'system', content: 'You are a helpful assistant.' },\n * { role: 'user', content: 'What is TypeScript?' }\n * ],\n * temperature: 0.7,\n * max_tokens: 150\n * });\n *\n * console.log(response.choices[0].message.content);\n * // Output: TypeScript is a programming language developed by Microsoft...\n * ```\n *\n * @example\n * ```typescript\n * // Streaming completion with real-time output\n * const stream = await client.completions({\n * model: 'gpt-4',\n * messages: [{ role: 'user', content: 'Write a short story' }],\n * stream: true,\n * temperature: 0.8\n * });\n *\n * for await (const chunk of stream) {\n * const content = chunk.choices[0]?.delta?.content;\n * if (content) {\n * process.stdout.write(content); // Real-time streaming output\n * }\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Advanced configuration with multiple parameters\n * const response = await client.completions({\n * model: 'gpt-3.5-turbo',\n * messages: [{ role: 'user', content: 'Explain quantum computing' }],\n * temperature: 0.3, // Lower temperature for more focused responses\n * max_tokens: 500, // Limit response length\n * top_p: 0.9, // Nucleus sampling\n * frequency_penalty: 0.1, // Reduce repetition\n * presence_penalty: 0.1, // Encourage topic diversity\n * stop: ['###', 'END'] // Custom stop sequences\n * });\n * ```\n *\n * @example\n * ```typescript\n * // Error handling\n * try {\n * const response = await client.completions({\n * model: 'gpt-3.5-turbo',\n * messages: [{ role: 'user', content: 'Hello!' }]\n * });\n * console.log('Success:', response);\n * } catch (error) {\n * if (error.response?.status === 401) {\n * console.error('Authentication failed - check API key');\n * } else if (error.response?.status === 429) {\n * console.error('Rate limit exceeded - retry later');\n * } else {\n * console.error('API error:', error.message);\n * }\n * }\n * ```\n */\n @post('/completions')\n completions<T extends ChatRequest = ChatRequest>(\n @body() chatRequest: T,\n ): Promise<\n T['stream'] extends true\n ? JsonServerSentEventStream<ChatResponse>\n : ChatResponse\n > {\n throw autoGeneratedError(chatRequest);\n }\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ChatClient } from './chat';\nimport { BaseURLCapable, Fetcher } from '@ahoo-wang/fetcher';\n\n/**\n * Configuration options for the OpenAI client.\n *\n * This interface defines the required settings to initialize an OpenAI client instance,\n * including the API endpoint and authentication credentials.\n */\nexport interface OpenAIOptions extends BaseURLCapable {\n /**\n * The base URL for the OpenAI API.\n *\n * This should be the root URL of the OpenAI API service (e.g., 'https://api.openai.com/v1').\n * It is used as the base for all API requests made by the client.\n */\n baseURL: string;\n\n /**\n * The API key for authenticating requests to the OpenAI API.\n *\n * This key must be a valid OpenAI API key obtained from the OpenAI platform.\n * It is included in the Authorization header as a Bearer token for all requests.\n */\n apiKey: string;\n}\n\n/**\n * OpenAI client class for interacting with the OpenAI API.\n *\n * This class provides a high-level interface to the OpenAI API, encapsulating HTTP client\n * functionality and specialized clients for different API features. It serves as the main entry\n * point for applications needing to integrate with OpenAI services.\n *\n * @example\n * ```typescript\n * const client = new OpenAI({\n * baseURL: 'https://api.openai.com/v1',\n * apiKey: 'your-api-key-here'\n * });\n *\n * // Use the chat client for completions\n * const response = await client.chat.completions.create({\n * model: 'gpt-3.5-turbo',\n * messages: [{ role: 'user', content: 'Hello!' }]\n * });\n * ```\n */\nexport class OpenAI {\n /**\n * HTTP client instance for making requests to the OpenAI API.\n *\n * This Fetcher instance is configured with the base URL and authentication headers\n * provided during initialization. It handles all underlying HTTP communication.\n */\n public readonly fetcher: Fetcher;\n\n /**\n * Chat completion client for interacting with OpenAI's chat models.\n *\n * Provides methods to create chat completions, manage conversations, and handle\n * streaming responses from chat-based models like GPT-3.5 and GPT-4.\n */\n public readonly chat: ChatClient;\n\n /**\n * Creates an instance of the OpenAI client.\n *\n * Initializes the client with the provided configuration options, setting up the\n * HTTP client with proper authentication and creating specialized sub-clients\n * for different API features.\n *\n * @param options - Configuration options for the OpenAI client.\n * @throws {Error} If the provided options are invalid or missing required fields.\n * @throws {TypeError} If the apiKey or baseURL are not strings.\n *\n * @example\n * ```typescript\n * const openai = new OpenAI({\n * baseURL: 'https://api.openai.com/v1',\n * apiKey: process.env.OPENAI_API_KEY!\n * });\n * ```\n */\n constructor(options: OpenAIOptions) {\n this.fetcher = new Fetcher({\n baseURL: options.baseURL,\n headers: {\n Authorization: `Bearer ${options.apiKey}`,\n },\n });\n this.chat = new ChatClient({ fetcher: this.fetcher });\n }\n}\n"],"names":["DoneDetector","event","CompletionStreamResultExtractor","exchange","ChatClient","apiMetadata","chatRequest","autoGeneratedError","__decorateClass","post","__decorateParam","body","api","OpenAI","options","Fetcher"],"mappings":"meAsCO,MAAMA,EAAmCC,GACvCA,EAAM,OAAS,SAgDXC,EAERC,GACIA,EAAS,iBAAiB,wBAAwBH,CAAY,2NCf1DI,EAAAA,WAAN,KAAiE,CAkCtE,YAA4BC,EAA2B,CAA3B,KAAA,YAAAA,CAA4B,CAkCxD,cAAcF,EAA+B,CACvBA,EAAS,QAAQ,KACrB,SACdA,EAAS,gBAAkBD,EAE/B,CAyGA,YACUI,EAKR,CACA,MAAMC,EAAAA,mBAAmBD,CAAW,CACtC,CACF,EATEE,EAAA,CADCC,EAAAA,KAAK,cAAc,EAEjBC,EAAA,EAAAC,OAAA,CAAK,CAAA,EAnLGP,aAkLX,UAAA,cAAA,CAAA,EAlLWA,EAAAA,WAANI,EAAA,CADNI,EAAAA,IAAI,MAAM,CAAA,EACER,YAAA,ECdN,MAAMS,CAAO,CAoClB,YAAYC,EAAwB,CAClC,KAAK,QAAU,IAAIC,UAAQ,CACzB,QAASD,EAAQ,QACjB,QAAS,CACP,cAAe,UAAUA,EAAQ,MAAM,EAAA,CACzC,CACD,EACD,KAAK,KAAO,IAAIV,EAAAA,WAAW,CAAE,QAAS,KAAK,QAAS,CACtD,CACF"}
|
package/dist/openai.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ChatClient } from './chat';
|
|
2
|
+
import { BaseURLCapable, Fetcher } from '@ahoo-wang/fetcher';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for the OpenAI client.
|
|
5
|
+
*
|
|
6
|
+
* This interface defines the required settings to initialize an OpenAI client instance,
|
|
7
|
+
* including the API endpoint and authentication credentials.
|
|
8
|
+
*/
|
|
9
|
+
export interface OpenAIOptions extends BaseURLCapable {
|
|
10
|
+
/**
|
|
11
|
+
* The base URL for the OpenAI API.
|
|
12
|
+
*
|
|
13
|
+
* This should be the root URL of the OpenAI API service (e.g., 'https://api.openai.com/v1').
|
|
14
|
+
* It is used as the base for all API requests made by the client.
|
|
15
|
+
*/
|
|
16
|
+
baseURL: string;
|
|
17
|
+
/**
|
|
18
|
+
* The API key for authenticating requests to the OpenAI API.
|
|
19
|
+
*
|
|
20
|
+
* This key must be a valid OpenAI API key obtained from the OpenAI platform.
|
|
21
|
+
* It is included in the Authorization header as a Bearer token for all requests.
|
|
22
|
+
*/
|
|
23
|
+
apiKey: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* OpenAI client class for interacting with the OpenAI API.
|
|
27
|
+
*
|
|
28
|
+
* This class provides a high-level interface to the OpenAI API, encapsulating HTTP client
|
|
29
|
+
* functionality and specialized clients for different API features. It serves as the main entry
|
|
30
|
+
* point for applications needing to integrate with OpenAI services.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const client = new OpenAI({
|
|
35
|
+
* baseURL: 'https://api.openai.com/v1',
|
|
36
|
+
* apiKey: 'your-api-key-here'
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* // Use the chat client for completions
|
|
40
|
+
* const response = await client.chat.completions.create({
|
|
41
|
+
* model: 'gpt-3.5-turbo',
|
|
42
|
+
* messages: [{ role: 'user', content: 'Hello!' }]
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare class OpenAI {
|
|
47
|
+
/**
|
|
48
|
+
* HTTP client instance for making requests to the OpenAI API.
|
|
49
|
+
*
|
|
50
|
+
* This Fetcher instance is configured with the base URL and authentication headers
|
|
51
|
+
* provided during initialization. It handles all underlying HTTP communication.
|
|
52
|
+
*/
|
|
53
|
+
readonly fetcher: Fetcher;
|
|
54
|
+
/**
|
|
55
|
+
* Chat completion client for interacting with OpenAI's chat models.
|
|
56
|
+
*
|
|
57
|
+
* Provides methods to create chat completions, manage conversations, and handle
|
|
58
|
+
* streaming responses from chat-based models like GPT-3.5 and GPT-4.
|
|
59
|
+
*/
|
|
60
|
+
readonly chat: ChatClient;
|
|
61
|
+
/**
|
|
62
|
+
* Creates an instance of the OpenAI client.
|
|
63
|
+
*
|
|
64
|
+
* Initializes the client with the provided configuration options, setting up the
|
|
65
|
+
* HTTP client with proper authentication and creating specialized sub-clients
|
|
66
|
+
* for different API features.
|
|
67
|
+
*
|
|
68
|
+
* @param options - Configuration options for the OpenAI client.
|
|
69
|
+
* @throws {Error} If the provided options are invalid or missing required fields.
|
|
70
|
+
* @throws {TypeError} If the apiKey or baseURL are not strings.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const openai = new OpenAI({
|
|
75
|
+
* baseURL: 'https://api.openai.com/v1',
|
|
76
|
+
* apiKey: process.env.OPENAI_API_KEY!
|
|
77
|
+
* });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
constructor(options: OpenAIOptions);
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../src/openai.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,WAAW,aAAc,SAAQ,cAAc;IACnD;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,MAAM;IACjB;;;;;OAKG;IACH,SAAgB,OAAO,EAAE,OAAO,CAAC;IAEjC;;;;;OAKG;IACH,SAAgB,IAAI,EAAE,UAAU,CAAC;IAEjC;;;;;;;;;;;;;;;;;;OAkBG;gBACS,OAAO,EAAE,aAAa;CASnC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ahoo-wang/fetcher-openai",
|
|
3
|
+
"version": "2.9.8",
|
|
4
|
+
"description": "Type-safe OpenAI API client for Fetcher ecosystem. Provides seamless integration with OpenAI's Chat Completions API, supporting both streaming and non-streaming responses with full TypeScript support.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"openai",
|
|
7
|
+
"chatgpt",
|
|
8
|
+
"gpt",
|
|
9
|
+
"ai",
|
|
10
|
+
"llm",
|
|
11
|
+
"chat-completions",
|
|
12
|
+
"streaming",
|
|
13
|
+
"typescript",
|
|
14
|
+
"fetch",
|
|
15
|
+
"http",
|
|
16
|
+
"client",
|
|
17
|
+
"declarative",
|
|
18
|
+
"type-safe",
|
|
19
|
+
"api"
|
|
20
|
+
],
|
|
21
|
+
"author": "Ahoo-Wang",
|
|
22
|
+
"license": "Apache-2.0",
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=16.0.0"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/Ahoo-Wang/fetcher/tree/master/packages/openai",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "https://github.com/Ahoo-Wang/fetcher.git",
|
|
30
|
+
"directory": "packages/openai"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/Ahoo-Wang/fetcher/issues"
|
|
34
|
+
},
|
|
35
|
+
"type": "module",
|
|
36
|
+
"main": "./dist/index.umd.js",
|
|
37
|
+
"module": "./dist/index.es.js",
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"exports": {
|
|
40
|
+
".": {
|
|
41
|
+
"types": "./dist/index.d.ts",
|
|
42
|
+
"import": "./dist/index.es.js",
|
|
43
|
+
"require": "./dist/index.umd.js"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"dist"
|
|
48
|
+
],
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@ahoo-wang/fetcher": "^2.9.3",
|
|
51
|
+
"@ahoo-wang/fetcher-eventstream": "^2.9.8",
|
|
52
|
+
"@ahoo-wang/fetcher-decorator": "^2.9.6"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@eslint/js": "^9.37.0",
|
|
56
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
57
|
+
"@vitest/ui": "^3.2.4",
|
|
58
|
+
"eslint": "^9.37.0",
|
|
59
|
+
"globals": "^16.4.0",
|
|
60
|
+
"prettier": "^3.6.2",
|
|
61
|
+
"typescript": "^5.9.3",
|
|
62
|
+
"typescript-eslint": "^8.46.1",
|
|
63
|
+
"unplugin-dts": "1.0.0-beta.6",
|
|
64
|
+
"vite": "^7.1.10",
|
|
65
|
+
"vite-bundle-analyzer": "^1.2.3",
|
|
66
|
+
"vitest": "^3.2.4",
|
|
67
|
+
"msw": "^2.11.3",
|
|
68
|
+
"@ahoo-wang/fetcher-eventbus": "^2.9.8",
|
|
69
|
+
"@ahoo-wang/fetcher-react": "^2.9.8",
|
|
70
|
+
"@ahoo-wang/fetcher-storage": "^2.9.8"
|
|
71
|
+
},
|
|
72
|
+
"scripts": {
|
|
73
|
+
"build": "vite build",
|
|
74
|
+
"test:ui": "vitest --ui",
|
|
75
|
+
"test": "vitest run --coverage",
|
|
76
|
+
"lint": "eslint . --fix",
|
|
77
|
+
"clean": "rm -rf dist",
|
|
78
|
+
"analyze": "npx vite-bundle-analyzer -p auto"
|
|
79
|
+
}
|
|
80
|
+
}
|