@leikeduntech/leiai-js 4.0.3 → 4.1.0

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/build/index.d.ts CHANGED
@@ -169,7 +169,6 @@ declare namespace openai {
169
169
  delta: {
170
170
  role: Role;
171
171
  content?: string;
172
- reasoning_content?: string;
173
172
  };
174
173
  index: number;
175
174
  finish_reason: string | null;
@@ -203,17 +202,29 @@ declare namespace openai {
203
202
  */
204
203
  role?: ChatCompletionRequestMessageRoleEnum;
205
204
  /**
206
- * The contents of the message
207
- * @type {string}
205
+ * The contents of the message. Can be a string or an array of content parts (text, images, etc.)
206
+ * @type {string | Array<any>}
208
207
  * @memberof ChatCompletionRequestMessage
209
208
  */
210
- content?: string;
209
+ content?: string | Array<any>;
211
210
  /**
212
211
  * The name of the user in a multi-user chat
213
212
  * @type {string}
214
213
  * @memberof ChatCompletionRequestMessage
215
214
  */
216
215
  name?: string;
216
+ /**
217
+ * Tool call ID for tool role messages
218
+ * @type {string}
219
+ * @memberof ChatCompletionRequestMessage
220
+ */
221
+ tool_call_id?: string;
222
+ /**
223
+ * Tool calls made by the assistant
224
+ * @type {Array<any>}
225
+ * @memberof ChatCompletionRequestMessage
226
+ */
227
+ tool_calls?: Array<any>;
217
228
  /**
218
229
  * 阿里云的参数 input = {prompt: '哪个公园距离我更近', history: [
219
230
  *
@@ -236,7 +247,6 @@ declare namespace openai {
236
247
  * ]}
237
248
  */
238
249
  input?: object;
239
- tool_call_id?: string;
240
250
  }
241
251
  const ChatCompletionRequestMessageRoleEnum: {
242
252
  readonly System: 'system';
@@ -262,7 +272,31 @@ declare namespace openai {
262
272
  * @type {string}
263
273
  * @memberof ChatCompletionResponseMessage
264
274
  */
265
- content: string;
275
+ content: string | null;
276
+ /**
277
+ * Tool calls made by the assistant
278
+ * @type {Array<any>}
279
+ * @memberof ChatCompletionResponseMessage
280
+ */
281
+ tool_calls?: Array<any> | null;
282
+ /**
283
+ * Deprecated: Use tool_calls instead
284
+ * @type {object}
285
+ * @memberof ChatCompletionResponseMessage
286
+ */
287
+ function_call?: object | null;
288
+ /**
289
+ * Refusal information
290
+ * @type {string | null}
291
+ * @memberof ChatCompletionResponseMessage
292
+ */
293
+ refusal?: string | null;
294
+ /**
295
+ * Annotations
296
+ * @type {Array<any>}
297
+ * @memberof ChatCompletionResponseMessage
298
+ */
299
+ annotations?: Array<any> | null;
266
300
  }
267
301
  const ChatCompletionResponseMessageRoleEnum: {
268
302
  readonly System: 'system';
@@ -277,7 +311,7 @@ declare namespace openai {
277
311
  */
278
312
  interface CreateChatCompletionRequest {
279
313
  /**
280
- * ID of the model to use. Currently, only `gpt-3.5-turbo` and `gpt-3.5-turbo-0301` are supported.
314
+ * ID of the model to use.
281
315
  * @type {string}
282
316
  * @memberof CreateChatCompletionRequest
283
317
  */
@@ -313,17 +347,29 @@ declare namespace openai {
313
347
  */
314
348
  stream?: boolean | null;
315
349
  /**
316
- *
350
+ * Options for streaming response. Only set this when you set `stream: true`.
351
+ * @type {object}
352
+ * @memberof CreateChatCompletionRequest
353
+ */
354
+ stream_options?: object | null;
355
+ /**
356
+ * Up to 4 sequences where the API will stop generating further tokens.
317
357
  * @type {CreateChatCompletionRequestStop}
318
358
  * @memberof CreateChatCompletionRequest
319
359
  */
320
360
  stop?: CreateChatCompletionRequestStop;
321
361
  /**
322
- * The maximum number of tokens allowed for the generated answer. By default, the number of tokens the model can return will be (4096 - prompt tokens).
362
+ * The maximum number of tokens allowed for the generated answer. Deprecated in favor of `max_completion_tokens`.
323
363
  * @type {number}
324
364
  * @memberof CreateChatCompletionRequest
325
365
  */
326
- max_tokens?: number;
366
+ max_tokens?: number | null;
367
+ /**
368
+ * An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.
369
+ * @type {number}
370
+ * @memberof CreateChatCompletionRequest
371
+ */
372
+ max_completion_tokens?: number | null;
327
373
  /**
328
374
  * Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model\'s likelihood to talk about new topics. [See more information about frequency and presence penalties.](/docs/api-reference/parameter-details)
329
375
  * @type {number}
@@ -343,13 +389,148 @@ declare namespace openai {
343
389
  */
344
390
  logit_bias?: object | null;
345
391
  /**
346
- * A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).
392
+ * Whether to return log probabilities of the output tokens or not.
393
+ * @type {boolean}
394
+ * @memberof CreateChatCompletionRequest
395
+ */
396
+ logprobs?: boolean | null;
397
+ /**
398
+ * An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability.
399
+ * @type {number}
400
+ * @memberof CreateChatCompletionRequest
401
+ */
402
+ top_logprobs?: number | null;
403
+ /**
404
+ * A list of tools the model may call. You can provide either custom tools or function tools.
405
+ * @type {Array<any>}
406
+ * @memberof CreateChatCompletionRequest
407
+ */
408
+ tools?: Array<any> | null;
409
+ /**
410
+ * Controls which (if any) tool is called by the model. `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools.
411
+ * @type {string | object}
412
+ * @memberof CreateChatCompletionRequest
413
+ */
414
+ tool_choice?: string | object | null;
415
+ /**
416
+ * Whether to enable parallel function calling during tool use.
417
+ * @type {boolean}
418
+ * @memberof CreateChatCompletionRequest
419
+ */
420
+ parallel_tool_calls?: boolean | null;
421
+ /**
422
+ * Parameters for audio output. Required when audio output is requested with `modalities: ["audio"]`.
423
+ * @type {object}
424
+ * @memberof CreateChatCompletionRequest
425
+ */
426
+ audio?: object | null;
427
+ /**
428
+ * Output types that you would like the model to generate. Most models are capable of generating text, which is the default: `["text"]`. The `gpt-4o-audio-preview` model can also be used to generate audio.
429
+ * @type {Array<string>}
430
+ * @memberof CreateChatCompletionRequest
431
+ */
432
+ modalities?: Array<string> | null;
433
+ /**
434
+ * An object specifying the format that the model must output. Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs.
435
+ * @type {object}
436
+ * @memberof CreateChatCompletionRequest
437
+ */
438
+ response_format?: object | null;
439
+ /**
440
+ * Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format.
441
+ * @type {object}
442
+ * @memberof CreateChatCompletionRequest
443
+ */
444
+ metadata?: object | null;
445
+ /**
446
+ * A stable identifier used to help detect users of your application that may be violating OpenAI's usage policies.
447
+ * @type {string}
448
+ * @memberof CreateChatCompletionRequest
449
+ */
450
+ safety_identifier?: string | null;
451
+ /**
452
+ * Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces the `user` field.
453
+ * @type {string}
454
+ * @memberof CreateChatCompletionRequest
455
+ */
456
+ prompt_cache_key?: string | null;
457
+ /**
458
+ * The retention policy for the prompt cache. Set to `24h` to enable extended prompt caching.
459
+ * @type {string}
460
+ * @memberof CreateChatCompletionRequest
461
+ */
462
+ prompt_cache_retention?: string | null;
463
+ /**
464
+ * Constrains effort on reasoning for reasoning models. Currently supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
347
465
  * @type {string}
348
466
  * @memberof CreateChatCompletionRequest
349
467
  */
350
- user?: string;
351
- pluginList?: string | object;
468
+ reasoning_effort?: string | null;
469
+ /**
470
+ * Specifies the processing type used for serving the request. Options: 'auto', 'default', 'flex', 'priority'.
471
+ * @type {string}
472
+ * @memberof CreateChatCompletionRequest
473
+ */
474
+ service_tier?: string | null;
475
+ /**
476
+ * Whether or not to store the output of this chat completion request for use in model distillation or evals products.
477
+ * @type {boolean}
478
+ * @memberof CreateChatCompletionRequest
479
+ */
480
+ store?: boolean | null;
481
+ /**
482
+ * Constrains the verbosity of the model's response. Lower values will result in more concise responses, while higher values will result in more verbose responses. Currently supported values are `low`, `medium`, and `high`.
483
+ * @type {string}
484
+ * @memberof CreateChatCompletionRequest
485
+ */
486
+ verbosity?: string | null;
487
+ /**
488
+ * Configuration for a Predicted Output, which can greatly improve response times when large parts of the model response are known ahead of time.
489
+ * @type {object}
490
+ * @memberof CreateChatCompletionRequest
491
+ */
492
+ prediction?: object | null;
493
+ /**
494
+ * This tool searches the web for relevant results to use in a response.
495
+ * @type {object}
496
+ * @memberof CreateChatCompletionRequest
497
+ */
498
+ web_search_options?: object | null;
499
+ /**
500
+ * A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Deprecated in favor of `safety_identifier` and `prompt_cache_key`.
501
+ * @type {string}
502
+ * @memberof CreateChatCompletionRequest
503
+ */
504
+ user?: string | null;
505
+ /**
506
+ * Deprecated: Use `tools` instead. A list of functions the model may generate JSON inputs for.
507
+ * @type {Array<any>}
508
+ * @memberof CreateChatCompletionRequest
509
+ */
510
+ functions?: Array<any> | null;
511
+ /**
512
+ * Deprecated: Use `tool_choice` instead. Controls which (if any) function is called by the model.
513
+ * @type {string | object}
514
+ * @memberof CreateChatCompletionRequest
515
+ */
516
+ function_call?: string | object | null;
517
+ /**
518
+ * Deprecated: Use `seed` instead. This feature is in Beta.
519
+ * @type {number}
520
+ * @memberof CreateChatCompletionRequest
521
+ */
522
+ seed?: number | null;
523
+ /**
524
+ * Custom file list (non-standard parameter)
525
+ * @type {Array<any>}
526
+ * @memberof CreateChatCompletionRequest
527
+ */
352
528
  fileList?: Array<any>;
529
+ /**
530
+ * Custom extended parameters (non-standard parameter)
531
+ * @type {any}
532
+ * @memberof CreateChatCompletionRequest
533
+ */
353
534
  extParams?: any;
354
535
  }
355
536
  /**
@@ -365,45 +546,100 @@ declare namespace openai {
365
546
  */
366
547
  interface CreateChatCompletionResponse {
367
548
  /**
368
- *
549
+ * A unique identifier for the chat completion.
369
550
  * @type {string}
370
551
  * @memberof CreateChatCompletionResponse
371
552
  */
372
553
  id?: string;
373
554
  /**
374
- *
555
+ * The object type, which is always `chat.completion`.
375
556
  * @type {string}
376
557
  * @memberof CreateChatCompletionResponse
377
558
  */
378
559
  object?: string;
379
560
  /**
380
- *
561
+ * The Unix timestamp (in seconds) of when the chat completion was created.
381
562
  * @type {number}
382
563
  * @memberof CreateChatCompletionResponse
383
564
  */
384
565
  created?: number;
385
566
  /**
386
- *
567
+ * The model used for the chat completion.
387
568
  * @type {string}
388
569
  * @memberof CreateChatCompletionResponse
389
570
  */
390
571
  model?: string;
391
572
  /**
392
- *
573
+ * A list of chat completion choices.
393
574
  * @type {Array<CreateChatCompletionResponseChoicesInner>}
394
575
  * @memberof CreateChatCompletionResponse
395
576
  */
396
577
  choices?: Array<CreateChatCompletionResponseChoicesInner>;
397
578
  /**
398
- *
579
+ * Usage statistics for the completion request.
399
580
  * @type {CreateCompletionResponseUsage}
400
581
  * @memberof CreateChatCompletionResponse
401
582
  */
402
583
  usage?: CreateCompletionResponseUsage;
584
+ /**
585
+ * Specifies the processing type used for serving the request.
586
+ * @type {string}
587
+ * @memberof CreateChatCompletionResponse
588
+ */
589
+ service_tier?: string | null;
590
+ /**
591
+ * System fingerprint representing the backend configuration.
592
+ * @type {string}
593
+ * @memberof CreateChatCompletionResponse
594
+ */
595
+ system_fingerprint?: string | null;
596
+ /**
597
+ * The tools used in this completion.
598
+ * @type {Array<any>}
599
+ * @memberof CreateChatCompletionResponse
600
+ */
601
+ tools?: Array<any> | null;
602
+ /**
603
+ * The tool choice used in this completion.
604
+ * @type {string | object}
605
+ * @memberof CreateChatCompletionResponse
606
+ */
607
+ tool_choice?: string | object | null;
608
+ /**
609
+ * Metadata attached to the completion.
610
+ * @type {object}
611
+ * @memberof CreateChatCompletionResponse
612
+ */
613
+ metadata?: object | null;
614
+ /**
615
+ * Custom result field (non-standard)
616
+ * @type {string}
617
+ * @memberof CreateChatCompletionResponse
618
+ */
403
619
  result?: string;
620
+ /**
621
+ * Custom is_truncated field (non-standard)
622
+ * @type {boolean}
623
+ * @memberof CreateChatCompletionResponse
624
+ */
404
625
  is_truncated?: boolean;
626
+ /**
627
+ * Custom need_clear_history field (non-standard)
628
+ * @type {boolean}
629
+ * @memberof CreateChatCompletionResponse
630
+ */
405
631
  need_clear_history?: boolean;
632
+ /**
633
+ * Custom output field (non-standard)
634
+ * @type {any}
635
+ * @memberof CreateChatCompletionResponse
636
+ */
406
637
  output?: any;
638
+ /**
639
+ * Custom request_id field (non-standard)
640
+ * @type {string}
641
+ * @memberof CreateChatCompletionResponse
642
+ */
407
643
  request_id?: string;
408
644
  }
409
645
  /**
@@ -413,23 +649,29 @@ declare namespace openai {
413
649
  */
414
650
  interface CreateChatCompletionResponseChoicesInner {
415
651
  /**
416
- *
652
+ * The index of the choice in the choices array.
417
653
  * @type {number}
418
654
  * @memberof CreateChatCompletionResponseChoicesInner
419
655
  */
420
656
  index?: number;
421
657
  /**
422
- *
658
+ * The message generated by the model.
423
659
  * @type {ChatCompletionResponseMessage}
424
660
  * @memberof CreateChatCompletionResponseChoicesInner
425
661
  */
426
662
  message?: ChatCompletionResponseMessage;
427
663
  /**
428
- *
664
+ * The reason the model stopped generating tokens.
429
665
  * @type {string}
430
666
  * @memberof CreateChatCompletionResponseChoicesInner
431
667
  */
432
- finish_reason?: string;
668
+ finish_reason?: string | null;
669
+ /**
670
+ * Log probability information for the choice.
671
+ * @type {object}
672
+ * @memberof CreateChatCompletionResponseChoicesInner
673
+ */
674
+ logprobs?: object | null;
433
675
  }
434
676
  /**
435
677
  *
@@ -438,23 +680,49 @@ declare namespace openai {
438
680
  */
439
681
  interface CreateCompletionResponseUsage {
440
682
  /**
441
- *
683
+ * Number of tokens in the prompt.
442
684
  * @type {number}
443
685
  * @memberof CreateCompletionResponseUsage
444
686
  */
445
687
  prompt_tokens: number;
446
688
  /**
447
- *
689
+ * Number of tokens in the completion.
448
690
  * @type {number}
449
691
  * @memberof CreateCompletionResponseUsage
450
692
  */
451
693
  completion_tokens: number;
452
694
  /**
453
- *
695
+ * Total number of tokens used.
454
696
  * @type {number}
455
697
  * @memberof CreateCompletionResponseUsage
456
698
  */
457
699
  total_tokens: number;
700
+ /**
701
+ * Details about prompt tokens (cached tokens, audio tokens, etc.)
702
+ * @type {object}
703
+ * @memberof CreateCompletionResponseUsage
704
+ */
705
+ prompt_tokens_details?: {
706
+ cached_tokens?: number;
707
+ audio_tokens?: number;
708
+ };
709
+ /**
710
+ * Details about completion tokens (reasoning tokens, audio tokens, etc.)
711
+ * @type {object}
712
+ * @memberof CreateCompletionResponseUsage
713
+ */
714
+ completion_tokens_details?: {
715
+ reasoning_tokens?: number;
716
+ audio_tokens?: number;
717
+ accepted_prediction_tokens?: number;
718
+ rejected_prediction_tokens?: number;
719
+ };
720
+ /**
721
+ * Whether the usage is estimated.
722
+ * @type {boolean}
723
+ * @memberof CreateCompletionResponseUsage
724
+ */
725
+ estimated?: boolean;
458
726
  }
459
727
  }
460
728
 
@@ -488,7 +756,6 @@ declare class ChatGPTAPI {
488
756
  * @param fetch - Optional override for the `fetch` implementation to use. Defaults to the global `fetch` function.
489
757
  */
490
758
  constructor(opts: ChatGPTAPIOptions);
491
- pluginListMap(pluginList: any): any;
492
759
  /**
493
760
  * Sends a message to the OpenAI chat completions endpoint, waits for the response
494
761
  * to resolve, and returns the response.
@@ -586,4 +853,4 @@ declare class ChatGPTUnofficialProxyAPI {
586
853
  sendMessage(text: string, opts?: SendMessageBrowserOptions): Promise<ChatMessage>;
587
854
  }
588
855
 
589
- export { ChatGPTAPI, ChatGPTAPIOptions, ChatGPTError, ChatGPTUnofficialProxyAPI, ChatMessage, ContentType, ConversationJSONBody, ConversationResponseEvent, CreateChatCompletionStreamResponse, CreateCompletionStreamResponseUsage, FetchFn, GetMessageByIdFunction, Message, MessageActionType, MessageContent, MessageMetadata, PluginParams, Prompt, PromptContent, Role, SendMessageBrowserOptions, SendMessageOptions, UpsertMessageFunction, openai };
856
+ export { ChatGPTAPI, type ChatGPTAPIOptions, ChatGPTError, ChatGPTUnofficialProxyAPI, type ChatMessage, type ContentType, type ConversationJSONBody, type ConversationResponseEvent, type CreateChatCompletionStreamResponse, type CreateCompletionStreamResponseUsage, type FetchFn, type GetMessageByIdFunction, type Message, type MessageActionType, type MessageContent, type MessageMetadata, type PluginParams, type Prompt, type PromptContent, type Role, type SendMessageBrowserOptions, type SendMessageOptions, type UpsertMessageFunction, openai };