Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions components/chat_data/actions/create-chatbot/create-chatbot.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import app from "../../chat_data.app.mjs";

export default {
key: "chat_data-create-chatbot",
name: "Create Chatbot",
description: "Create a chatbot with the specified properties. [See the documentation](https://www.chat-data.com/api-reference#tag/Chatbot-Operations/operation/chatbotCreate)",
version: "0.0.1",
type: "action",
props: {
app,
chatbotName: {
propDefinition: [
app,
"chatbotName",
],
},
sourceText: {
propDefinition: [
app,
"sourceText",
],
},
urlsToScrape: {
propDefinition: [
app,
"urlsToScrape",
],
},
customBackend: {
propDefinition: [
app,
"customBackend",
],
},
model: {
propDefinition: [
app,
"model",
],
},
},

async run({ $ }) {
const response = await this.app.createChatbot({
$,
data: {
chatbotName: this.chatbotName,
sourceText: this.sourceText,
urlsToScrape: this.urlsToScrape,
customBackend: this.customBackend,
model: this.model,
},
});
$.export("$summary", `Successfully created Chatbot with ID '${response.chatbotId}'`);
return response;
},
};
29 changes: 29 additions & 0 deletions components/chat_data/actions/delete-chatbot/delete-chatbot.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import app from "../../chat_data.app.mjs";

export default {
key: "chat_data-delete-chatbot",
name: "Delete Chatbot",
description: "Delete a chatbot with the specified ID. [See the documentation](https://www.chat-data.com/api-reference#tag/Chatbot-Operations/operation/chatbotDelete)",
version: "0.0.1",
type: "action",
props: {
app,
chatbotId: {
propDefinition: [
app,
"chatbotId",
],
},
},

async run({ $ }) {
const response = await this.app.deleteChatbot({
$,
chatbotId: this.chatbotId,
});

$.export("$summary", `Successfully deleted Chatbot with ID '${this.chatbotId}'`);

return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import app from "../../chat_data.app.mjs";

export default {
key: "chat_data-get-chatbot-details",

name: "Get Chatbot Status",
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)",
version: "0.0.1",
type: "action",
props: {
app,
chatbotId: {
propDefinition: [
app,
"chatbotId",
],
},
Comment on lines +12 to +17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Property definition found but has incorrect labels

The chatbotId property is defined in the app file but has incorrect labels:

  • The label is set to "Employee ID" instead of something related to chatbots
  • The description is "The employee ID" which is inconsistent with the property's purpose

These should be updated to reflect that this is a chatbot identifier, especially since:

  1. The property name is chatbotId
  2. The options method fetches chatbots and returns chatbotId/chatbotName pairs
  3. The API endpoints use it as a chatbot identifier
🔗 Analysis chain

Verify chatbotId prop definition in app file

Ensure that the chatbotId property is properly defined in the chat_data app module.


The previous ast-grep pattern might have failed due to syntax. Let's try a different approach by:

  1. First locating potential app definition files
  2. Then searching for chatbotId property definition using ripgrep with context

Let's try to:

  1. First locate the chat_data app file specifically
  2. Then search for chatbotId property definition in that file

Let's examine the full app file content to locate the chatbotId property definition, as it might be defined in a different format or structure than initially assumed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify chatbotId property definition in app file
ast-grep --pattern 'chatbotId: {
  $$$
}'

Length of output: 43


Script:

#!/bin/bash
# Search for files that might contain the app definition
fd "app.(m?js|ts)" --type f

# Then search for chatbotId property definition in those files
rg "chatbotId.*type|chatbotId.*description" -A 5

Length of output: 100127


Script:

#!/bin/bash
# Search for chat_data app file
fd "chat_data.app.(m?js|ts)" --type f

# Then search for chatbotId property definition in that file
rg "chatbotId.*type|chatbotId.*description" -A 5 components/chat_data/chat_data.app.mjs

Length of output: 168


Script:

#!/bin/bash
# Let's try to get the entire content of the app file to find the chatbotId definition
cat components/chat_data/chat_data.app.mjs

# Also search for any prop definitions in the app file
rg "propDefinitions" -A 10 components/chat_data/chat_data.app.mjs

Length of output: 3089

},

async run({ $ }) {
const response = await this.app.getChatbotStatus({
$,
chatbotId: this.chatbotId,
});

$.export("$summary", `Successfully retrieved status of the Chatbot with ID '${this.chatbotId}'`);

return response;
},
};
105 changes: 100 additions & 5 deletions components/chat_data/chat_data.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,106 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "chat_data",
propDefinitions: {},
propDefinitions: {
chatbotId: {
type: "string",
label: "Employee ID",
description: "The employee ID",
async options() {
const response = await this.getChatbots();

const chatbotIds = response.chatbots;

return chatbotIds.map(({
chatbotId, chatbotName,
}) => ({
value: chatbotId,
label: chatbotName,
}));
},
},
chatbotName: {
type: "string",
label: "Chatbot Name",
description: "Name of the Chatbot",
},
sourceText: {
type: "string",
label: "Source Text",
description: "Text data for the chatbot, subject to character limits based on your plan. Relevant only if the model is custom-data-upload",
optional: true,
},
urlsToScrape: {
type: "string[]",
label: "URLs to Scrape",
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",
optional: true,
},
customBackend: {
type: "string",
label: "Custom Backend",
description: "The URL of a customized backend for the chatbot",
optional: true,
},
model: {
type: "string",
label: "Model",
description: "The chatbot defaults to `custom-data-upload` if the model parameter is not provided",
options: constants.CHATBOT_MODELS,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.chat-data.com/api/v2";
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
...headers,
Authorization: `Bearer ${this.$auth.api_key}`,
},
});
},
async createChatbot(args = {}) {
return this._makeRequest({
path: "/create-chatbot",
method: "post",
...args,
});
},
async getChatbotStatus({
chatbotId, ...args
}) {
return this._makeRequest({
path: `/chatbot/status/${chatbotId}/`,
...args,
});
},
async deleteChatbot({
chatbotId, ...args
}) {
return this._makeRequest({
path: `/delete-chatbot/${chatbotId}/`,
method: "delete",
...args,
});
},
async getChatbots(args = {}) {
return this._makeRequest({
path: "/get-chatbots",
...args,
});
},
},
};
};
8 changes: 8 additions & 0 deletions components/chat_data/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
CHATBOT_MODELS: [
"custom-data-upload",
"medical-chat-human",
"medical-chat-vet",
"custom-model",
],
};
7 changes: 5 additions & 2 deletions components/chat_data/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/chat_data",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Chat Data Components",
"main": "chat_data.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
}
Loading
Loading