@promptbook/templates 0.89.0-7 → 0.89.0-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/esm/index.es.js CHANGED
@@ -16,7 +16,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
16
16
  * @generated
17
17
  * @see https://github.com/webgptorg/promptbook
18
18
  */
19
- const PROMPTBOOK_ENGINE_VERSION = '0.89.0-7';
19
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-8';
20
20
  /**
21
21
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
22
22
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1494,7 +1494,7 @@ function getTemplatesPipelineCollection() {
1494
1494
  "preparations": [
1495
1495
  {
1496
1496
  "id": 1,
1497
- "promptbookVersion": "0.89.0-6",
1497
+ "promptbookVersion": "0.89.0-7",
1498
1498
  "usage": {
1499
1499
  "price": {
1500
1500
  "value": 0.005718
@@ -1975,7 +1975,7 @@ function getTemplatesPipelineCollection() {
1975
1975
  "preparations": [
1976
1976
  {
1977
1977
  "id": 1,
1978
- "promptbookVersion": "0.89.0-6",
1978
+ "promptbookVersion": "0.89.0-7",
1979
1979
  "usage": {
1980
1980
  "price": {
1981
1981
  "value": 0.005718
@@ -2551,7 +2551,7 @@ function getTemplatesPipelineCollection() {
2551
2551
  "preparations": [
2552
2552
  {
2553
2553
  "id": 1,
2554
- "promptbookVersion": "0.89.0-6",
2554
+ "promptbookVersion": "0.89.0-7",
2555
2555
  "usage": {
2556
2556
  "price": {
2557
2557
  "value": 0.00588
@@ -2673,7 +2673,7 @@ function getTemplatesPipelineCollection() {
2673
2673
  "preparations": [
2674
2674
  {
2675
2675
  "id": 1,
2676
- "promptbookVersion": "0.89.0-6",
2676
+ "promptbookVersion": "0.89.0-7",
2677
2677
  "usage": {
2678
2678
  "price": {
2679
2679
  "value": 0.005865
@@ -2769,7 +2769,7 @@ function getTemplatesPipelineCollection() {
2769
2769
  "preparations": [
2770
2770
  {
2771
2771
  "id": 1,
2772
- "promptbookVersion": "0.89.0-6",
2772
+ "promptbookVersion": "0.89.0-7",
2773
2773
  "usage": {
2774
2774
  "price": {
2775
2775
  "value": 0
@@ -2886,7 +2886,7 @@ function getTemplatesPipelineCollection() {
2886
2886
  "preparations": [
2887
2887
  {
2888
2888
  "id": 1,
2889
- "promptbookVersion": "0.89.0-6",
2889
+ "promptbookVersion": "0.89.0-7",
2890
2890
  "usage": {
2891
2891
  "price": {
2892
2892
  "value": 0.005412
@@ -3016,7 +3016,7 @@ function getTemplatesPipelineCollection() {
3016
3016
  "preparations": [
3017
3017
  {
3018
3018
  "id": 1,
3019
- "promptbookVersion": "0.89.0-6",
3019
+ "promptbookVersion": "0.89.0-7",
3020
3020
  "usage": {
3021
3021
  "price": {
3022
3022
  "value": 0.005442000000000001
@@ -3326,7 +3326,7 @@ function getTemplatesPipelineCollection() {
3326
3326
  "preparations": [
3327
3327
  {
3328
3328
  "id": 1,
3329
- "promptbookVersion": "0.89.0-6",
3329
+ "promptbookVersion": "0.89.0-7",
3330
3330
  "usage": {
3331
3331
  "price": {
3332
3332
  "value": 0.005895
@@ -121,6 +121,7 @@ import type { RemoteServerOptions } from '../remote-server/types/RemoteServerOpt
121
121
  import type { AnonymousRemoteServerOptions } from '../remote-server/types/RemoteServerOptions';
122
122
  import type { ApplicationRemoteServerOptions } from '../remote-server/types/RemoteServerOptions';
123
123
  import type { ApplicationRemoteServerClientOptions } from '../remote-server/types/RemoteServerOptions';
124
+ import type { ApplicationRemoteServerOptionsLoginResponse } from '../remote-server/types/RemoteServerOptions';
124
125
  import type { Converter } from '../scrapers/_common/Converter';
125
126
  import type { ScraperAndConverterMetadata } from '../scrapers/_common/register/ScraperAndConverterMetadata';
126
127
  import type { ScraperConstructor } from '../scrapers/_common/register/ScraperConstructor';
@@ -411,6 +412,7 @@ export type { RemoteServerOptions };
411
412
  export type { AnonymousRemoteServerOptions };
412
413
  export type { ApplicationRemoteServerOptions };
413
414
  export type { ApplicationRemoteServerClientOptions };
415
+ export type { ApplicationRemoteServerOptionsLoginResponse };
414
416
  export type { Converter };
415
417
  export type { ScraperAndConverterMetadata };
416
418
  export type { ScraperConstructor };
@@ -1,5 +1,7 @@
1
+ import type { Request, Response } from 'express';
1
2
  import type { Promisable } from 'type-fest';
2
3
  import type { PipelineCollection } from '../../collection/PipelineCollection';
4
+ import { AuthenticationError } from '../../errors/AuthenticationError';
3
5
  import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
4
6
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
5
7
  import type { string_app_id } from '../../types/typeAliases';
@@ -35,7 +37,11 @@ export type RemoteServerOptions<TCustomOptions> = CommonToolsOptions & {
35
37
  * @example '/api/promptbook/'
36
38
  */
37
39
  readonly rootPath?: string_uri;
38
- } & (AnonymousRemoteServerOptions | ApplicationRemoteServerOptions<TCustomOptions> | (AnonymousRemoteServerOptions & ApplicationRemoteServerOptions<TCustomOptions>));
40
+ } & ((AnonymousRemoteServerOptions & {
41
+ readonly isApplicationModeAllowed?: false;
42
+ }) | ({
43
+ readonly isAnonymousModeAllowed?: false;
44
+ } & ApplicationRemoteServerOptions<TCustomOptions>) | (AnonymousRemoteServerOptions & ApplicationRemoteServerOptions<TCustomOptions>));
39
45
  export type AnonymousRemoteServerOptions = {
40
46
  /**
41
47
  * Enable anonymous mode
@@ -55,13 +61,14 @@ export type ApplicationRemoteServerOptions<TCustomOptions> = {
55
61
  readonly collection: PipelineCollection;
56
62
  /**
57
63
  * User tries to login to the server, this function will be called verify the user and return the identification or throw an error
58
- *
64
+ * This can be also doubled as a function to register the user
59
65
  *
60
66
  * Note: In most cases, you will return `PromptbookServer_ApplicationIdentification`
61
67
  * `PromptbookServer_AnonymousIdentification` is useful only in scenarios when user stores its own api keys on the application server and
62
68
  * server acts only as a api key provider
63
69
  *
64
- * @throws `AuthenticationError` if the user is not allowed to login for example because of invalid credentials
70
+ * Note: In most cases DO NOT THROW `AuthenticationError` but return `isSuccess: false` with message
71
+ * @throws `AuthenticationError` if the user is not allowed to login for example because of invalid credentials
65
72
  */
66
73
  login(credentials: {
67
74
  /**
@@ -78,7 +85,17 @@ export type ApplicationRemoteServerOptions<TCustomOptions> = {
78
85
  * Password of the user
79
86
  */
80
87
  readonly password: string_password;
81
- }): Promise<PromptbookServer_Identification<TCustomOptions>>;
88
+ /**
89
+ * Request object from express if you want to access some request data for example headers, IP address, etc.
90
+ */
91
+ readonly rawRequest: Request;
92
+ /**
93
+ * Response object from express if you want to add some custom headers.
94
+ *
95
+ * Note: It is not recommended to use this object to send body of the response because it can confuse the client
96
+ */
97
+ readonly rawResponse: Response;
98
+ }): Promise<ApplicationRemoteServerOptionsLoginResponse<TCustomOptions>>;
82
99
  /**
83
100
  * Creates llm execution tools for each client
84
101
  */
@@ -110,6 +127,18 @@ export type ApplicationRemoteServerClientOptions<TCustomOptions> = {
110
127
  */
111
128
  readonly customOptions?: TCustomOptions;
112
129
  };
130
+ export type ApplicationRemoteServerOptionsLoginResponse<TCustomOptions> = {
131
+ /**
132
+ * Was the login successful
133
+ */
134
+ readonly isSuccess: boolean;
135
+ /**
136
+ *
137
+ */
138
+ readonly message?: string;
139
+ readonly error?: AuthenticationError;
140
+ readonly identification?: PromptbookServer_Identification<TCustomOptions>;
141
+ };
113
142
  /**
114
143
  * TODO: Constrain anonymous mode for specific models / providers
115
144
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/templates",
3
- "version": "0.89.0-7",
3
+ "version": "0.89.0-8",
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,
@@ -47,7 +47,7 @@
47
47
  "module": "./esm/index.es.js",
48
48
  "typings": "./esm/typings/src/_packages/templates.index.d.ts",
49
49
  "peerDependencies": {
50
- "@promptbook/core": "0.89.0-7"
50
+ "@promptbook/core": "0.89.0-8"
51
51
  },
52
52
  "dependencies": {
53
53
  "prettier": "2.8.1",
package/umd/index.umd.js CHANGED
@@ -23,7 +23,7 @@
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- const PROMPTBOOK_ENGINE_VERSION = '0.89.0-7';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-8';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1501,7 +1501,7 @@
1501
1501
  "preparations": [
1502
1502
  {
1503
1503
  "id": 1,
1504
- "promptbookVersion": "0.89.0-6",
1504
+ "promptbookVersion": "0.89.0-7",
1505
1505
  "usage": {
1506
1506
  "price": {
1507
1507
  "value": 0.005718
@@ -1982,7 +1982,7 @@
1982
1982
  "preparations": [
1983
1983
  {
1984
1984
  "id": 1,
1985
- "promptbookVersion": "0.89.0-6",
1985
+ "promptbookVersion": "0.89.0-7",
1986
1986
  "usage": {
1987
1987
  "price": {
1988
1988
  "value": 0.005718
@@ -2558,7 +2558,7 @@
2558
2558
  "preparations": [
2559
2559
  {
2560
2560
  "id": 1,
2561
- "promptbookVersion": "0.89.0-6",
2561
+ "promptbookVersion": "0.89.0-7",
2562
2562
  "usage": {
2563
2563
  "price": {
2564
2564
  "value": 0.00588
@@ -2680,7 +2680,7 @@
2680
2680
  "preparations": [
2681
2681
  {
2682
2682
  "id": 1,
2683
- "promptbookVersion": "0.89.0-6",
2683
+ "promptbookVersion": "0.89.0-7",
2684
2684
  "usage": {
2685
2685
  "price": {
2686
2686
  "value": 0.005865
@@ -2776,7 +2776,7 @@
2776
2776
  "preparations": [
2777
2777
  {
2778
2778
  "id": 1,
2779
- "promptbookVersion": "0.89.0-6",
2779
+ "promptbookVersion": "0.89.0-7",
2780
2780
  "usage": {
2781
2781
  "price": {
2782
2782
  "value": 0
@@ -2893,7 +2893,7 @@
2893
2893
  "preparations": [
2894
2894
  {
2895
2895
  "id": 1,
2896
- "promptbookVersion": "0.89.0-6",
2896
+ "promptbookVersion": "0.89.0-7",
2897
2897
  "usage": {
2898
2898
  "price": {
2899
2899
  "value": 0.005412
@@ -3023,7 +3023,7 @@
3023
3023
  "preparations": [
3024
3024
  {
3025
3025
  "id": 1,
3026
- "promptbookVersion": "0.89.0-6",
3026
+ "promptbookVersion": "0.89.0-7",
3027
3027
  "usage": {
3028
3028
  "price": {
3029
3029
  "value": 0.005442000000000001
@@ -3333,7 +3333,7 @@
3333
3333
  "preparations": [
3334
3334
  {
3335
3335
  "id": 1,
3336
- "promptbookVersion": "0.89.0-6",
3336
+ "promptbookVersion": "0.89.0-7",
3337
3337
  "usage": {
3338
3338
  "price": {
3339
3339
  "value": 0.005895