@xsai/shared-chat 0.0.28 → 0.0.29

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.
Files changed (2) hide show
  1. package/dist/index.d.ts +27 -27
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,6 +1,15 @@
1
1
  import { CommonRequestOptions } from '@xsai/shared';
2
2
 
3
- type Part = AudioPart | ImagePart | RefusalPart | TextPart;
3
+ interface AudioBase64 {
4
+ /**
5
+ * Base64 encoded audio data.
6
+ */
7
+ data: string;
8
+ format: 'mp3' | 'wav';
9
+ }
10
+ interface AudioPart extends CommonPart<'input_audio'> {
11
+ input_audio: AudioBase64;
12
+ }
4
13
  interface CommonPart<T extends string> {
5
14
  type: T;
6
15
  }
@@ -17,16 +26,7 @@ interface ImageURLorBase64 {
17
26
  */
18
27
  url: string;
19
28
  }
20
- interface AudioPart extends CommonPart<'input_audio'> {
21
- input_audio: AudioBase64;
22
- }
23
- interface AudioBase64 {
24
- /**
25
- * Base64 encoded audio data.
26
- */
27
- data: string;
28
- format: 'mp3' | 'wav';
29
- }
29
+ type Part = AudioPart | ImagePart | RefusalPart | TextPart;
30
30
  interface RefusalPart extends CommonPart<'refusal'> {
31
31
  refusal: string;
32
32
  }
@@ -34,20 +34,23 @@ interface TextPart extends CommonPart<'text'> {
34
34
  text: string;
35
35
  }
36
36
 
37
- type Optional<T, K extends keyof T> = Omit<T, K> & Pick<Partial<T>, K>;
38
- type Message = AssistantMessage | SystemMessage | ToolMessage | UserMessage;
37
+ interface AssistantMessage extends Optional<CommonMessage<'assistant', AssistantMessagePart>, 'content'> {
38
+ refusal?: null | string;
39
+ tool_calls?: ToolCall[];
40
+ }
41
+ type AssistantMessagePart = RefusalPart | TextPart;
42
+ interface AssistantMessageResponse extends Omit<AssistantMessage, 'content'> {
43
+ content?: string;
44
+ }
39
45
  interface CommonMessage<T extends string, P extends Part> {
40
46
  content: Array<P> | string;
41
47
  name?: string;
42
48
  role: T;
43
49
  }
44
- type SystemMessagePart = TextPart;
50
+ type Message = AssistantMessage | SystemMessage | ToolMessage | UserMessage;
45
51
  interface SystemMessage extends CommonMessage<'system', SystemMessagePart> {
46
52
  }
47
- type UserMessagePart = AudioPart | ImagePart | TextPart;
48
- interface UserMessage extends CommonMessage<'user', UserMessagePart> {
49
- }
50
- type AssistantMessagePart = RefusalPart | TextPart;
53
+ type SystemMessagePart = TextPart;
51
54
  interface ToolCall {
52
55
  function: {
53
56
  arguments: string;
@@ -56,17 +59,14 @@ interface ToolCall {
56
59
  id: string;
57
60
  type: 'function';
58
61
  }
59
- interface AssistantMessage extends Optional<CommonMessage<'assistant', AssistantMessagePart>, 'content'> {
60
- refusal?: null | string;
61
- tool_calls?: ToolCall[];
62
- }
63
- interface AssistantMessageResponse extends Omit<AssistantMessage, 'content'> {
64
- content?: string;
65
- }
66
- type ToolMessagePart = TextPart;
67
62
  interface ToolMessage extends Omit<CommonMessage<'tool', ToolMessagePart>, 'name'> {
68
63
  tool_call_id: string;
69
64
  }
65
+ type ToolMessagePart = TextPart;
66
+ interface UserMessage extends CommonMessage<'user', UserMessagePart> {
67
+ }
68
+ type UserMessagePart = AudioPart | ImagePart | TextPart;
69
+ type Optional<T, K extends keyof T> = Omit<T, K> & Pick<Partial<T>, K>;
70
70
 
71
71
  type ToolChoice = 'auto' | 'none' | 'required' | {
72
72
  function: {
@@ -81,7 +81,7 @@ interface ChatOptions extends CommonRequestOptions {
81
81
  toolChoice?: ToolChoice;
82
82
  }
83
83
 
84
- type FinishReason = 'content_filter' | 'error' | 'length' | 'other' | 'stop' | 'tool-calls' | ({} & string);
84
+ type FinishReason = 'content_filter' | 'error' | 'length' | 'other' | 'stop' | 'tool-calls' | (string & {});
85
85
 
86
86
  interface Tool {
87
87
  execute: (input: unknown) => Promise<string> | string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsai/shared-chat",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "type": "module",
5
5
  "author": "Moeru AI",
6
6
  "license": "MIT",