Skip to content

Commit 67643a1

Browse files
authored
[Components] chat_data #14041 (#15260)
* chat-data components * pnpm-lock.yaml
1 parent 3a1bbdf commit 67643a1

File tree

7 files changed

+234
-8
lines changed

7 files changed

+234
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import app from "../../chat_data.app.mjs";
2+
3+
export default {
4+
key: "chat_data-create-chatbot",
5+
name: "Create Chatbot",
6+
description: "Create a chatbot with the specified properties. [See the documentation](https://www.chat-data.com/api-reference#tag/Chatbot-Operations/operation/chatbotCreate)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
chatbotName: {
12+
propDefinition: [
13+
app,
14+
"chatbotName",
15+
],
16+
},
17+
sourceText: {
18+
propDefinition: [
19+
app,
20+
"sourceText",
21+
],
22+
},
23+
urlsToScrape: {
24+
propDefinition: [
25+
app,
26+
"urlsToScrape",
27+
],
28+
},
29+
customBackend: {
30+
propDefinition: [
31+
app,
32+
"customBackend",
33+
],
34+
},
35+
model: {
36+
propDefinition: [
37+
app,
38+
"model",
39+
],
40+
},
41+
},
42+
43+
async run({ $ }) {
44+
const response = await this.app.createChatbot({
45+
$,
46+
data: {
47+
chatbotName: this.chatbotName,
48+
sourceText: this.sourceText,
49+
urlsToScrape: this.urlsToScrape,
50+
customBackend: this.customBackend,
51+
model: this.model,
52+
},
53+
});
54+
$.export("$summary", `Successfully created Chatbot with ID '${response.chatbotId}'`);
55+
return response;
56+
},
57+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import app from "../../chat_data.app.mjs";
2+
3+
export default {
4+
key: "chat_data-delete-chatbot",
5+
name: "Delete Chatbot",
6+
description: "Delete a chatbot with the specified ID. [See the documentation](https://www.chat-data.com/api-reference#tag/Chatbot-Operations/operation/chatbotDelete)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
chatbotId: {
12+
propDefinition: [
13+
app,
14+
"chatbotId",
15+
],
16+
},
17+
},
18+
19+
async run({ $ }) {
20+
const response = await this.app.deleteChatbot({
21+
$,
22+
chatbotId: this.chatbotId,
23+
});
24+
25+
$.export("$summary", `Successfully deleted Chatbot with ID '${this.chatbotId}'`);
26+
27+
return response;
28+
},
29+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import app from "../../chat_data.app.mjs";
2+
3+
export default {
4+
key: "chat_data-get-chatbot-details",
5+
6+
name: "Get Chatbot Status",
7+
description: "Get status of the Chatbot with the specified ID. [See the documentation](https://www.chat-data.com/api-reference#tag/Chatbot-Operations/operation/GetChatbotStatus)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
chatbotId: {
13+
propDefinition: [
14+
app,
15+
"chatbotId",
16+
],
17+
},
18+
},
19+
20+
async run({ $ }) {
21+
const response = await this.app.getChatbotStatus({
22+
$,
23+
chatbotId: this.chatbotId,
24+
});
25+
26+
$.export("$summary", `Successfully retrieved status of the Chatbot with ID '${this.chatbotId}'`);
27+
28+
return response;
29+
},
30+
};
+100-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,106 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
14
export default {
25
type: "app",
36
app: "chat_data",
4-
propDefinitions: {},
7+
propDefinitions: {
8+
chatbotId: {
9+
type: "string",
10+
label: "Employee ID",
11+
description: "The employee ID",
12+
async options() {
13+
const response = await this.getChatbots();
14+
15+
const chatbotIds = response.chatbots;
16+
17+
return chatbotIds.map(({
18+
chatbotId, chatbotName,
19+
}) => ({
20+
value: chatbotId,
21+
label: chatbotName,
22+
}));
23+
},
24+
},
25+
chatbotName: {
26+
type: "string",
27+
label: "Chatbot Name",
28+
description: "Name of the Chatbot",
29+
},
30+
sourceText: {
31+
type: "string",
32+
label: "Source Text",
33+
description: "Text data for the chatbot, subject to character limits based on your plan. Relevant only if the model is custom-data-upload",
34+
optional: true,
35+
},
36+
urlsToScrape: {
37+
type: "string[]",
38+
label: "URLs to Scrape",
39+
description: "A list of URLs is for text content extraction by Chat Data, i.e.: `https://www.chat-data.com`. Relevant only if the model is custom-data-upload",
40+
optional: true,
41+
},
42+
customBackend: {
43+
type: "string",
44+
label: "Custom Backend",
45+
description: "The URL of a customized backend for the chatbot",
46+
optional: true,
47+
},
48+
model: {
49+
type: "string",
50+
label: "Model",
51+
description: "The chatbot defaults to `custom-data-upload` if the model parameter is not provided",
52+
options: constants.CHATBOT_MODELS,
53+
},
54+
},
555
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
56+
_baseUrl() {
57+
return "https://api.chat-data.com/api/v2";
58+
},
59+
async _makeRequest(opts = {}) {
60+
const {
61+
$ = this,
62+
path,
63+
headers,
64+
...otherOpts
65+
} = opts;
66+
return axios($, {
67+
...otherOpts,
68+
url: this._baseUrl() + path,
69+
headers: {
70+
...headers,
71+
Authorization: `Bearer ${this.$auth.api_key}`,
72+
},
73+
});
74+
},
75+
async createChatbot(args = {}) {
76+
return this._makeRequest({
77+
path: "/create-chatbot",
78+
method: "post",
79+
...args,
80+
});
81+
},
82+
async getChatbotStatus({
83+
chatbotId, ...args
84+
}) {
85+
return this._makeRequest({
86+
path: `/chatbot/status/${chatbotId}/`,
87+
...args,
88+
});
89+
},
90+
async deleteChatbot({
91+
chatbotId, ...args
92+
}) {
93+
return this._makeRequest({
94+
path: `/delete-chatbot/${chatbotId}/`,
95+
method: "delete",
96+
...args,
97+
});
98+
},
99+
async getChatbots(args = {}) {
100+
return this._makeRequest({
101+
path: "/get-chatbots",
102+
...args,
103+
});
9104
},
10105
},
11-
};
106+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
CHATBOT_MODELS: [
3+
"custom-data-upload",
4+
"medical-chat-human",
5+
"medical-chat-vet",
6+
"custom-model",
7+
],
8+
};

components/chat_data/package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/chat_data",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Chat Data Components",
55
"main": "chat_data.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}

pnpm-lock.yaml

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)