@xsai/shared-chat 0.1.0-beta.7 → 0.1.0-beta.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.
Files changed (2) hide show
  1. package/dist/index.d.ts +35 -15
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { CommonRequestOptions } from '@xsai/shared';
2
2
 
3
+ type FinishReason = 'content_filter' | 'error' | 'length' | 'other' | 'stop' | 'tool-calls' | (string & {});
4
+
3
5
  interface AudioBase64 {
4
6
  /**
5
7
  * Base64 encoded audio data.
@@ -68,21 +70,6 @@ interface UserMessage extends CommonMessage<'user', UserMessagePart> {
68
70
  type UserMessagePart = AudioPart | ImagePart | TextPart;
69
71
  type Optional<T, K extends keyof T> = Omit<T, K> & Pick<Partial<T>, K>;
70
72
 
71
- type ToolChoice = 'auto' | 'none' | 'required' | {
72
- function: {
73
- name: string;
74
- };
75
- type: 'function';
76
- };
77
-
78
- interface ChatOptions extends CommonRequestOptions {
79
- [key: string]: unknown;
80
- messages: Message[];
81
- toolChoice?: ToolChoice;
82
- }
83
-
84
- type FinishReason = 'content_filter' | 'error' | 'length' | 'other' | 'stop' | 'tool-calls' | (string & {});
85
-
86
73
  interface CompletionToolCall {
87
74
  args: string;
88
75
  toolCallId: string;
@@ -111,12 +98,45 @@ interface ToolExecuteOptions {
111
98
  toolCallId: string;
112
99
  }
113
100
 
101
+ type ToolChoice = 'auto' | 'none' | 'required' | {
102
+ function: {
103
+ name: string;
104
+ };
105
+ type: 'function';
106
+ };
107
+
114
108
  interface Usage {
115
109
  completion_tokens: number;
116
110
  prompt_tokens: number;
117
111
  total_tokens: number;
118
112
  }
119
113
 
114
+ /** @see {@link https://platform.openai.com/docs/api-reference/chat/create} */
115
+ interface ChatOptions extends CommonRequestOptions {
116
+ [key: string]: unknown;
117
+ /**
118
+ * number between -2.0 and 2.0.
119
+ * @default 0
120
+ */
121
+ frequencyPenalty?: number;
122
+ messages: Message[];
123
+ /**
124
+ * number between -2.0 and 2.0.
125
+ * @default 0
126
+ */
127
+ presencePenalty?: number;
128
+ seed?: number;
129
+ /** up to 4 sequences where the API will stop generating further tokens. */
130
+ stop?: [string, string, string, string] | [string, string, string] | [string, string] | [string] | string;
131
+ /**
132
+ * what sampling temperature to use, between 0 and 2.
133
+ * @default 1
134
+ */
135
+ temperature?: number;
136
+ toolChoice?: ToolChoice;
137
+ /** @default 1 */
138
+ topP?: number;
139
+ }
120
140
  declare const chat: <T extends ChatOptions>(options: T) => Promise<Response>;
121
141
 
122
142
  export { type AssistantMessage, type AssistantMessagePart, type AssistantMessageResponse, type AudioBase64, type AudioPart, type ChatOptions, type CommonMessage, type CommonPart, type CompletionToolCall, type CompletionToolResult, type FinishReason, type ImagePart, type ImageURLorBase64, type Message, type Part, type RefusalPart, type SystemMessage, type SystemMessagePart, type TextPart, type Tool, type ToolCall, type ToolChoice, type ToolExecuteOptions, type ToolMessage, type ToolMessagePart, type Usage, type UserMessage, type UserMessagePart, chat };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xsai/shared-chat",
3
3
  "type": "module",
4
- "version": "0.1.0-beta.7",
4
+ "version": "0.1.0-beta.8",
5
5
  "description": "extra-small AI SDK for Browser, Node.js, Deno, Bun or Edge Runtime.",
6
6
  "author": "Moeru AI",
7
7
  "license": "MIT",