@promptbook/markdown-utils 0.88.0 → 0.89.0-1

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.
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ts-node
2
+ export {};
3
+ /**
4
+ * Note: [⚫] Code in this file should never be published in any package
5
+ */
@@ -37,7 +37,8 @@ export type PromptbookServer_AnonymousIdentification = {
37
37
  /**
38
38
  * Identifier of the end user
39
39
  *
40
- * Note: this is passed to the certain model providers to identify misuse
40
+ * Note: This can be either some id or email or any other identifier
41
+ * Note: In anonymous mode, this is passed to the certain model providers to identify misuse
41
42
  * Note: In anonymous mode, there is no need to identify yourself, nor does it change the actual configuration of LLM Tools (unlike in application mode)
42
43
  */
43
44
  readonly userId?: string_user_id;
@@ -58,15 +58,27 @@ export type ApplicationRemoteServerOptions<TCustomOptions> = {
58
58
  };
59
59
  export type ApplicationRemoteServerClientOptions<TCustomOptions> = {
60
60
  /**
61
- * @@@
61
+ * Identifier of the application
62
+ *
63
+ * Note: This is usefull when you use Promptbook remote server for multiple apps/frontends, if its used just for single app, use here just "app" or "your-app-name"
64
+ * Note: This can be some id or some semantic name like "email-agent"
62
65
  */
63
66
  readonly appId: string_app_id | null;
64
67
  /**
65
- * @@@
68
+ * Identifier of the end user
69
+ *
70
+ * Note: This can be either some id or email or any other identifier
71
+ * Note: This is also passed to the certain model providers to identify misuse
66
72
  */
67
73
  readonly userId?: string_user_id;
68
74
  /**
69
- * @@@
75
+ * Token of the user to verify its identity
76
+ *
77
+ * Note: This is passed for example to `createLlmExecutionTools`
78
+ */
79
+ readonly userToken?: string_user_id;
80
+ /**
81
+ * Additional arbitrary options to identify the client or to pass custom metadata
70
82
  */
71
83
  readonly customOptions?: TCustomOptions;
72
84
  };
@@ -433,13 +433,13 @@ export type string_uuid = string & {
433
433
  *
434
434
  * @@@
435
435
  */
436
- export type string_app_id = id;
436
+ export type string_app_id = id | 'app';
437
437
  /**
438
438
  * End user identifier
439
439
  *
440
440
  * @@@
441
441
  */
442
- export type string_user_id = id;
442
+ export type string_user_id = id | string_email;
443
443
  /**
444
444
  * Semantic helper
445
445
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/markdown-utils",
3
- "version": "0.88.0",
3
+ "version": "0.89.0-1",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -25,7 +25,7 @@
25
25
  * @generated
26
26
  * @see https://github.com/webgptorg/promptbook
27
27
  */
28
- const PROMPTBOOK_ENGINE_VERSION = '0.88.0';
28
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-1';
29
29
  /**
30
30
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
31
31
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2284,8 +2284,9 @@
2284
2284
  * @returns LLM tools with same functionality with added total cost counting
2285
2285
  * @public exported from `@promptbook/core`
2286
2286
  */
2287
- function countTotalUsage(llmTools) {
2287
+ function countUsage(llmTools) {
2288
2288
  let totalUsage = ZERO_USAGE;
2289
+ const spending = new rxjs.Subject();
2289
2290
  const proxyTools = {
2290
2291
  get title() {
2291
2292
  // TODO: [🧠] Maybe put here some suffix
@@ -2295,12 +2296,15 @@
2295
2296
  // TODO: [🧠] Maybe put here some suffix
2296
2297
  return llmTools.description;
2297
2298
  },
2298
- async checkConfiguration() {
2299
+ checkConfiguration() {
2299
2300
  return /* not await */ llmTools.checkConfiguration();
2300
2301
  },
2301
2302
  listModels() {
2302
2303
  return /* not await */ llmTools.listModels();
2303
2304
  },
2305
+ spending() {
2306
+ return spending.asObservable();
2307
+ },
2304
2308
  getTotalUsage() {
2305
2309
  // <- Note: [🥫] Not using getter `get totalUsage` but `getTotalUsage` to allow this object to be proxied
2306
2310
  return totalUsage;
@@ -2311,6 +2315,7 @@
2311
2315
  // console.info('[🚕] callChatModel through countTotalUsage');
2312
2316
  const promptResult = await llmTools.callChatModel(prompt);
2313
2317
  totalUsage = addUsage(totalUsage, promptResult.usage);
2318
+ spending.next(promptResult.usage);
2314
2319
  return promptResult;
2315
2320
  };
2316
2321
  }
@@ -2319,6 +2324,7 @@
2319
2324
  // console.info('[🚕] callCompletionModel through countTotalUsage');
2320
2325
  const promptResult = await llmTools.callCompletionModel(prompt);
2321
2326
  totalUsage = addUsage(totalUsage, promptResult.usage);
2327
+ spending.next(promptResult.usage);
2322
2328
  return promptResult;
2323
2329
  };
2324
2330
  }
@@ -2327,6 +2333,7 @@
2327
2333
  // console.info('[🚕] callEmbeddingModel through countTotalUsage');
2328
2334
  const promptResult = await llmTools.callEmbeddingModel(prompt);
2329
2335
  totalUsage = addUsage(totalUsage, promptResult.usage);
2336
+ spending.next(promptResult.usage);
2330
2337
  return promptResult;
2331
2338
  };
2332
2339
  }
@@ -3609,7 +3616,7 @@
3609
3616
  // TODO: [🚐] Make arrayable LLMs -> single LLM DRY
3610
3617
  const _llms = arrayableToArray(tools.llm);
3611
3618
  const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
3612
- const llmToolsWithUsage = countTotalUsage(llmTools);
3619
+ const llmToolsWithUsage = countUsage(llmTools);
3613
3620
  // <- TODO: [🌯]
3614
3621
  /*
3615
3622
  TODO: [🧠][🪑][🔃] Should this be done or not