@boldvideo/bold-js 1.14.0 → 1.15.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @boldvideo/bold-js
2
2
 
3
+ ## 1.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d7e0675: Add `bold.ai.getConversation(conversationId)` method to fetch conversation history by ID. Returns the full conversation including messages, metadata, and timestamps.
8
+
3
9
  ## 1.14.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -220,6 +220,19 @@ const stream = await bold.ai.chat({
220
220
  });
221
221
  ```
222
222
 
223
+ ### Get Conversation History
224
+
225
+ Retrieve a conversation by ID to display message history:
226
+
227
+ ```typescript
228
+ const conversation = await bold.ai.getConversation('550e8400-e29b-41d4-a716-446655440000');
229
+
230
+ console.log(`Created: ${conversation.createdAt}`);
231
+ for (const msg of conversation.messages) {
232
+ console.log(`${msg.role}: ${msg.content}`);
233
+ }
234
+ ```
235
+
223
236
  ### Multi-turn Conversations
224
237
 
225
238
  Use the `context` parameter for follow-up questions:
@@ -279,6 +292,8 @@ import type {
279
292
  RecommendationsOptions,
280
293
  RecommendationsResponse,
281
294
  Recommendation,
295
+ Conversation,
296
+ ConversationMessage,
282
297
  Source
283
298
  } from '@boldvideo/bold-js';
284
299
  ```
package/dist/index.cjs CHANGED
@@ -321,6 +321,21 @@ async function jsonRequest(path, body, config) {
321
321
  const raw = await response.json();
322
322
  return camelizeKeys(raw);
323
323
  }
324
+ async function getRequest(path, config) {
325
+ const url = buildURL(config.baseURL, path);
326
+ const response = await fetch(url, {
327
+ method: "GET",
328
+ headers: {
329
+ "Accept": "application/json",
330
+ ...config.headers
331
+ }
332
+ });
333
+ if (!response.ok) {
334
+ throw new Error(`AI request failed: ${response.status} ${response.statusText}`);
335
+ }
336
+ const raw = await response.json();
337
+ return camelizeKeys(raw);
338
+ }
324
339
  function createAI(config) {
325
340
  async function chat(options) {
326
341
  const isVideoScoped = !!options.videoId;
@@ -387,13 +402,20 @@ function createAI(config) {
387
402
  async function recommend(options) {
388
403
  return recommendations(options);
389
404
  }
405
+ async function getConversation(conversationId) {
406
+ if (!conversationId) {
407
+ throw new Error("conversationId is required");
408
+ }
409
+ return getRequest(`ai/chat/${conversationId}`, config);
410
+ }
390
411
  return {
391
412
  chat,
392
413
  ask,
393
414
  coach,
394
415
  search,
395
416
  recommendations,
396
- recommend
417
+ recommend,
418
+ getConversation
397
419
  };
398
420
  }
399
421
 
package/dist/index.d.ts CHANGED
@@ -360,6 +360,35 @@ interface RecommendationsResponse {
360
360
  * @deprecated Use RecommendationsResponse instead
361
361
  */
362
362
  type RecommendResponse = RecommendationsResponse;
363
+ /**
364
+ * A message in a conversation
365
+ */
366
+ interface ConversationMessage {
367
+ id: string;
368
+ role: 'user' | 'assistant' | 'system';
369
+ content: string;
370
+ sources: Segment[];
371
+ insertedAt: string;
372
+ }
373
+ /**
374
+ * Conversation metadata
375
+ */
376
+ interface ConversationMetadata {
377
+ originalQuery: string;
378
+ status: string;
379
+ confidence: string;
380
+ chunksFound: number;
381
+ }
382
+ /**
383
+ * Full conversation with message history
384
+ */
385
+ interface Conversation {
386
+ conversationId: string;
387
+ messages: ConversationMessage[];
388
+ metadata: ConversationMetadata;
389
+ createdAt: string;
390
+ updatedAt: string;
391
+ }
363
392
 
364
393
  /**
365
394
  * AI client interface for type-safe method overloading
@@ -461,6 +490,16 @@ interface AIClient {
461
490
  stream?: true;
462
491
  }): Promise<AsyncIterable<AIEvent>>;
463
492
  recommend(options: RecommendOptions): Promise<AsyncIterable<AIEvent> | RecommendResponse>;
493
+ /**
494
+ * Get conversation history by ID
495
+ *
496
+ * @example
497
+ * const conversation = await bold.ai.getConversation("550e8400-e29b-41d4-a716-446655440000");
498
+ * for (const msg of conversation.messages) {
499
+ * console.log(`${msg.role}: ${msg.content}`);
500
+ * }
501
+ */
502
+ getConversation(conversationId: string): Promise<Conversation>;
464
503
  }
465
504
 
466
505
  type ClientOptions = {
@@ -505,4 +544,4 @@ declare const DEFAULT_API_BASE_URL = "https://app.boldvideo.io/api/v1/";
505
544
  */
506
545
  declare const DEFAULT_INTERNAL_API_BASE_URL = "https://app.boldvideo.io/i/v1/";
507
546
 
508
- export { AIContextMessage, AIEvent, AIResponse, AIUsage, Account, AccountAI, AnalyticsProvider, AskOptions, AssistantConfig, ChatOptions, Citation, ClientOptions, CustomRedirect, DEFAULT_API_BASE_URL, DEFAULT_INTERNAL_API_BASE_URL, MenuItem, Playlist, Portal, PortalDisplay, PortalHero, PortalLayout, PortalNavigation, PortalTheme, RecommendOptions, RecommendResponse, Recommendation, RecommendationVideo, RecommendationsOptions, RecommendationsResponse, SearchOptions, Segment, Settings, Source, ThemeColors, ThemeConfig, Video, VideoAttachment, VideoDownloadUrls, VideoMetadata, VideoSubtitles, VideoTranscript, createClient };
547
+ export { AIContextMessage, AIEvent, AIResponse, AIUsage, Account, AccountAI, AnalyticsProvider, AskOptions, AssistantConfig, ChatOptions, Citation, ClientOptions, Conversation, ConversationMessage, ConversationMetadata, CustomRedirect, DEFAULT_API_BASE_URL, DEFAULT_INTERNAL_API_BASE_URL, MenuItem, Playlist, Portal, PortalDisplay, PortalHero, PortalLayout, PortalNavigation, PortalTheme, RecommendOptions, RecommendResponse, Recommendation, RecommendationVideo, RecommendationsOptions, RecommendationsResponse, SearchOptions, Segment, Settings, Source, ThemeColors, ThemeConfig, Video, VideoAttachment, VideoDownloadUrls, VideoMetadata, VideoSubtitles, VideoTranscript, createClient };
package/dist/index.js CHANGED
@@ -283,6 +283,21 @@ async function jsonRequest(path, body, config) {
283
283
  const raw = await response.json();
284
284
  return camelizeKeys(raw);
285
285
  }
286
+ async function getRequest(path, config) {
287
+ const url = buildURL(config.baseURL, path);
288
+ const response = await fetch(url, {
289
+ method: "GET",
290
+ headers: {
291
+ "Accept": "application/json",
292
+ ...config.headers
293
+ }
294
+ });
295
+ if (!response.ok) {
296
+ throw new Error(`AI request failed: ${response.status} ${response.statusText}`);
297
+ }
298
+ const raw = await response.json();
299
+ return camelizeKeys(raw);
300
+ }
286
301
  function createAI(config) {
287
302
  async function chat(options) {
288
303
  const isVideoScoped = !!options.videoId;
@@ -349,13 +364,20 @@ function createAI(config) {
349
364
  async function recommend(options) {
350
365
  return recommendations(options);
351
366
  }
367
+ async function getConversation(conversationId) {
368
+ if (!conversationId) {
369
+ throw new Error("conversationId is required");
370
+ }
371
+ return getRequest(`ai/chat/${conversationId}`, config);
372
+ }
352
373
  return {
353
374
  chat,
354
375
  ask,
355
376
  coach,
356
377
  search,
357
378
  recommendations,
358
- recommend
379
+ recommend,
380
+ getConversation
359
381
  };
360
382
  }
361
383
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@boldvideo/bold-js",
3
3
  "license": "MIT",
4
- "version": "1.14.0",
4
+ "version": "1.15.0",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",