samsar-js 0.48.6 → 0.48.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/README.md +23 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +26 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -292,6 +292,14 @@ const externalUser = {
|
|
|
292
292
|
const externalSession = await platform.createExternalUserSession(externalUser);
|
|
293
293
|
console.log(externalSession.data.remainingCredits, externalSession.data.external_api_key);
|
|
294
294
|
|
|
295
|
+
// Store an external-user-specific assistant prompt
|
|
296
|
+
await platform.setExternalAssistantSystemPrompt(
|
|
297
|
+
{
|
|
298
|
+
system_prompt: 'You are the storefront assistant for this creator. Keep answers short, commercial, and visually aware.',
|
|
299
|
+
},
|
|
300
|
+
externalUser,
|
|
301
|
+
);
|
|
302
|
+
|
|
295
303
|
// Create a render attributed to that external user
|
|
296
304
|
const externalRender = await platform.createExternalVideoFromText(externalUser, {
|
|
297
305
|
prompt: 'A sleek teaser for a futuristic running shoe',
|
|
@@ -301,6 +309,18 @@ const externalRender = await platform.createExternalVideoFromText(externalUser,
|
|
|
301
309
|
enable_subtitles: true,
|
|
302
310
|
});
|
|
303
311
|
|
|
312
|
+
// Run an assistant completion against one of that external user's sessions.
|
|
313
|
+
// Credits are deducted from the external user, while the owning Samsar account model config is used internally.
|
|
314
|
+
const externalAssistant = await platform.createExternalAssistantCompletion(
|
|
315
|
+
{
|
|
316
|
+
session_id: externalRender.data.request_id,
|
|
317
|
+
input: 'Write a product caption for this video and suggest a headline.',
|
|
318
|
+
max_output_tokens: 250,
|
|
319
|
+
},
|
|
320
|
+
externalUser,
|
|
321
|
+
);
|
|
322
|
+
console.log(externalAssistant.data.output_text);
|
|
323
|
+
|
|
304
324
|
// Fetch their external library
|
|
305
325
|
const library = await platform.listExternalUserRequests(externalUser, { limit: 12 });
|
|
306
326
|
console.log(library.data.requests.length);
|
|
@@ -326,6 +346,9 @@ const verified = await platform.verifyClientSession({
|
|
|
326
346
|
const externalClient = new SamsarClient({
|
|
327
347
|
apiKey: verified.data.authToken!,
|
|
328
348
|
});
|
|
349
|
+
await externalClient.setExternalAssistantSystemPrompt({
|
|
350
|
+
system_prompt: 'You are my personal launch assistant. Stay concise and actionable.',
|
|
351
|
+
});
|
|
329
352
|
const externalLibrary = await externalClient.listExternalUserRequests();
|
|
330
353
|
console.log(externalLibrary.data.requests.map((request) => request.request_id));
|
|
331
354
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1062,6 +1062,10 @@ export interface ExternalCreateLoginTokenResponse extends CreateLoginTokenRespon
|
|
|
1062
1062
|
external_user?: ExternalUserSummary | null;
|
|
1063
1063
|
externalUser?: ExternalUserSummary | null;
|
|
1064
1064
|
}
|
|
1065
|
+
export interface ExternalAssistantSetSystemPromptResponse extends AssistantSetSystemPromptResponse {
|
|
1066
|
+
external_user?: ExternalUserSummary | null;
|
|
1067
|
+
externalUser?: ExternalUserSummary | null;
|
|
1068
|
+
}
|
|
1065
1069
|
export interface VerifyClientSessionInput {
|
|
1066
1070
|
loginToken?: string;
|
|
1067
1071
|
authToken?: string;
|
|
@@ -1231,6 +1235,16 @@ export declare class SamsarClient {
|
|
|
1231
1235
|
createExternalUserLoginToken(externalUser?: ExternalUserIdentity | null, options?: ({
|
|
1232
1236
|
redirect?: string;
|
|
1233
1237
|
} & SamsarRequestOptions)): Promise<SamsarResult<ExternalCreateLoginTokenResponse>>;
|
|
1238
|
+
/**
|
|
1239
|
+
* Store or clear the external user’s assistant system prompt.
|
|
1240
|
+
* When set, it overrides the owning account prompt for future assistant requests from that external user.
|
|
1241
|
+
*/
|
|
1242
|
+
setExternalAssistantSystemPrompt(payload: AssistantSetSystemPromptRequest, externalUser?: ExternalUserIdentity | null, options?: SamsarRequestOptions): Promise<SamsarResult<ExternalAssistantSetSystemPromptResponse>>;
|
|
1243
|
+
/**
|
|
1244
|
+
* Create an assistant completion scoped to an external user while billing that external user's credit balance.
|
|
1245
|
+
* The owning Samsar account's configured assistant model is used internally.
|
|
1246
|
+
*/
|
|
1247
|
+
createExternalAssistantCompletion(payload: AssistantCompletionRequest, externalUser?: ExternalUserIdentity | null, options?: SamsarRequestOptions): Promise<SamsarResult<AssistantCompletionResponse>>;
|
|
1234
1248
|
/**
|
|
1235
1249
|
* Translate an existing video session into a new language.
|
|
1236
1250
|
* Creates a new session_id and queues generation steps for lip sync + transcription + video render.
|
package/dist/index.js
CHANGED
|
@@ -128,6 +128,32 @@ export class SamsarClient {
|
|
|
128
128
|
}
|
|
129
129
|
return this.post('external_users/create_login_token', body, options);
|
|
130
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Store or clear the external user’s assistant system prompt.
|
|
133
|
+
* When set, it overrides the owning account prompt for future assistant requests from that external user.
|
|
134
|
+
*/
|
|
135
|
+
async setExternalAssistantSystemPrompt(payload, externalUser, options) {
|
|
136
|
+
const body = {
|
|
137
|
+
...payload,
|
|
138
|
+
};
|
|
139
|
+
if (externalUser) {
|
|
140
|
+
body.external_user = normalizeExternalUserIdentity(externalUser);
|
|
141
|
+
}
|
|
142
|
+
return this.post('external_users/assistant/set_system_prompt', body, options);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Create an assistant completion scoped to an external user while billing that external user's credit balance.
|
|
146
|
+
* The owning Samsar account's configured assistant model is used internally.
|
|
147
|
+
*/
|
|
148
|
+
async createExternalAssistantCompletion(payload, externalUser, options) {
|
|
149
|
+
const body = {
|
|
150
|
+
...payload,
|
|
151
|
+
};
|
|
152
|
+
if (externalUser) {
|
|
153
|
+
body.external_user = normalizeExternalUserIdentity(externalUser);
|
|
154
|
+
}
|
|
155
|
+
return this.post('external_users/assistant/completion', body, options);
|
|
156
|
+
}
|
|
131
157
|
/**
|
|
132
158
|
* Translate an existing video session into a new language.
|
|
133
159
|
* Creates a new session_id and queues generation steps for lip sync + transcription + video render.
|