@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.
@@ -87,7 +87,7 @@ import { $llmToolsMetadataRegister } from '../llm-providers/_common/register/$ll
87
87
  import { $llmToolsRegister } from '../llm-providers/_common/register/$llmToolsRegister';
88
88
  import { createLlmToolsFromConfiguration } from '../llm-providers/_common/register/createLlmToolsFromConfiguration';
89
89
  import { cacheLlmTools } from '../llm-providers/_common/utils/cache/cacheLlmTools';
90
- import { countTotalUsage } from '../llm-providers/_common/utils/count-total-usage/countTotalUsage';
90
+ import { countUsage } from '../llm-providers/_common/utils/count-total-usage/countUsage';
91
91
  import { limitTotalUsage } from '../llm-providers/_common/utils/count-total-usage/limitTotalUsage';
92
92
  import { _AnthropicClaudeMetadataRegistration } from '../llm-providers/anthropic-claude/register-configuration';
93
93
  import { _AzureOpenAiMetadataRegistration } from '../llm-providers/azure-openai/register-configuration';
@@ -217,7 +217,7 @@ export { $llmToolsMetadataRegister };
217
217
  export { $llmToolsRegister };
218
218
  export { createLlmToolsFromConfiguration };
219
219
  export { cacheLlmTools };
220
- export { countTotalUsage };
220
+ export { countUsage };
221
221
  export { limitTotalUsage };
222
222
  export { _AnthropicClaudeMetadataRegistration };
223
223
  export { _AzureOpenAiMetadataRegistration };
@@ -106,6 +106,11 @@ import type { ScriptTaskJson } from '../pipeline/PipelineJson/ScriptTaskJson';
106
106
  import type { SimpleTaskJson } from '../pipeline/PipelineJson/SimpleTaskJson';
107
107
  import type { TaskJson } from '../pipeline/PipelineJson/TaskJson';
108
108
  import type { PipelineString } from '../pipeline/PipelineString';
109
+ import type { paths } from '../playground/brjapp-api-schema';
110
+ import type { webhooks } from '../playground/brjapp-api-schema';
111
+ import type { components } from '../playground/brjapp-api-schema';
112
+ import type { $defs } from '../playground/brjapp-api-schema';
113
+ import type { operations } from '../playground/brjapp-api-schema';
109
114
  import type { PrepareAndScrapeOptions } from '../prepare/PrepareAndScrapeOptions';
110
115
  import type { PromptbookServer_Identification } from '../remote-server/socket-types/_subtypes/PromptbookServer_Identification';
111
116
  import type { PromptbookServer_ApplicationIdentification } from '../remote-server/socket-types/_subtypes/PromptbookServer_Identification';
@@ -389,6 +394,11 @@ export type { ScriptTaskJson };
389
394
  export type { SimpleTaskJson };
390
395
  export type { TaskJson };
391
396
  export type { PipelineString };
397
+ export type { paths };
398
+ export type { webhooks };
399
+ export type { components };
400
+ export type { $defs };
401
+ export type { operations };
392
402
  export type { PrepareAndScrapeOptions };
393
403
  export type { PromptbookServer_Identification };
394
404
  export type { PromptbookServer_ApplicationIdentification };
@@ -1,3 +1,4 @@
1
+ import type { Observable } from 'rxjs';
1
2
  import type { LlmExecutionTools } from '../../../../execution/LlmExecutionTools';
2
3
  import type { PromptResultUsage } from '../../../../execution/PromptResultUsage';
3
4
  /**
@@ -8,6 +9,12 @@ export type LlmExecutionToolsWithTotalUsage = LlmExecutionTools & {
8
9
  * Get total cost of the execution up to this point
9
10
  */
10
11
  getTotalUsage(): PromptResultUsage;
12
+ /**
13
+ * Observable of total cost of the execution up to this point
14
+ *
15
+ * Note: This does report the cost of the last prompt, not the total cost of the execution up to this point
16
+ */
17
+ spending(): Observable<PromptResultUsage>;
11
18
  };
12
19
  /**
13
20
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
@@ -7,7 +7,7 @@ import type { LlmExecutionToolsWithTotalUsage } from './LlmExecutionToolsWithTot
7
7
  * @returns LLM tools with same functionality with added total cost counting
8
8
  * @public exported from `@promptbook/core`
9
9
  */
10
- export declare function countTotalUsage(llmTools: LlmExecutionTools): LlmExecutionToolsWithTotalUsage;
10
+ export declare function countUsage(llmTools: LlmExecutionTools): LlmExecutionToolsWithTotalUsage;
11
11
  /**
12
12
  * TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
13
13
  * TODO: [🧠] Is there some meaningfull way how to test this util
@@ -0,0 +1,64 @@
1
+ type BrjappOptions = {
2
+ /**
3
+ * Add user to these groups
4
+ */
5
+ readonly userGroups: Array<string>;
6
+ /**
7
+ * Add this amount of credits to new users
8
+ */
9
+ readonly initialCredits: number;
10
+ };
11
+ /**
12
+ * Note: Credit = 1 Word to generate or read
13
+ * Note: What we call here "user" is on BRJ.APP "customer"
14
+ *
15
+ * @private - this will be moved to Promptbook studio
16
+ */
17
+ export declare class BrjappConnector {
18
+ private readonly apiKey;
19
+ private options;
20
+ private readonly client;
21
+ constructor(apiKey: string, options: BrjappOptions);
22
+ /**
23
+ * Login or register user
24
+ *
25
+ * TODO: [🧠] Probbably better name for this method
26
+ *
27
+ * @param options
28
+ * @returns user token or null if user needs to verify email
29
+ */
30
+ loginOrRegister(options: {
31
+ email: string;
32
+ password: string;
33
+ customerRealIp: string;
34
+ }): Promise<{
35
+ isSuccess: boolean;
36
+ message: string;
37
+ token: string | null;
38
+ isEmailVerificationRequired: boolean;
39
+ }>;
40
+ private addInitailCredits;
41
+ buyCredits(options: {
42
+ email: string;
43
+ customerRealIp: string;
44
+ }): Promise<{
45
+ isSuccess: boolean;
46
+ message: string;
47
+ payLink: string | null;
48
+ }>;
49
+ /**
50
+ *
51
+ * @returns true if credits were spent, false if not enough credits or another error
52
+ */
53
+ spendCredits(options: {
54
+ email: string;
55
+ token: string;
56
+ creditsAmount: number;
57
+ description: string;
58
+ customerRealIp: string;
59
+ }): Promise<{
60
+ isSuccess: boolean;
61
+ message: string;
62
+ }>;
63
+ }
64
+ export {};