@butlerbot/sdk 0.0.1 → 0.0.3

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/dist/index.d.ts CHANGED
@@ -22,7 +22,4 @@ export declare class ButlerBotClient {
22
22
  createConversation(config?: OptionalApiKey<ConversationOptions>): Conversation;
23
23
  }
24
24
  export { Conversation, ConversationOptions };
25
- export * from "./types/ai_response_v3";
26
- export * from "./types/dialogue_response_v3";
27
- export * from "./types/error";
28
- export * from "./types/ai_tools_v3";
25
+ export * from "./types/type_registry";
package/dist/index.js CHANGED
@@ -54,8 +54,4 @@ class ButlerBotClient {
54
54
  }
55
55
  }
56
56
  exports.ButlerBotClient = ButlerBotClient;
57
- // Expose types from /types
58
- __exportStar(require("./types/ai_response_v3"), exports); // ai_response_v3.ts
59
- __exportStar(require("./types/dialogue_response_v3"), exports); // dialogue_response_v3.ts
60
- __exportStar(require("./types/error"), exports); // error.ts
61
- __exportStar(require("./types/ai_tools_v3"), exports); // ai_tools_v3.ts
57
+ __exportStar(require("./types/type_registry"), exports);
@@ -13,6 +13,7 @@ export type DialogueRequestParams = {
13
13
  /** Custom personality configuration for the AI */
14
14
  personality?: string;
15
15
  };
16
+ export type DialogueRequestOptions = Omit<Omit<DialogueRequestParams, "message">, "chatId">;
16
17
  export type ConversationOptions = {
17
18
  /** The conversation ID to load the conversation from, server will error if this convo id doesn't exist */
18
19
  convoId?: string;
@@ -27,10 +28,35 @@ export type ConversationOptions = {
27
28
  };
28
29
  export declare class Conversation {
29
30
  convoId?: string;
30
- endpoint: string;
31
31
  apiKey: string;
32
32
  private debug;
33
+ private options?;
34
+ private endpoint;
33
35
  constructor(config: ConversationOptions);
36
+ /** Sets the endpoint where the request is sent to, appended to server URL */
37
+ setEndpoint(endpoint: string): this;
38
+ /** Sets the conversation ID, has to be an existing conversation ID, undefined otherwise */
39
+ setConvoId(convoId: string | undefined): this;
40
+ /** Sets the AI model used for the next interaction, e.g Claude-Sonnet, GPT-4 */
41
+ setModel(model: string): this;
42
+ /** Sets additional instructions for location-specific context */
43
+ setInstructions(instructions: string): this;
44
+ /** Sets the platform where the chat is occurring, used internally for logging - ignore in most contexts */
45
+ setPlatform(platform: string): this;
46
+ /** Sets a custom personality configuration for the AI */
47
+ setPersonality(personality: string): this;
48
+ /** Gets the current conversation ID */
49
+ getConvoId(): string | undefined;
50
+ /** Gets the current endpoint */
51
+ getEndpoint(): string;
52
+ /** Gets the current options object */
53
+ getModel(): string | undefined;
54
+ /** Gets the current location-specific instructions */
55
+ getInstructions(): string | undefined;
56
+ /** Gets the current platform */
57
+ getPlatform(): string | undefined;
58
+ /** Gets the current personality configuration */
59
+ getPersonality(): string | undefined;
34
60
  /** Sends a message into the conversation */
35
- send(message: string, cb: (chunk: RequestResponse) => any): Promise<void>;
61
+ send(message: string, cb: (chunk: RequestResponse) => any, options?: DialogueRequestOptions): Promise<void>;
36
62
  }
@@ -19,13 +19,72 @@ class Conversation {
19
19
  this.apiKey = config.apiKey;
20
20
  this.debug = config.debug || false;
21
21
  }
22
+ // SETTERS
23
+ /** Sets the endpoint where the request is sent to, appended to server URL */
24
+ setEndpoint(endpoint) {
25
+ this.endpoint = endpoint;
26
+ return this;
27
+ }
28
+ /** Sets the conversation ID, has to be an existing conversation ID, undefined otherwise */
29
+ setConvoId(convoId) {
30
+ this.convoId = convoId;
31
+ return this;
32
+ }
33
+ /** Sets the AI model used for the next interaction, e.g Claude-Sonnet, GPT-4 */
34
+ setModel(model) {
35
+ this.options = Object.assign(Object.assign({}, this.options), { model });
36
+ return this;
37
+ }
38
+ /** Sets additional instructions for location-specific context */
39
+ setInstructions(instructions) {
40
+ this.options = Object.assign(Object.assign({}, this.options), { instructions });
41
+ return this;
42
+ }
43
+ /** Sets the platform where the chat is occurring, used internally for logging - ignore in most contexts */
44
+ setPlatform(platform) {
45
+ this.options = Object.assign(Object.assign({}, this.options), { platform });
46
+ return this;
47
+ }
48
+ /** Sets a custom personality configuration for the AI */
49
+ setPersonality(personality) {
50
+ this.options = Object.assign(Object.assign({}, this.options), { personality });
51
+ return this;
52
+ }
53
+ // GETTERS
54
+ /** Gets the current conversation ID */
55
+ getConvoId() {
56
+ return this.convoId;
57
+ }
58
+ /** Gets the current endpoint */
59
+ getEndpoint() {
60
+ return this.endpoint;
61
+ }
62
+ /** Gets the current options object */
63
+ getModel() {
64
+ var _a;
65
+ return (_a = this.options) === null || _a === void 0 ? void 0 : _a.model;
66
+ }
67
+ /** Gets the current location-specific instructions */
68
+ getInstructions() {
69
+ var _a;
70
+ return (_a = this.options) === null || _a === void 0 ? void 0 : _a.instructions;
71
+ }
72
+ /** Gets the current platform */
73
+ getPlatform() {
74
+ var _a;
75
+ return (_a = this.options) === null || _a === void 0 ? void 0 : _a.platform;
76
+ }
77
+ /** Gets the current personality configuration */
78
+ getPersonality() {
79
+ var _a;
80
+ return (_a = this.options) === null || _a === void 0 ? void 0 : _a.personality;
81
+ }
82
+ // LIFE CYCLE
22
83
  /** Sends a message into the conversation */
23
- send(message, cb) {
84
+ send(message, cb, options) {
24
85
  return __awaiter(this, void 0, void 0, function* () {
25
- const params = {
26
- message,
27
- api_key: this.apiKey
28
- };
86
+ const params = Object.assign(Object.assign({ message, api_key: this.apiKey }, this.options), options // overwrite convos for this call
87
+ );
29
88
  if (this.convoId)
30
89
  params.chatId = this.convoId;
31
90
  const paramQuery = new URLSearchParams(params).toString();
@@ -17,7 +17,7 @@ export type RequestFailResponse = {
17
17
  message: string;
18
18
  } & RequestBaseResponsePayload;
19
19
  };
20
- export type RequestSucessResponse = {
20
+ export type RequestSuccessResponse = {
21
21
  success: true;
22
22
  data: {
23
23
  /** The AI's response */
@@ -26,4 +26,4 @@ export type RequestSucessResponse = {
26
26
  convoId?: string;
27
27
  } & RequestBaseResponsePayload;
28
28
  };
29
- export type RequestResponse = RequestFailResponse | RequestSucessResponse;
29
+ export type RequestResponse = RequestFailResponse | RequestSuccessResponse;
@@ -0,0 +1,4 @@
1
+ export * from "./ai_response_v3";
2
+ export * from "./dialogue_response_v3";
3
+ export * from "./error";
4
+ export * from "./ai_tools_v3";
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ai_response_v3"), exports);
18
+ __exportStar(require("./dialogue_response_v3"), exports);
19
+ __exportStar(require("./error"), exports);
20
+ __exportStar(require("./ai_tools_v3"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@butlerbot/sdk",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "The official ButlerBot SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",