@websimai/client-api-types 0.0.2 → 0.0.3
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/README.md +1 -1
- package/dist/index.d.mts +268 -0
- package/dist/index.mjs +1 -0
- package/package.json +27 -11
- package/LICENSE +0 -21
- package/src/client-api.d.ts +0 -74
- package/src/globals.d.ts +0 -9
- package/src/index.d.ts +0 -4
- package/src/types/chat.d.ts +0 -106
- package/src/types/image-gen.d.ts +0 -67
- package/src/types/index.d.ts +0 -4
- package/src/types/text-to-speech.d.ts +0 -32
- package/src/types/user.d.ts +0 -13
- package/tsconfig.json +0 -28
package/README.md
CHANGED
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
//#region src/types/chat.d.ts
|
|
2
|
+
type ChatCompletionsMessageRole = "system" | "user" | "assistant" | "tool";
|
|
3
|
+
type ChatCompletionsMessageContent = {
|
|
4
|
+
/**
|
|
5
|
+
* The type of content part.
|
|
6
|
+
*/
|
|
7
|
+
type: "text";
|
|
8
|
+
/**
|
|
9
|
+
* The text content.
|
|
10
|
+
*/
|
|
11
|
+
text: string;
|
|
12
|
+
} | {
|
|
13
|
+
/**
|
|
14
|
+
* The type of content part.
|
|
15
|
+
*/
|
|
16
|
+
type: "image_url";
|
|
17
|
+
/**
|
|
18
|
+
* An object containing the base64 encoded image data URL.
|
|
19
|
+
*/
|
|
20
|
+
image_url: {
|
|
21
|
+
/**
|
|
22
|
+
* A base64 encoded image data URL.
|
|
23
|
+
*/
|
|
24
|
+
url: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Represents a single message in the conversation history.
|
|
29
|
+
*/
|
|
30
|
+
type ChatCompletionsMessage = {
|
|
31
|
+
/**
|
|
32
|
+
* The role of the message sender.
|
|
33
|
+
*/
|
|
34
|
+
role: ChatCompletionsMessageRole;
|
|
35
|
+
/**
|
|
36
|
+
* The message content.
|
|
37
|
+
* Can be plain text or an array for multimodal inputs.
|
|
38
|
+
*/
|
|
39
|
+
content: string | ChatCompletionsMessageContent[];
|
|
40
|
+
};
|
|
41
|
+
type ChatCompletionOptions = {
|
|
42
|
+
/**
|
|
43
|
+
* A list of messages comprising the conversation so far.
|
|
44
|
+
* Each message includes a `role` (system, user, assistant, tool) and `content`.
|
|
45
|
+
*/
|
|
46
|
+
messages: ChatCompletionsMessage[];
|
|
47
|
+
/**
|
|
48
|
+
* ID of the model to use.
|
|
49
|
+
* If not specified, websim uses its default model.
|
|
50
|
+
*/
|
|
51
|
+
model?: string;
|
|
52
|
+
/**
|
|
53
|
+
* If `true`, the model will attempt to generate a JSON object.
|
|
54
|
+
* The response content will be a string that you will need to parse.
|
|
55
|
+
* Defaults to `false`.
|
|
56
|
+
*/
|
|
57
|
+
json?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* If `true`, the response will be streamed back incrementally.
|
|
60
|
+
* Defaults to `false`.
|
|
61
|
+
*/
|
|
62
|
+
stream?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* What sampling temperature to use, between 0 and 2.
|
|
65
|
+
* Higher values (e.g., 0.8) make the output more random; lower values (e.g., 0.2) make it more focused.
|
|
66
|
+
* Defaults to 1.
|
|
67
|
+
*/
|
|
68
|
+
temperature?: number;
|
|
69
|
+
/**
|
|
70
|
+
* An alternative to sampling with temperature, where the model considers tokens with top_p probability mass.
|
|
71
|
+
* E.g., 0.1 means only tokens comprising the top 10% probability mass are considered.
|
|
72
|
+
* Defaults to 1.
|
|
73
|
+
*/
|
|
74
|
+
top_p?: number;
|
|
75
|
+
/**
|
|
76
|
+
* The maximum number of tokens to generate in the chat completion.
|
|
77
|
+
*/
|
|
78
|
+
max_tokens?: number;
|
|
79
|
+
};
|
|
80
|
+
type ChatCompletionResult = {
|
|
81
|
+
/**
|
|
82
|
+
* The generated text content from the assistant.
|
|
83
|
+
*/
|
|
84
|
+
readonly content: string;
|
|
85
|
+
/**
|
|
86
|
+
* The role of the message sender, which will always be "assistant" for the model's response.
|
|
87
|
+
*/
|
|
88
|
+
readonly role: "assistant";
|
|
89
|
+
};
|
|
90
|
+
declare namespace ChatCompletions {
|
|
91
|
+
type MessageRole = ChatCompletionsMessageRole;
|
|
92
|
+
type ContentPart = ChatCompletionsMessageContent;
|
|
93
|
+
type Message = ChatCompletionsMessage;
|
|
94
|
+
type Options = ChatCompletionOptions;
|
|
95
|
+
type Result = ChatCompletionResult;
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/types/image-gen.d.ts
|
|
99
|
+
type ImageGenAspectRatio = "1:1" | "16:9" | "21:9" | "3:2" | "2:3" | "4:5" | "5:4" | "3:4" | "4:3" | "9:16" | "9:21";
|
|
100
|
+
type ImageGenOptions = {
|
|
101
|
+
/**
|
|
102
|
+
* The primary text prompt describing the image to generate.
|
|
103
|
+
* This is a required parameter.
|
|
104
|
+
*/
|
|
105
|
+
prompt: string;
|
|
106
|
+
/**
|
|
107
|
+
* Optional aspect ratio for the generated image.
|
|
108
|
+
* Defaults to "1:1".
|
|
109
|
+
* If `width` and `height` are provided, this parameter will be ignored.
|
|
110
|
+
*/
|
|
111
|
+
aspect_ratio?: ImageGenAspectRatio;
|
|
112
|
+
/**
|
|
113
|
+
* Optional width of the generated image in pixels.
|
|
114
|
+
* If provided along with `height`, it overrides `aspect_ratio`.
|
|
115
|
+
*/
|
|
116
|
+
width?: number;
|
|
117
|
+
/**
|
|
118
|
+
* Optional height of the generated image in pixels.
|
|
119
|
+
* If provided along with `width`, it overrides `aspect_ratio`.
|
|
120
|
+
*/
|
|
121
|
+
height?: number;
|
|
122
|
+
/**
|
|
123
|
+
* Optional boolean.
|
|
124
|
+
* If `true`, the generated image will have a transparent background.
|
|
125
|
+
* Defaults to `false`.
|
|
126
|
+
*/
|
|
127
|
+
transparent?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Optional array of image inputs.
|
|
130
|
+
* Each object in the array should have a `url` property, which is a base64 encoded image data URL.
|
|
131
|
+
* Supports 1-4 input images for image-to-image generation.
|
|
132
|
+
*/
|
|
133
|
+
image_inputs?: {
|
|
134
|
+
url: string;
|
|
135
|
+
}[];
|
|
136
|
+
/**
|
|
137
|
+
* Optional seed for the image generation process.
|
|
138
|
+
* Using the same prompt and seed will produce variations of the same output, useful for consistent results or exploring variations.
|
|
139
|
+
*/
|
|
140
|
+
seed?: number;
|
|
141
|
+
};
|
|
142
|
+
type ImageGenResult = {
|
|
143
|
+
/**
|
|
144
|
+
* The URL of the generated image.
|
|
145
|
+
* This URL can be used to display the image.
|
|
146
|
+
*/
|
|
147
|
+
readonly url: `https://${string}/${string}`;
|
|
148
|
+
};
|
|
149
|
+
declare namespace ImageGen {
|
|
150
|
+
type AspectRatio = ImageGenAspectRatio;
|
|
151
|
+
type Options = ImageGenOptions;
|
|
152
|
+
type Result = ImageGenResult;
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/types/text-to-speech.d.ts
|
|
156
|
+
type TextToSpeechOptions = {
|
|
157
|
+
/**
|
|
158
|
+
* The text string to synthesize to speech.
|
|
159
|
+
*/
|
|
160
|
+
text: string;
|
|
161
|
+
/**
|
|
162
|
+
* Voice identifier (e.g., "en-male") or ElevenLabs voice ID for a specific voice.
|
|
163
|
+
*/
|
|
164
|
+
voice?: string;
|
|
165
|
+
/**
|
|
166
|
+
* Desired audio format.
|
|
167
|
+
* Defaults to "mp3".
|
|
168
|
+
*/
|
|
169
|
+
format?: "mp3" | "wav";
|
|
170
|
+
/**
|
|
171
|
+
* Playback speed multiplier.
|
|
172
|
+
* Typical range 0.5 - 2.0.
|
|
173
|
+
*/
|
|
174
|
+
speed?: number;
|
|
175
|
+
/**
|
|
176
|
+
* Pitch adjustment in semitones.
|
|
177
|
+
* Typical range -12 to 12.
|
|
178
|
+
*/
|
|
179
|
+
pitch?: number;
|
|
180
|
+
};
|
|
181
|
+
type TextToSpeechResult = {
|
|
182
|
+
/**
|
|
183
|
+
* A public URL pointing to the generated audio file.
|
|
184
|
+
*/
|
|
185
|
+
readonly url: `https://${string}/${string}`;
|
|
186
|
+
};
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/types/user.d.ts
|
|
189
|
+
type AnonymousWebsimUser = {
|
|
190
|
+
readonly id: "1";
|
|
191
|
+
readonly username: "anonymous";
|
|
192
|
+
readonly avatar_url: null;
|
|
193
|
+
};
|
|
194
|
+
type WebsimUser = {
|
|
195
|
+
readonly id: string;
|
|
196
|
+
readonly username: string;
|
|
197
|
+
readonly avatar_url: `https://${string}/${string}` | null;
|
|
198
|
+
};
|
|
199
|
+
type WebsimUserOrAnonymous = WebsimUser | AnonymousWebsimUser;
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/client-api.d.ts
|
|
202
|
+
interface WebsimClientAPI {
|
|
203
|
+
getUser(): Promise<WebsimUserOrAnonymous>;
|
|
204
|
+
/** Alias for getUser */
|
|
205
|
+
getCurrentUser(): Promise<WebsimUserOrAnonymous>;
|
|
206
|
+
/** @deprecated Use getBootstrap instead */
|
|
207
|
+
getDistinctId(): Promise<string>;
|
|
208
|
+
getBootstrap(): Promise<{
|
|
209
|
+
readonly distinct_id: string;
|
|
210
|
+
readonly session_id: string;
|
|
211
|
+
}>;
|
|
212
|
+
getCreatedBy(): Promise<WebsimUser>;
|
|
213
|
+
/** Alias for getCreatedBy */
|
|
214
|
+
getCreator(): Promise<WebsimUser>;
|
|
215
|
+
getCurrentProject(): Promise<{
|
|
216
|
+
readonly id: string;
|
|
217
|
+
readonly title: string;
|
|
218
|
+
readonly description: string;
|
|
219
|
+
}>;
|
|
220
|
+
getColorScheme(): Promise<"light" | "dark">;
|
|
221
|
+
postComment(args: {
|
|
222
|
+
content: string;
|
|
223
|
+
credits?: number;
|
|
224
|
+
images?: string[];
|
|
225
|
+
}): Promise<{
|
|
226
|
+
readonly error?: "User has not interacted with the page";
|
|
227
|
+
}>;
|
|
228
|
+
addEventListener(eventType: "comment:created", callback: (data: any) => void): () => void;
|
|
229
|
+
upload: (file: File) => Promise<string>;
|
|
230
|
+
readonly chat: {
|
|
231
|
+
readonly completions: {
|
|
232
|
+
create: (args: ChatCompletionOptions) => Promise<ChatCompletionResult>;
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
imageGen: (args: ImageGenOptions) => Promise<ImageGenResult>;
|
|
236
|
+
textToSpeech: (args: TextToSpeechOptions) => Promise<TextToSpeechResult>;
|
|
237
|
+
readonly experimental: {
|
|
238
|
+
readonly v0: {
|
|
239
|
+
login: () => Promise<void>;
|
|
240
|
+
/**
|
|
241
|
+
* Saves the given htmlContent to a new websim site.
|
|
242
|
+
* @param htmlContent html content to save
|
|
243
|
+
* @returns object with id of the saved site
|
|
244
|
+
*/
|
|
245
|
+
save(htmlContent: string): Promise<{
|
|
246
|
+
id: string;
|
|
247
|
+
}>;
|
|
248
|
+
/**
|
|
249
|
+
* Returns the HTML for the given siteId.
|
|
250
|
+
* Defaults to the current websimsite.
|
|
251
|
+
* @param siteId
|
|
252
|
+
* @returns HTML for the given siteId.
|
|
253
|
+
*/
|
|
254
|
+
getHTML(siteId?: string): Promise<string>;
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
readonly internal_only_experimental: Record<never, never>;
|
|
258
|
+
}
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region src/globals.d.ts
|
|
261
|
+
declare global {
|
|
262
|
+
interface Window {
|
|
263
|
+
readonly websim: WebsimClientAPI;
|
|
264
|
+
}
|
|
265
|
+
const websim: WebsimClientAPI;
|
|
266
|
+
}
|
|
267
|
+
//#endregion
|
|
268
|
+
export { AnonymousWebsimUser, ChatCompletionOptions, ChatCompletionResult, ChatCompletions, ChatCompletionsMessage, ChatCompletionsMessageContent, ChatCompletionsMessageRole, ImageGen, ImageGenAspectRatio, ImageGenOptions, ImageGenResult, TextToSpeechOptions, TextToSpeechResult, type WebsimClientAPI, WebsimUser, WebsimUserOrAnonymous };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@websimai/client-api-types",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Type declarations for `window.websim` object",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "Type declarations for the `window.websim` object",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"author": "GameRoMan",
|
|
6
7
|
"license": "MIT",
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
".": {
|
|
10
|
-
"types": "./src/index.d.ts"
|
|
11
|
-
}
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
12
10
|
},
|
|
13
|
-
"
|
|
14
|
-
"
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/websimnpm/websim.git",
|
|
14
|
+
"directory": "packages/client-api-types"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"websim",
|
|
@@ -20,7 +20,23 @@
|
|
|
20
20
|
"types",
|
|
21
21
|
"typescript"
|
|
22
22
|
],
|
|
23
|
-
"
|
|
24
|
-
"
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "bunx --bun tsdown",
|
|
25
|
+
"npm:publish": "bun run build && bun publish"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist/**/*",
|
|
29
|
+
"README.md",
|
|
30
|
+
"LICENSE"
|
|
31
|
+
],
|
|
32
|
+
"main": "./dist/index.mjs",
|
|
33
|
+
"module": "./dist/index.mjs",
|
|
34
|
+
"types": "./dist/index.d.mts",
|
|
35
|
+
"exports": {
|
|
36
|
+
".": "./dist/index.mjs",
|
|
37
|
+
"./package.json": "./package.json"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"tsdown": "^0.17.3"
|
|
25
41
|
}
|
|
26
42
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Roman A
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/src/client-api.d.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import type { WebsimUser, WebsimUserOrAnonymous } from "./types";
|
|
2
|
-
|
|
3
|
-
import type { ChatCompletionOptions, ChatCompletionResult } from "./types";
|
|
4
|
-
|
|
5
|
-
import type { ImageGenOptions, ImageGenResult } from "./types";
|
|
6
|
-
|
|
7
|
-
import type { TextToSpeechOptions, TextToSpeechResult } from "./types";
|
|
8
|
-
|
|
9
|
-
export interface WebsimClientAPI {
|
|
10
|
-
getUser(): Promise<WebsimUserOrAnonymous>;
|
|
11
|
-
/** Alias for getUser */
|
|
12
|
-
getCurrentUser(): Promise<WebsimUserOrAnonymous>;
|
|
13
|
-
/** @deprecated Use getBootstrap instead */
|
|
14
|
-
getDistinctId(): Promise<string>;
|
|
15
|
-
getBootstrap(): Promise<{
|
|
16
|
-
readonly distinct_id: string;
|
|
17
|
-
readonly session_id: string;
|
|
18
|
-
}>;
|
|
19
|
-
getCreatedBy(): Promise<WebsimUser>;
|
|
20
|
-
/** Alias for getCreatedBy */
|
|
21
|
-
getCreator(): Promise<WebsimUser>;
|
|
22
|
-
getCurrentProject(): Promise<{
|
|
23
|
-
readonly id: string;
|
|
24
|
-
readonly title: string;
|
|
25
|
-
readonly description: string;
|
|
26
|
-
}>;
|
|
27
|
-
getColorScheme(): Promise<"light" | "dark">;
|
|
28
|
-
|
|
29
|
-
postComment(args: {
|
|
30
|
-
content: string;
|
|
31
|
-
credits?: number;
|
|
32
|
-
images?: string[];
|
|
33
|
-
}): Promise<{ readonly error?: "User has not interacted with the page" }>;
|
|
34
|
-
|
|
35
|
-
addEventListener(
|
|
36
|
-
eventType: "comment:created",
|
|
37
|
-
callback: (data: any) => void
|
|
38
|
-
): () => void;
|
|
39
|
-
|
|
40
|
-
upload: (file: File) => Promise<string>;
|
|
41
|
-
|
|
42
|
-
readonly chat: {
|
|
43
|
-
readonly completions: {
|
|
44
|
-
create: (args: ChatCompletionOptions) => Promise<ChatCompletionResult>;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
imageGen: (args: ImageGenOptions) => Promise<ImageGenResult>;
|
|
49
|
-
|
|
50
|
-
textToSpeech: (args: TextToSpeechOptions) => Promise<TextToSpeechResult>;
|
|
51
|
-
|
|
52
|
-
experimental: {
|
|
53
|
-
v0: {
|
|
54
|
-
login: () => Promise<void>;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Saves the given htmlContent to a new websim site.
|
|
58
|
-
* @param htmlContent html content to save
|
|
59
|
-
* @returns object with id of the saved site
|
|
60
|
-
*/
|
|
61
|
-
save(htmlContent: string): Promise<{ id: string }>;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Returns the HTML for the given siteId.
|
|
65
|
-
* Defaults to the current websimsite.
|
|
66
|
-
* @param siteId
|
|
67
|
-
* @returns HTML for the given siteId.
|
|
68
|
-
*/
|
|
69
|
-
getHTML(siteId?: string): Promise<string>;
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
internal_only_experimental: {};
|
|
74
|
-
}
|
package/src/globals.d.ts
DELETED
package/src/index.d.ts
DELETED
package/src/types/chat.d.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
export type ChatCompletionsMessageRole =
|
|
2
|
-
| "system"
|
|
3
|
-
| "user"
|
|
4
|
-
| "assistant"
|
|
5
|
-
| "tool";
|
|
6
|
-
|
|
7
|
-
export type ChatCompletionsMessageContent =
|
|
8
|
-
| {
|
|
9
|
-
/**
|
|
10
|
-
* The type of content part.
|
|
11
|
-
*/
|
|
12
|
-
type: "text";
|
|
13
|
-
/**
|
|
14
|
-
* The text content.
|
|
15
|
-
*/
|
|
16
|
-
text: string;
|
|
17
|
-
}
|
|
18
|
-
| {
|
|
19
|
-
/**
|
|
20
|
-
* The type of content part.
|
|
21
|
-
*/
|
|
22
|
-
type: "image_url";
|
|
23
|
-
/**
|
|
24
|
-
* An object containing the base64 encoded image data URL.
|
|
25
|
-
*/
|
|
26
|
-
image_url: {
|
|
27
|
-
/**
|
|
28
|
-
* A base64 encoded image data URL.
|
|
29
|
-
*/
|
|
30
|
-
url: string;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Represents a single message in the conversation history.
|
|
36
|
-
*/
|
|
37
|
-
export type ChatCompletionsMessage = {
|
|
38
|
-
/**
|
|
39
|
-
* The role of the message sender.
|
|
40
|
-
*/
|
|
41
|
-
role: ChatCompletionsMessageRole;
|
|
42
|
-
/**
|
|
43
|
-
* The message content.
|
|
44
|
-
* Can be plain text or an array for multimodal inputs.
|
|
45
|
-
*/
|
|
46
|
-
content: string | ChatCompletionsMessageContent[];
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export type ChatCompletionOptions = {
|
|
50
|
-
/**
|
|
51
|
-
* A list of messages comprising the conversation so far.
|
|
52
|
-
* Each message includes a `role` (system, user, assistant, tool) and `content`.
|
|
53
|
-
*/
|
|
54
|
-
messages: ChatCompletionsMessage[];
|
|
55
|
-
/**
|
|
56
|
-
* ID of the model to use.
|
|
57
|
-
* If not specified, websim uses its default model.
|
|
58
|
-
*/
|
|
59
|
-
model?: string;
|
|
60
|
-
/**
|
|
61
|
-
* If `true`, the model will attempt to generate a JSON object.
|
|
62
|
-
* The response content will be a string that you will need to parse.
|
|
63
|
-
* Defaults to `false`.
|
|
64
|
-
*/
|
|
65
|
-
json?: boolean;
|
|
66
|
-
/**
|
|
67
|
-
* If `true`, the response will be streamed back incrementally.
|
|
68
|
-
* Defaults to `false`.
|
|
69
|
-
*/
|
|
70
|
-
stream?: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* What sampling temperature to use, between 0 and 2.
|
|
73
|
-
* Higher values (e.g., 0.8) make the output more random; lower values (e.g., 0.2) make it more focused.
|
|
74
|
-
* Defaults to 1.
|
|
75
|
-
*/
|
|
76
|
-
temperature?: number;
|
|
77
|
-
/**
|
|
78
|
-
* An alternative to sampling with temperature, where the model considers tokens with top_p probability mass.
|
|
79
|
-
* E.g., 0.1 means only tokens comprising the top 10% probability mass are considered.
|
|
80
|
-
* Defaults to 1.
|
|
81
|
-
*/
|
|
82
|
-
top_p?: number;
|
|
83
|
-
/**
|
|
84
|
-
* The maximum number of tokens to generate in the chat completion.
|
|
85
|
-
*/
|
|
86
|
-
max_tokens?: number;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export type ChatCompletionResult = {
|
|
90
|
-
/**
|
|
91
|
-
* The generated text content from the assistant.
|
|
92
|
-
*/
|
|
93
|
-
readonly content: string;
|
|
94
|
-
/**
|
|
95
|
-
* The role of the message sender, which will always be "assistant" for the model's response.
|
|
96
|
-
*/
|
|
97
|
-
readonly role: "assistant";
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export namespace ChatCompletions {
|
|
101
|
-
export type MessageRole = ChatCompletionsMessageRole;
|
|
102
|
-
export type ContentPart = ChatCompletionsMessageContent;
|
|
103
|
-
export type Message = ChatCompletionsMessage;
|
|
104
|
-
export type Options = ChatCompletionOptions;
|
|
105
|
-
export type Result = ChatCompletionResult;
|
|
106
|
-
}
|
package/src/types/image-gen.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
export type ImageGenAspectRatio =
|
|
2
|
-
| "1:1"
|
|
3
|
-
| "16:9"
|
|
4
|
-
| "21:9"
|
|
5
|
-
| "3:2"
|
|
6
|
-
| "2:3"
|
|
7
|
-
| "4:5"
|
|
8
|
-
| "5:4"
|
|
9
|
-
| "3:4"
|
|
10
|
-
| "4:3"
|
|
11
|
-
| "9:16"
|
|
12
|
-
| "9:21";
|
|
13
|
-
|
|
14
|
-
export type ImageGenOptions = {
|
|
15
|
-
/**
|
|
16
|
-
* The primary text prompt describing the image to generate.
|
|
17
|
-
* This is a required parameter.
|
|
18
|
-
*/
|
|
19
|
-
prompt: string;
|
|
20
|
-
/**
|
|
21
|
-
* Optional aspect ratio for the generated image.
|
|
22
|
-
* Defaults to "1:1".
|
|
23
|
-
* If `width` and `height` are provided, this parameter will be ignored.
|
|
24
|
-
*/
|
|
25
|
-
aspect_ratio?: ImageGenAspectRatio;
|
|
26
|
-
/**
|
|
27
|
-
* Optional width of the generated image in pixels.
|
|
28
|
-
* If provided along with `height`, it overrides `aspect_ratio`.
|
|
29
|
-
*/
|
|
30
|
-
width?: number;
|
|
31
|
-
/**
|
|
32
|
-
* Optional height of the generated image in pixels.
|
|
33
|
-
* If provided along with `width`, it overrides `aspect_ratio`.
|
|
34
|
-
*/
|
|
35
|
-
height?: number;
|
|
36
|
-
/**
|
|
37
|
-
* Optional boolean.
|
|
38
|
-
* If `true`, the generated image will have a transparent background.
|
|
39
|
-
* Defaults to `false`.
|
|
40
|
-
*/
|
|
41
|
-
transparent?: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Optional array of image inputs.
|
|
44
|
-
* Each object in the array should have a `url` property, which is a base64 encoded image data URL.
|
|
45
|
-
* Supports 1-4 input images for image-to-image generation.
|
|
46
|
-
*/
|
|
47
|
-
image_inputs?: { url: string }[];
|
|
48
|
-
/**
|
|
49
|
-
* Optional seed for the image generation process.
|
|
50
|
-
* Using the same prompt and seed will produce variations of the same output, useful for consistent results or exploring variations.
|
|
51
|
-
*/
|
|
52
|
-
seed?: number;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export type ImageGenResult = {
|
|
56
|
-
/**
|
|
57
|
-
* The URL of the generated image.
|
|
58
|
-
* This URL can be used to display the image.
|
|
59
|
-
*/
|
|
60
|
-
readonly url: `https://${string}/${string}`;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export namespace ImageGen {
|
|
64
|
-
export type AspectRatio = ImageGenAspectRatio;
|
|
65
|
-
export type Options = ImageGenOptions;
|
|
66
|
-
export type Result = ImageGenResult;
|
|
67
|
-
}
|
package/src/types/index.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export type TextToSpeechOptions = {
|
|
2
|
-
/**
|
|
3
|
-
* The text string to synthesize to speech.
|
|
4
|
-
*/
|
|
5
|
-
text: string;
|
|
6
|
-
/**
|
|
7
|
-
* Voice identifier (e.g., "en-male") or ElevenLabs voice ID for a specific voice.
|
|
8
|
-
*/
|
|
9
|
-
voice?: string;
|
|
10
|
-
/**
|
|
11
|
-
* Desired audio format.
|
|
12
|
-
* Defaults to "mp3".
|
|
13
|
-
*/
|
|
14
|
-
format?: "mp3" | "wav";
|
|
15
|
-
/**
|
|
16
|
-
* Playback speed multiplier.
|
|
17
|
-
* Typical range 0.5 - 2.0.
|
|
18
|
-
*/
|
|
19
|
-
speed?: number;
|
|
20
|
-
/**
|
|
21
|
-
* Pitch adjustment in semitones.
|
|
22
|
-
* Typical range -12 to 12.
|
|
23
|
-
*/
|
|
24
|
-
pitch?: number;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export type TextToSpeechResult = {
|
|
28
|
-
/**
|
|
29
|
-
* A public URL pointing to the generated audio file.
|
|
30
|
-
*/
|
|
31
|
-
readonly url: `https://${string}/${string}`;
|
|
32
|
-
};
|
package/src/types/user.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type AnonymousWebsimUser = {
|
|
2
|
-
readonly id: "1";
|
|
3
|
-
readonly username: "anonymous";
|
|
4
|
-
readonly avatar_url: null;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export type WebsimUser = {
|
|
8
|
-
readonly id: string;
|
|
9
|
-
readonly username: string;
|
|
10
|
-
readonly avatar_url: `https://${string}/${string}` | null;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type WebsimUserOrAnonymous = WebsimUser | AnonymousWebsimUser;
|
package/tsconfig.json
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
// Environment setup & latest features
|
|
4
|
-
"lib": ["ESNext", "DOM"],
|
|
5
|
-
"target": "esnext",
|
|
6
|
-
"module": "preserve",
|
|
7
|
-
"moduleDetection": "force",
|
|
8
|
-
|
|
9
|
-
// Bundler mode
|
|
10
|
-
"moduleResolution": "bundler",
|
|
11
|
-
"allowImportingTsExtensions": true,
|
|
12
|
-
"noEmit": true,
|
|
13
|
-
|
|
14
|
-
// Max strictness
|
|
15
|
-
"strict": true,
|
|
16
|
-
"skipLibCheck": true,
|
|
17
|
-
"noFallthroughCasesInSwitch": true,
|
|
18
|
-
"noUncheckedIndexedAccess": true,
|
|
19
|
-
"noImplicitOverride": true,
|
|
20
|
-
"noUnusedLocals": true,
|
|
21
|
-
"noUnusedParameters": true,
|
|
22
|
-
"noPropertyAccessFromIndexSignature": true,
|
|
23
|
-
"noImplicitAny": true,
|
|
24
|
-
"strictNullChecks": true,
|
|
25
|
-
"forceConsistentCasingInFileNames": true,
|
|
26
|
-
"verbatimModuleSyntax": true
|
|
27
|
-
}
|
|
28
|
-
}
|