@butlerbot/sdk 0.0.2 → 0.0.4

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.
@@ -28,10 +28,35 @@ export type ConversationOptions = {
28
28
  };
29
29
  export declare class Conversation {
30
30
  convoId?: string;
31
- endpoint: string;
32
31
  apiKey: string;
33
32
  private debug;
33
+ private options?;
34
+ private endpoint;
34
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;
35
60
  /** Sends a message into the conversation */
36
61
  send(message: string, cb: (chunk: RequestResponse) => any, options?: DialogueRequestOptions): Promise<void>;
37
62
  }
@@ -19,10 +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
84
  send(message, cb, options) {
24
85
  return __awaiter(this, void 0, void 0, function* () {
25
- const params = Object.assign({ message, api_key: this.apiKey }, options);
86
+ const params = Object.assign(Object.assign({ message, api_key: this.apiKey }, this.options), options // overwrite convos for this call
87
+ );
26
88
  if (this.convoId)
27
89
  params.chatId = this.convoId;
28
90
  const paramQuery = new URLSearchParams(params).toString();
@@ -10,15 +10,21 @@ export type AIChatResultSuccess = {
10
10
  usage: any;
11
11
  };
12
12
  export type AIChatResult = AIChatResultFail | AIChatResultSuccess;
13
+ type AIChatProfileDisplayEntity = {
14
+ name?: string;
15
+ avatarUrl?: string;
16
+ };
13
17
  export type BaseAIResponseMetadata = {
14
18
  /** The model that generated this message */
15
19
  model: string;
16
20
  /** The actual model ID that generated this message */
17
21
  modelId: string;
18
- /** Epoch time for when this happened */
22
+ /** The time when this action started (represents time of first action, meaning in streamed messages it'll hold the time the first chunk was sent) */
23
+ firstTimestamp: number;
24
+ /** Epoch time for when this happened (represents time of last action, meaning in streamed messages it'll hold the time the last chunk was sent) */
19
25
  timestamp: number;
20
26
  };
21
- export type AIMessageResponse = {
27
+ type AIMessageResponse = {
22
28
  /** Specifies type to be a message */
23
29
  type: "message";
24
30
  payload: {
@@ -29,7 +35,26 @@ export type AIMessageResponse = {
29
35
  /** Whether this message was completed */
30
36
  completed: boolean;
31
37
  };
32
- metadata: BaseAIResponseMetadata & {};
38
+ metadata: BaseAIResponseMetadata & {
39
+ /** Display data for this message response, such as the author's name and profile picture */
40
+ display?: AIChatProfileDisplayEntity;
41
+ };
42
+ };
43
+ export type AIFileResponse = {
44
+ /** Specifies type to be a message */
45
+ type: "file";
46
+ payload: {
47
+ /** URL location of the file */
48
+ url?: string;
49
+ /** Base64 representation of the file */
50
+ base64?: string;
51
+ /** The media type of the file */
52
+ mediaType: string;
53
+ };
54
+ metadata: BaseAIResponseMetadata & {
55
+ /** Display data for this message response, such as the author's name and profile picture */
56
+ display?: AIChatProfileDisplayEntity;
57
+ };
33
58
  };
34
59
  export type AIResponseStatusResponse = {
35
60
  /** Specifies type to be a status update for the response */
@@ -59,4 +84,5 @@ export type AIToolResponse = {
59
84
  };
60
85
  metadata: BaseAIResponseMetadata & {};
61
86
  };
62
- export type AIResponse = AIMessageResponse | AIToolResponse | AIConvoStatusResponse | AIResponseStatusResponse;
87
+ export type AIResponse = AIMessageResponse | AIToolResponse | AIConvoStatusResponse | AIResponseStatusResponse | AIFileResponse;
88
+ export {};
package/package.json CHANGED
@@ -1,44 +1,44 @@
1
1
  {
2
- "name": "@butlerbot/sdk",
3
- "version": "0.0.2",
4
- "description": "The official ButlerBot SDK",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "files": [
8
- "dist/**/*"
9
- ],
10
- "scripts": {
11
- "build": "tsc",
12
- "pack": "npm run build && npm pack --pack-destination=\"G:\\tarballs\"",
13
- "update": "npm run build && npm publish --access public",
14
- "test": "jest"
15
- },
16
- "keywords": [
17
- "butlerbot",
18
- "alfred",
19
- "sdk",
20
- "chatbot",
21
- "ai",
22
- "butler"
23
- ],
24
- "author": "Fragly",
25
- "license": "MIT",
26
- "repository": {
27
- "type": "git",
28
- "url": "git+https://github.com/isdevco/alfred5_sdk.git"
29
- },
30
- "bugs": {
31
- "url": "https://github.com/isdevco/alfred5_sdk/issues"
32
- },
33
- "homepage": "https://butlerbot.net",
34
- "engines": {
35
- "node": ">=14.0.0"
36
- },
37
- "devDependencies": {
38
- "@types/node": "^22.13.10",
39
- "typescript": "^5.8.2"
40
- },
41
- "dependencies": {
42
- "eventsource": "^3.0.5"
43
- }
44
- }
2
+ "name": "@butlerbot/sdk",
3
+ "version": "0.0.4",
4
+ "description": "The official ButlerBot SDK",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist/**/*"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "pack": "npm run build && npm pack --pack-destination=\"G:\\tarballs\"",
13
+ "update": "npm run build && npm publish --access public",
14
+ "test": "jest"
15
+ },
16
+ "keywords": [
17
+ "butlerbot",
18
+ "alfred",
19
+ "sdk",
20
+ "chatbot",
21
+ "ai",
22
+ "butler"
23
+ ],
24
+ "author": "Fragly",
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/isdevco/alfred5_sdk.git"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/isdevco/alfred5_sdk/issues"
32
+ },
33
+ "homepage": "https://butlerbot.net",
34
+ "engines": {
35
+ "node": ">=14.0.0"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "^22.13.10",
39
+ "typescript": "^5.8.2"
40
+ },
41
+ "dependencies": {
42
+ "eventsource": "^3.0.5"
43
+ }
44
+ }
package/readme.md CHANGED
@@ -10,6 +10,8 @@ Grab an API key at [ButlerBot](https://butlerbot.net/) and install the package:
10
10
  npm i @butlerbot/sdk
11
11
  ```
12
12
 
13
+ > NOTE: API key is currently not available on the ButlerBot UI
14
+
13
15
  ## Prerequisites
14
16
 
15
17
  - ButlerBot API key