From 1eab971693808c18d8cdd762135e077c1c53d424 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Fri, 20 Sep 2024 16:07:51 -0300 Subject: [PATCH 1/7] dust init --- .../actions/talk-assistant/talk-assistant.mjs | 38 +++++++++ .../upload-document/upload-document.mjs | 34 ++++++++ components/dust/dust.app.mjs | 82 +++++++++++++++++-- components/dust/package.json | 2 +- 4 files changed, 150 insertions(+), 6 deletions(-) create mode 100644 components/dust/actions/talk-assistant/talk-assistant.mjs create mode 100644 components/dust/actions/upload-document/upload-document.mjs diff --git a/components/dust/actions/talk-assistant/talk-assistant.mjs b/components/dust/actions/talk-assistant/talk-assistant.mjs new file mode 100644 index 0000000000000..9162bcc42d4c0 --- /dev/null +++ b/components/dust/actions/talk-assistant/talk-assistant.mjs @@ -0,0 +1,38 @@ +import dust from "../../dust.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "dust-talk-assistant", + name: "Talk to Assistant", + description: "Send a message to an assistant on Dust and receive an answer. [See the documentation](https://docs.dust.tt/reference/post_api-v1-w-wid-assistant-conversations-cid-messages)", + version: "0.0.{{ts}}", + type: "action", + props: { + dust, + content: { + propDefinition: [ + dust, + "content", + ], + }, + assistantId: { + type: "string", + label: "Assistant ID", + description: "The unique identifier of the assistant.", + }, + conversationId: { + type: "string", + label: "Conversation ID", + description: "The unique identifier of the conversation.", + }, + }, + async run({ $ }) { + const response = await this.dust.sendMessageToAssistant({ + content: this.content, + assistantId: this.assistantId, + conversationId: this.conversationId, + }); + $.export("$summary", "Successfully sent message to assistant"); + return response; + }, +}; diff --git a/components/dust/actions/upload-document/upload-document.mjs b/components/dust/actions/upload-document/upload-document.mjs new file mode 100644 index 0000000000000..e0719af2cc551 --- /dev/null +++ b/components/dust/actions/upload-document/upload-document.mjs @@ -0,0 +1,34 @@ +import dust from "../../dust.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "dust-upload-document", + name: "Upload Document", + description: "Adds a document to a chosen Dust data source or folder. [See the documentation](https://docs.dust.tt/reference/post_api-v1-w-wid-data-sources-name-documents-documentid)", + version: "0.0.1", + type: "action", + props: { + dust, + document: { + propDefinition: [ + dust, + "document", + ], + }, + destination: { + propDefinition: [ + dust, + "destination", + ], + }, + }, + async run({ $ }) { + const response = await this.dust.upsertDocument({ + document: this.document, + destination: this.destination, + }); + + $.export("$summary", `Successfully uploaded document to destination ${this.destination}`); + return response; + }, +}; diff --git a/components/dust/dust.app.mjs b/components/dust/dust.app.mjs index 6f745e57d01d5..91f7a75e5edae 100644 --- a/components/dust/dust.app.mjs +++ b/components/dust/dust.app.mjs @@ -1,11 +1,83 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "dust", - propDefinitions: {}, + propDefinitions: { + content: { + type: "string", + label: "Message Content", + description: "The content of the message to be sent to the assistant", + }, + document: { + type: "string", + label: "Document", + description: "The content of the document to be uploaded", + }, + destination: { + type: "string", + label: "Destination", + description: "The destination data source or folder where the document will be uploaded", + async options() { + const dataSources = await this.listDataSources(); + return dataSources.map((dataSource) => ({ + label: dataSource.name, + value: dataSource.id, + })); + }, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://dust.tt/api/v1"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + method = "GET", + path = "/", + headers, + ...otherOpts + } = opts; + + return axios($, { + ...otherOpts, + method, + url: this._baseUrl() + path, + headers: { + ...headers, + Authorization: `Bearer ${this.$auth.oauth_access_token}`, + }, + }); + }, + async listDataSources(opts = {}) { + return this._makeRequest({ + path: `/w/${this.$auth.workspace_id}/data_sources`, + ...opts, + }); + }, + async sendMessageToAssistant({ + content, assistantId, conversationId, + }) { + return this._makeRequest({ + method: "POST", + path: `/w/${this.$auth.workspace_id}/assistant/conversations/${conversationId}/messages`, + data: { + content, + assistantId, + }, + }); + }, + async upsertDocument({ + document, destination, + }) { + return this._makeRequest({ + method: "POST", + path: `/w/${this.$auth.workspace_id}/data_sources/${destination}/documents/${document.documentId}`, + data: { + text: document, + }, + }); }, }, -}; \ No newline at end of file +}; diff --git a/components/dust/package.json b/components/dust/package.json index 4a3b133b40c34..f2eb92debb239 100644 --- a/components/dust/package.json +++ b/components/dust/package.json @@ -12,4 +12,4 @@ "publishConfig": { "access": "public" } -} \ No newline at end of file +} From 89b56ebaeec5f236640d218b6921984ce7fe5870 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Mon, 23 Sep 2024 16:11:09 -0300 Subject: [PATCH 2/7] [Components] dust #14021 Actions - Talk to Assistant - Upsert Document --- .../actions/talk-assistant/talk-assistant.mjs | 64 +- .../upload-document/upload-document.mjs | 34 - .../upsert-document/upsert-document.mjs | 49 ++ components/dust/common/constants.mjs | 599 ++++++++++++++++++ components/dust/dust.app.mjs | 101 +-- components/dust/package.json | 5 +- 6 files changed, 757 insertions(+), 95 deletions(-) delete mode 100644 components/dust/actions/upload-document/upload-document.mjs create mode 100644 components/dust/actions/upsert-document/upsert-document.mjs create mode 100644 components/dust/common/constants.mjs diff --git a/components/dust/actions/talk-assistant/talk-assistant.mjs b/components/dust/actions/talk-assistant/talk-assistant.mjs index 9162bcc42d4c0..248b227ab90ad 100644 --- a/components/dust/actions/talk-assistant/talk-assistant.mjs +++ b/components/dust/actions/talk-assistant/talk-assistant.mjs @@ -1,38 +1,76 @@ +import { TIMEZONE_OPTIONS } from "../../common/constants.mjs"; import dust from "../../dust.app.mjs"; -import { axios } from "@pipedream/platform"; export default { key: "dust-talk-assistant", name: "Talk to Assistant", description: "Send a message to an assistant on Dust and receive an answer. [See the documentation](https://docs.dust.tt/reference/post_api-v1-w-wid-assistant-conversations-cid-messages)", - version: "0.0.{{ts}}", + version: "0.0.1", type: "action", props: { dust, + assistantId: { + propDefinition: [ + dust, + "assistantId", + ], + }, content: { propDefinition: [ dust, "content", ], }, - assistantId: { + timezone: { + type: "string", + label: "Timezone", + description: "Set the timezone in which you want to operate.", + options: TIMEZONE_OPTIONS, + }, + username: { type: "string", - label: "Assistant ID", - description: "The unique identifier of the assistant.", + label: "Username", + description: "The name to be displayed in the conversation.", }, - conversationId: { + email: { type: "string", - label: "Conversation ID", - description: "The unique identifier of the conversation.", + label: "Email", + description: "Put an email if needed.", + optional: true, }, }, async run({ $ }) { - const response = await this.dust.sendMessageToAssistant({ - content: this.content, - assistantId: this.assistantId, - conversationId: this.conversationId, + const { + conversation, message, + } = await this.dust.sendMessageToAssistant({ + $, + data: { + message: { + content: this.content, + context: { + timezone: this.timezone, + username: this.username, + fullName: null, + email: this.email, + profilePictureUrl: null, + }, + mentions: [ + { + configurationId: this.assistantId, + }, + ], + }, + blocking: true, + visibility: "unlisted", + title: null, + }, }); + $.export("$summary", "Successfully sent message to assistant"); - return response; + return { + agentMessage: conversation.content[1][0].content, + conversationUrl: `https://dust.tt/w/${conversation.owner.sId}/assistant/${conversation.sId}`, + message, + }; }, }; diff --git a/components/dust/actions/upload-document/upload-document.mjs b/components/dust/actions/upload-document/upload-document.mjs deleted file mode 100644 index e0719af2cc551..0000000000000 --- a/components/dust/actions/upload-document/upload-document.mjs +++ /dev/null @@ -1,34 +0,0 @@ -import dust from "../../dust.app.mjs"; -import { axios } from "@pipedream/platform"; - -export default { - key: "dust-upload-document", - name: "Upload Document", - description: "Adds a document to a chosen Dust data source or folder. [See the documentation](https://docs.dust.tt/reference/post_api-v1-w-wid-data-sources-name-documents-documentid)", - version: "0.0.1", - type: "action", - props: { - dust, - document: { - propDefinition: [ - dust, - "document", - ], - }, - destination: { - propDefinition: [ - dust, - "destination", - ], - }, - }, - async run({ $ }) { - const response = await this.dust.upsertDocument({ - document: this.document, - destination: this.destination, - }); - - $.export("$summary", `Successfully uploaded document to destination ${this.destination}`); - return response; - }, -}; diff --git a/components/dust/actions/upsert-document/upsert-document.mjs b/components/dust/actions/upsert-document/upsert-document.mjs new file mode 100644 index 0000000000000..4beada52f972e --- /dev/null +++ b/components/dust/actions/upsert-document/upsert-document.mjs @@ -0,0 +1,49 @@ +import dust from "../../dust.app.mjs"; + +export default { + key: "dust-upsert-document", + name: "Upsert Document", + description: "Upsert a document to a chosen Dust data source. [See the documentation](https://docs.dust.tt/reference/post_api-v1-w-wid-data-sources-name-documents-documentid)", + version: "0.0.1", + type: "action", + props: { + dust, + dataSourceId: { + propDefinition: [ + dust, + "dataSourceId", + ], + }, + documentId: { + type: "string", + label: "Document Id", + description: "An Id for the new document", + }, + content: { + type: "string", + label: "Content", + description: "The text content of the document to upsert.", + optional: true, + }, + lightDocumentOutput: { + type: "boolean", + label: "Light Document Output", + description: "If true, a lightweight version of the document will be returned in the response (excluding the text, chunks and vectors). Defaults to false.", + optional: true, + }, + }, + async run({ $ }) { + const response = await this.dust.upsertDocument({ + $, + dataSourceId: this.dataSourceId, + documentId: this.documentId, + data: { + text: this.content, + light_document_output: this.lightDocumentOutput, + }, + }); + + $.export("$summary", `Successfully uploaded document to destination ${this.destination}`); + return response; + }, +}; diff --git a/components/dust/common/constants.mjs b/components/dust/common/constants.mjs new file mode 100644 index 0000000000000..7e1205e5046a7 --- /dev/null +++ b/components/dust/common/constants.mjs @@ -0,0 +1,599 @@ +export const TIMEZONE_OPTIONS = [ + "Africa/Abidjan", + "Africa/Accra", + "Africa/Addis_Ababa", + "Africa/Algiers", + "Africa/Asmara", + "Africa/Asmera", + "Africa/Bamako", + "Africa/Bangui", + "Africa/Banjul", + "Africa/Bissau", + "Africa/Blantyre", + "Africa/Brazzaville", + "Africa/Bujumbura", + "Africa/Cairo", + "Africa/Casablanca", + "Africa/Ceuta", + "Africa/Conakry", + "Africa/Dakar", + "Africa/Dar_es_Salaam", + "Africa/Djibouti", + "Africa/Douala", + "Africa/El_Aaiun", + "Africa/Freetown", + "Africa/Gaborone", + "Africa/Harare", + "Africa/Johannesburg", + "Africa/Juba", + "Africa/Kampala", + "Africa/Khartoum", + "Africa/Kigali", + "Africa/Kinshasa", + "Africa/Lagos", + "Africa/Libreville", + "Africa/Lome", + "Africa/Luanda", + "Africa/Lubumbashi", + "Africa/Lusaka", + "Africa/Malabo", + "Africa/Maputo", + "Africa/Maseru", + "Africa/Mbabane", + "Africa/Mogadishu", + "Africa/Monrovia", + "Africa/Nairobi", + "Africa/Ndjamena", + "Africa/Niamey", + "Africa/Nouakchott", + "Africa/Ouagadougou", + "Africa/Porto-Novo", + "Africa/Sao_Tome", + "Africa/Timbuktu", + "Africa/Tripoli", + "Africa/Tunis", + "Africa/Windhoek", + "America/Adak", + "America/Anchorage", + "America/Anguilla", + "America/Antigua", + "America/Araguaina", + "America/Argentina/Buenos_Aires", + "America/Argentina/Catamarca", + "America/Argentina/ComodRivadavia", + "America/Argentina/Cordoba", + "America/Argentina/Jujuy", + "America/Argentina/La_Rioja", + "America/Argentina/Mendoza", + "America/Argentina/Rio_Gallegos", + "America/Argentina/Salta", + "America/Argentina/San_Juan", + "America/Argentina/San_Luis", + "America/Argentina/Tucuman", + "America/Argentina/Ushuaia", + "America/Aruba", + "America/Asuncion", + "America/Atikokan", + "America/Atka", + "America/Bahia", + "America/Bahia_Banderas", + "America/Barbados", + "America/Belem", + "America/Belize", + "America/Blanc-Sablon", + "America/Boa_Vista", + "America/Bogota", + "America/Boise", + "America/Buenos_Aires", + "America/Cambridge_Bay", + "America/Campo_Grande", + "America/Cancun", + "America/Caracas", + "America/Catamarca", + "America/Cayenne", + "America/Cayman", + "America/Chicago", + "America/Chihuahua", + "America/Ciudad_Juarez", + "America/Coral_Harbour", + "America/Cordoba", + "America/Costa_Rica", + "America/Creston", + "America/Cuiaba", + "America/Curacao", + "America/Danmarkshavn", + "America/Dawson", + "America/Dawson_Creek", + "America/Denver", + "America/Detroit", + "America/Dominica", + "America/Edmonton", + "America/Eirunepe", + "America/El_Salvador", + "America/Ensenada", + "America/Fort_Nelson", + "America/Fort_Wayne", + "America/Fortaleza", + "America/Glace_Bay", + "America/Godthab", + "America/Goose_Bay", + "America/Grand_Turk", + "America/Grenada", + "America/Guadeloupe", + "America/Guatemala", + "America/Guayaquil", + "America/Guyana", + "America/Halifax", + "America/Havana", + "America/Hermosillo", + "America/Indiana/Indianapolis", + "America/Indiana/Knox", + "America/Indiana/Marengo", + "America/Indiana/Petersburg", + "America/Indiana/Tell_City", + "America/Indiana/Vevay", + "America/Indiana/Vincennes", + "America/Indiana/Winamac", + "America/Indianapolis", + "America/Inuvik", + "America/Iqaluit", + "America/Jamaica", + "America/Jujuy", + "America/Juneau", + "America/Kentucky/Louisville", + "America/Kentucky/Monticello", + "America/Knox_IN", + "America/Kralendijk", + "America/La_Paz", + "America/Lima", + "America/Los_Angeles", + "America/Louisville", + "America/Lower_Princes", + "America/Maceio", + "America/Managua", + "America/Manaus", + "America/Marigot", + "America/Martinique", + "America/Matamoros", + "America/Mazatlan", + "America/Mendoza", + "America/Menominee", + "America/Merida", + "America/Metlakatla", + "America/Mexico_City", + "America/Miquelon", + "America/Moncton", + "America/Monterrey", + "America/Montevideo", + "America/Montreal", + "America/Montserrat", + "America/Nassau", + "America/New_York", + "America/Nipigon", + "America/Nome", + "America/Noronha", + "America/North_Dakota/Beulah", + "America/North_Dakota/Center", + "America/North_Dakota/New_Salem", + "America/Nuuk", + "America/Ojinaga", + "America/Panama", + "America/Pangnirtung", + "America/Paramaribo", + "America/Phoenix", + "America/Port-au-Prince", + "America/Port_of_Spain", + "America/Porto_Acre", + "America/Porto_Velho", + "America/Puerto_Rico", + "America/Punta_Arenas", + "America/Rainy_River", + "America/Rankin_Inlet", + "America/Recife", + "America/Regina", + "America/Resolute", + "America/Rio_Branco", + "America/Rosario", + "America/Santa_Isabel", + "America/Santarem", + "America/Santiago", + "America/Santo_Domingo", + "America/Sao_Paulo", + "America/Scoresbysund", + "America/Shiprock", + "America/Sitka", + "America/St_Barthelemy", + "America/St_Johns", + "America/St_Kitts", + "America/St_Lucia", + "America/St_Thomas", + "America/St_Vincent", + "America/Swift_Current", + "America/Tegucigalpa", + "America/Thule", + "America/Thunder_Bay", + "America/Tijuana", + "America/Toronto", + "America/Tortola", + "America/Vancouver", + "America/Virgin", + "America/Whitehorse", + "America/Winnipeg", + "America/Yakutat", + "America/Yellowknife", + "Antarctica/Casey", + "Antarctica/Davis", + "Antarctica/DumontDUrville", + "Antarctica/Macquarie", + "Antarctica/Mawson", + "Antarctica/McMurdo", + "Antarctica/Palmer", + "Antarctica/Rothera", + "Antarctica/South_Pole", + "Antarctica/Syowa", + "Antarctica/Troll", + "Antarctica/Vostok", + "Arctic/Longyearbyen", + "Asia/Aden", + "Asia/Almaty", + "Asia/Amman", + "Asia/Anadyr", + "Asia/Aqtau", + "Asia/Aqtobe", + "Asia/Ashgabat", + "Asia/Ashkhabad", + "Asia/Atyrau", + "Asia/Baghdad", + "Asia/Bahrain", + "Asia/Baku", + "Asia/Bangkok", + "Asia/Barnaul", + "Asia/Beirut", + "Asia/Bishkek", + "Asia/Brunei", + "Asia/Calcutta", + "Asia/Chita", + "Asia/Choibalsan", + "Asia/Chongqing", + "Asia/Chungking", + "Asia/Colombo", + "Asia/Dacca", + "Asia/Damascus", + "Asia/Dhaka", + "Asia/Dili", + "Asia/Dubai", + "Asia/Dushanbe", + "Asia/Famagusta", + "Asia/Gaza", + "Asia/Harbin", + "Asia/Hebron", + "Asia/Ho_Chi_Minh", + "Asia/Hong_Kong", + "Asia/Hovd", + "Asia/Irkutsk", + "Asia/Istanbul", + "Asia/Jakarta", + "Asia/Jayapura", + "Asia/Jerusalem", + "Asia/Kabul", + "Asia/Kamchatka", + "Asia/Karachi", + "Asia/Kashgar", + "Asia/Kathmandu", + "Asia/Katmandu", + "Asia/Khandyga", + "Asia/Kolkata", + "Asia/Krasnoyarsk", + "Asia/Kuala_Lumpur", + "Asia/Kuching", + "Asia/Kuwait", + "Asia/Macao", + "Asia/Macau", + "Asia/Magadan", + "Asia/Makassar", + "Asia/Manila", + "Asia/Muscat", + "Asia/Nicosia", + "Asia/Novokuznetsk", + "Asia/Novosibirsk", + "Asia/Omsk", + "Asia/Oral", + "Asia/Phnom_Penh", + "Asia/Pontianak", + "Asia/Pyongyang", + "Asia/Qatar", + "Asia/Qostanay", + "Asia/Qyzylorda", + "Asia/Rangoon", + "Asia/Riyadh", + "Asia/Saigon", + "Asia/Sakhalin", + "Asia/Samarkand", + "Asia/Seoul", + "Asia/Shanghai", + "Asia/Singapore", + "Asia/Srednekolymsk", + "Asia/Taipei", + "Asia/Tashkent", + "Asia/Tbilisi", + "Asia/Tehran", + "Asia/Tel_Aviv", + "Asia/Thimbu", + "Asia/Thimphu", + "Asia/Tokyo", + "Asia/Tomsk", + "Asia/Ujung_Pandang", + "Asia/Ulaanbaatar", + "Asia/Ulan_Bator", + "Asia/Urumqi", + "Asia/Ust-Nera", + "Asia/Vientiane", + "Asia/Vladivostok", + "Asia/Yakutsk", + "Asia/Yangon", + "Asia/Yekaterinburg", + "Asia/Yerevan", + "Atlantic/Azores", + "Atlantic/Bermuda", + "Atlantic/Canary", + "Atlantic/Cape_Verde", + "Atlantic/Faeroe", + "Atlantic/Faroe", + "Atlantic/Jan_Mayen", + "Atlantic/Madeira", + "Atlantic/Reykjavik", + "Atlantic/South_Georgia", + "Atlantic/St_Helena", + "Atlantic/Stanley", + "Australia/ACT", + "Australia/Adelaide", + "Australia/Brisbane", + "Australia/Broken_Hill", + "Australia/Canberra", + "Australia/Currie", + "Australia/Darwin", + "Australia/Eucla", + "Australia/Hobart", + "Australia/LHI", + "Australia/Lindeman", + "Australia/Lord_Howe", + "Australia/Melbourne", + "Australia/North", + "Australia/NSW", + "Australia/Perth", + "Australia/Queensland", + "Australia/South", + "Australia/Sydney", + "Australia/Tasmania", + "Australia/Victoria", + "Australia/West", + "Australia/Yancowinna", + "Brazil/Acre", + "Brazil/DeNoronha", + "Brazil/East", + "Brazil/West", + "Canada/Atlantic", + "Canada/Central", + "Canada/Eastern", + "Canada/Mountain", + "Canada/Newfoundland", + "Canada/Pacific", + "Canada/Saskatchewan", + "Canada/Yukon", + "CET", + "Chile/Continental", + "Chile/EasterIsland", + "CST6CDT", + "Cuba", + "EET", + "Egypt", + "Eire", + "EST", + "EST5EDT", + "Etc/GMT", + "Etc/GMT+0", + "Etc/GMT+1", + "Etc/GMT+10", + "Etc/GMT+11", + "Etc/GMT+12", + "Etc/GMT+2", + "Etc/GMT+3", + "Etc/GMT+4", + "Etc/GMT+5", + "Etc/GMT+6", + "Etc/GMT+7", + "Etc/GMT+8", + "Etc/GMT+9", + "Etc/GMT-0", + "Etc/GMT-1", + "Etc/GMT-10", + "Etc/GMT-11", + "Etc/GMT-12", + "Etc/GMT-13", + "Etc/GMT-14", + "Etc/GMT-2", + "Etc/GMT-3", + "Etc/GMT-4", + "Etc/GMT-5", + "Etc/GMT-6", + "Etc/GMT-7", + "Etc/GMT-8", + "Etc/GMT-9", + "Etc/GMT0", + "Etc/Greenwich", + "Etc/UCT", + "Etc/Universal", + "Etc/UTC", + "Etc/Zulu", + "Europe/Amsterdam", + "Europe/Andorra", + "Europe/Astrakhan", + "Europe/Athens", + "Europe/Belfast", + "Europe/Belgrade", + "Europe/Berlin", + "Europe/Bratislava", + "Europe/Brussels", + "Europe/Bucharest", + "Europe/Budapest", + "Europe/Busingen", + "Europe/Chisinau", + "Europe/Copenhagen", + "Europe/Dublin", + "Europe/Gibraltar", + "Europe/Guernsey", + "Europe/Helsinki", + "Europe/Isle_of_Man", + "Europe/Istanbul", + "Europe/Jersey", + "Europe/Kaliningrad", + "Europe/Kiev", + "Europe/Kirov", + "Europe/Kyiv", + "Europe/Lisbon", + "Europe/Ljubljana", + "Europe/London", + "Europe/Luxembourg", + "Europe/Madrid", + "Europe/Malta", + "Europe/Mariehamn", + "Europe/Minsk", + "Europe/Monaco", + "Europe/Moscow", + "Europe/Nicosia", + "Europe/Oslo", + "Europe/Paris", + "Europe/Podgorica", + "Europe/Prague", + "Europe/Riga", + "Europe/Rome", + "Europe/Samara", + "Europe/San_Marino", + "Europe/Sarajevo", + "Europe/Saratov", + "Europe/Simferopol", + "Europe/Skopje", + "Europe/Sofia", + "Europe/Stockholm", + "Europe/Tallinn", + "Europe/Tirane", + "Europe/Tiraspol", + "Europe/Ulyanovsk", + "Europe/Uzhgorod", + "Europe/Vaduz", + "Europe/Vatican", + "Europe/Vienna", + "Europe/Vilnius", + "Europe/Volgograd", + "Europe/Warsaw", + "Europe/Zagreb", + "Europe/Zaporozhye", + "Europe/Zurich", + "Factory", + "GB", + "GB-Eire", + "GMT", + "GMT+0", + "GMT-0", + "GMT0", + "Greenwich", + "Hongkong", + "HST", + "Iceland", + "Indian/Antananarivo", + "Indian/Chagos", + "Indian/Christmas", + "Indian/Cocos", + "Indian/Comoro", + "Indian/Kerguelen", + "Indian/Mahe", + "Indian/Maldives", + "Indian/Mauritius", + "Indian/Mayotte", + "Indian/Reunion", + "Iran", + "Israel", + "Jamaica", + "Japan", + "Kwajalein", + "Libya", + "MET", + "Mexico/BajaNorte", + "Mexico/BajaSur", + "Mexico/General", + "MST", + "MST7MDT", + "Navajo", + "NZ", + "NZ-CHAT", + "Pacific/Apia", + "Pacific/Auckland", + "Pacific/Bougainville", + "Pacific/Chatham", + "Pacific/Chuuk", + "Pacific/Easter", + "Pacific/Efate", + "Pacific/Enderbury", + "Pacific/Fakaofo", + "Pacific/Fiji", + "Pacific/Funafuti", + "Pacific/Galapagos", + "Pacific/Gambier", + "Pacific/Guadalcanal", + "Pacific/Guam", + "Pacific/Honolulu", + "Pacific/Johnston", + "Pacific/Kanton", + "Pacific/Kiritimati", + "Pacific/Kosrae", + "Pacific/Kwajalein", + "Pacific/Majuro", + "Pacific/Marquesas", + "Pacific/Midway", + "Pacific/Nauru", + "Pacific/Niue", + "Pacific/Norfolk", + "Pacific/Noumea", + "Pacific/Pago_Pago", + "Pacific/Palau", + "Pacific/Pitcairn", + "Pacific/Pohnpei", + "Pacific/Ponape", + "Pacific/Port_Moresby", + "Pacific/Rarotonga", + "Pacific/Saipan", + "Pacific/Samoa", + "Pacific/Tahiti", + "Pacific/Tarawa", + "Pacific/Tongatapu", + "Pacific/Truk", + "Pacific/Wake", + "Pacific/Wallis", + "Pacific/Yap", + "Poland", + "Portugal", + "PRC", + "PST8PDT", + "ROC", + "ROK", + "Singapore", + "Turkey", + "UCT", + "Universal", + "US/Alaska", + "US/Aleutian", + "US/Arizona", + "US/Central", + "US/East-Indiana", + "US/Eastern", + "US/Hawaii", + "US/Indiana-Starke", + "US/Michigan", + "US/Mountain", + "US/Pacific", + "US/Samoa", + "UTC", + "W-SU", + "WET", + "Zulu", +]; diff --git a/components/dust/dust.app.mjs b/components/dust/dust.app.mjs index 91f7a75e5edae..256ec1ed5429b 100644 --- a/components/dust/dust.app.mjs +++ b/components/dust/dust.app.mjs @@ -4,79 +4,86 @@ export default { type: "app", app: "dust", propDefinitions: { - content: { + assistantId: { type: "string", - label: "Message Content", - description: "The content of the message to be sent to the assistant", - }, - document: { - type: "string", - label: "Document", - description: "The content of the document to be uploaded", + label: "Assistant ID", + description: "Select the name of your Assistant from the list. Your Dust Assistant must be a **Shared** or **Company** Assistant. Personal Assistants are not visible in this list.", + async options() { + const { agentConfigurations } = await this.listAssistants(); + + return agentConfigurations.map(({ + description, name, sId: value, + }) => ({ + label: `${name} - ${description}`, + value, + })); + }, }, - destination: { + dataSourceId: { type: "string", - label: "Destination", - description: "The destination data source or folder where the document will be uploaded", + label: "Folder ID", + description: "ID of the data source.", async options() { - const dataSources = await this.listDataSources(); - return dataSources.map((dataSource) => ({ - label: dataSource.name, - value: dataSource.id, + const { data_sources: ds } = await this.listDataSources(); + + return ds.map(({ + description, name, dustAPIDataSourceId: value, + }) => ({ + label: `${name} - ${description}`, + value, })); }, }, + document: { + type: "string", + label: "Document", + description: "The content of the document to be uploaded", + }, }, methods: { _baseUrl() { - return "https://dust.tt/api/v1"; + return `https://dust.tt/api/v1/w/${this.$auth.workspace_id}`; }, - async _makeRequest(opts = {}) { - const { - $ = this, - method = "GET", - path = "/", - headers, - ...otherOpts - } = opts; - + _headers() { + return { + Authorization: `Bearer ${this.$auth.api_key}`, + }; + }, + _makeRequest({ + $ = this, path, ...opts + }) { return axios($, { - ...otherOpts, - method, url: this._baseUrl() + path, - headers: { - ...headers, - Authorization: `Bearer ${this.$auth.oauth_access_token}`, - }, + headers: this._headers(), + ...opts, }); }, - async listDataSources(opts = {}) { + listAssistants(opts = {}) { return this._makeRequest({ - path: `/w/${this.$auth.workspace_id}/data_sources`, + path: "/assistant/agent_configurations", ...opts, }); }, - async sendMessageToAssistant({ - content, assistantId, conversationId, - }) { + listDataSources(opts = {}) { + return this._makeRequest({ + path: "/data_sources", + ...opts, + }); + }, + sendMessageToAssistant(opts = {}) { return this._makeRequest({ method: "POST", - path: `/w/${this.$auth.workspace_id}/assistant/conversations/${conversationId}/messages`, - data: { - content, - assistantId, - }, + path: "/assistant/conversations", + ...opts, }); }, - async upsertDocument({ - document, destination, + upsertDocument({ + documentId, dataSourceId, ...opts }) { return this._makeRequest({ method: "POST", - path: `/w/${this.$auth.workspace_id}/data_sources/${destination}/documents/${document.documentId}`, - data: { - text: document, - }, + path: `/data_sources/${dataSourceId}/documents/${documentId}`, + ...opts, }); }, }, diff --git a/components/dust/package.json b/components/dust/package.json index f2eb92debb239..de2d79e946f0d 100644 --- a/components/dust/package.json +++ b/components/dust/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/dust", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Dust Components", "main": "dust.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.1" } } From c16f283e208c46ee393528990443e769a140a060 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Mon, 23 Sep 2024 16:12:55 -0300 Subject: [PATCH 3/7] pnpm update --- pnpm-lock.yaml | 107 +++++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 52 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ed81a587cec96..45d557beb0ed1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2833,7 +2833,10 @@ importers: '@pipedream/platform': 1.5.1 components/dust: - specifiers: {} + specifiers: + '@pipedream/platform': ^3.0.1 + dependencies: + '@pipedream/platform': 3.0.3 components/dux_soup: specifiers: @@ -12745,55 +12748,6 @@ packages: - aws-crt dev: false - /@aws-sdk/client-sso-oidc/3.600.0_tdq3komn4zwyd65w7klbptsu34: - resolution: {integrity: sha512-7+I8RWURGfzvChyNQSyj5/tKrqRbzRl7H+BnTOf/4Vsw1nFOi5ROhlhD4X/Y0QCTacxnaoNcIrqnY7uGGvVRzw==} - engines: {node: '>=16.0.0'} - dependencies: - '@aws-crypto/sha256-browser': 5.2.0 - '@aws-crypto/sha256-js': 5.2.0 - '@aws-sdk/client-sts': 3.600.0 - '@aws-sdk/core': 3.598.0 - '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 - '@aws-sdk/middleware-host-header': 3.598.0 - '@aws-sdk/middleware-logger': 3.598.0 - '@aws-sdk/middleware-recursion-detection': 3.598.0 - '@aws-sdk/middleware-user-agent': 3.598.0 - '@aws-sdk/region-config-resolver': 3.598.0 - '@aws-sdk/types': 3.598.0 - '@aws-sdk/util-endpoints': 3.598.0 - '@aws-sdk/util-user-agent-browser': 3.598.0 - '@aws-sdk/util-user-agent-node': 3.598.0 - '@smithy/config-resolver': 3.0.3 - '@smithy/core': 2.2.3 - '@smithy/fetch-http-handler': 3.2.1 - '@smithy/hash-node': 3.0.2 - '@smithy/invalid-dependency': 3.0.2 - '@smithy/middleware-content-length': 3.0.2 - '@smithy/middleware-endpoint': 3.0.4 - '@smithy/middleware-retry': 3.0.6 - '@smithy/middleware-serde': 3.0.3 - '@smithy/middleware-stack': 3.0.3 - '@smithy/node-config-provider': 3.1.3 - '@smithy/node-http-handler': 3.1.2 - '@smithy/protocol-http': 4.0.3 - '@smithy/smithy-client': 3.1.6 - '@smithy/types': 3.3.0 - '@smithy/url-parser': 3.0.3 - '@smithy/util-base64': 3.0.0 - '@smithy/util-body-length-browser': 3.0.0 - '@smithy/util-body-length-node': 3.0.0 - '@smithy/util-defaults-mode-browser': 3.0.6 - '@smithy/util-defaults-mode-node': 3.0.6 - '@smithy/util-endpoints': 2.0.3 - '@smithy/util-middleware': 3.0.3 - '@smithy/util-retry': 3.0.2 - '@smithy/util-utf8': 3.0.0 - tslib: 2.6.3 - transitivePeerDependencies: - - '@aws-sdk/client-sts' - - aws-crt - dev: false - /@aws-sdk/client-sso/3.423.0: resolution: {integrity: sha512-znIufHkwhCIePgaYciIs3x/+BpzR57CZzbCKHR9+oOvGyufEPPpUT5bFLvbwTgfiVkTjuk6sG/ES3U5Bc+xtrA==} engines: {node: '>=14.0.0'} @@ -13029,7 +12983,7 @@ packages: dependencies: '@aws-crypto/sha256-browser': 5.2.0 '@aws-crypto/sha256-js': 5.2.0 - '@aws-sdk/client-sso-oidc': 3.600.0_tdq3komn4zwyd65w7klbptsu34 + '@aws-sdk/client-sso-oidc': 3.600.0 '@aws-sdk/core': 3.598.0 '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 '@aws-sdk/middleware-host-header': 3.598.0 @@ -13071,6 +13025,55 @@ packages: - aws-crt dev: false + /@aws-sdk/client-sts/3.600.0_dseaa2p5u2yk67qiepewcq3hkq: + resolution: {integrity: sha512-KQG97B7LvTtTiGmjlrG1LRAY8wUvCQzrmZVV5bjrJ/1oXAU7DITYwVbSJeX9NWg6hDuSk0VE3MFwIXS2SvfLIA==} + engines: {node: '>=16.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 5.2.0 + '@aws-crypto/sha256-js': 5.2.0 + '@aws-sdk/client-sso-oidc': 3.600.0 + '@aws-sdk/core': 3.598.0 + '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 + '@aws-sdk/middleware-host-header': 3.598.0 + '@aws-sdk/middleware-logger': 3.598.0 + '@aws-sdk/middleware-recursion-detection': 3.598.0 + '@aws-sdk/middleware-user-agent': 3.598.0 + '@aws-sdk/region-config-resolver': 3.598.0 + '@aws-sdk/types': 3.598.0 + '@aws-sdk/util-endpoints': 3.598.0 + '@aws-sdk/util-user-agent-browser': 3.598.0 + '@aws-sdk/util-user-agent-node': 3.598.0 + '@smithy/config-resolver': 3.0.3 + '@smithy/core': 2.2.3 + '@smithy/fetch-http-handler': 3.2.1 + '@smithy/hash-node': 3.0.2 + '@smithy/invalid-dependency': 3.0.2 + '@smithy/middleware-content-length': 3.0.2 + '@smithy/middleware-endpoint': 3.0.4 + '@smithy/middleware-retry': 3.0.6 + '@smithy/middleware-serde': 3.0.3 + '@smithy/middleware-stack': 3.0.3 + '@smithy/node-config-provider': 3.1.3 + '@smithy/node-http-handler': 3.1.2 + '@smithy/protocol-http': 4.0.3 + '@smithy/smithy-client': 3.1.6 + '@smithy/types': 3.3.0 + '@smithy/url-parser': 3.0.3 + '@smithy/util-base64': 3.0.0 + '@smithy/util-body-length-browser': 3.0.0 + '@smithy/util-body-length-node': 3.0.0 + '@smithy/util-defaults-mode-browser': 3.0.6 + '@smithy/util-defaults-mode-node': 3.0.6 + '@smithy/util-endpoints': 2.0.3 + '@smithy/util-middleware': 3.0.3 + '@smithy/util-retry': 3.0.2 + '@smithy/util-utf8': 3.0.0 + tslib: 2.6.3 + transitivePeerDependencies: + - '@aws-sdk/client-sso-oidc' + - aws-crt + dev: false + /@aws-sdk/core/3.556.0: resolution: {integrity: sha512-vJaSaHw2kPQlo11j/Rzuz0gk1tEaKdz+2ser0f0qZ5vwFlANjt08m/frU17ctnVKC1s58bxpctO/1P894fHLrA==} engines: {node: '>=14.0.0'} @@ -17391,7 +17394,7 @@ packages: '@aws-sdk/client-sns': 3.423.0 '@aws-sdk/client-sqs': 3.423.0 '@aws-sdk/client-ssm': 3.423.0 - '@aws-sdk/client-sts': 3.600.0 + '@aws-sdk/client-sts': 3.600.0_dseaa2p5u2yk67qiepewcq3hkq '@aws-sdk/s3-request-presigner': 3.609.0 '@pipedream/helper_functions': 0.3.12 '@pipedream/platform': 1.6.6 From 28658698f067753a2976210e4c506c58d2cc9a4b Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Tue, 24 Sep 2024 12:57:00 -0300 Subject: [PATCH 4/7] some adjusts --- components/dust/actions/talk-assistant/talk-assistant.mjs | 7 +++---- components/dust/dust.app.mjs | 5 ----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/components/dust/actions/talk-assistant/talk-assistant.mjs b/components/dust/actions/talk-assistant/talk-assistant.mjs index 248b227ab90ad..a71198e9528a0 100644 --- a/components/dust/actions/talk-assistant/talk-assistant.mjs +++ b/components/dust/actions/talk-assistant/talk-assistant.mjs @@ -16,10 +16,9 @@ export default { ], }, content: { - propDefinition: [ - dust, - "content", - ], + type: "string", + label: "Message Content", + description: "The content of the message to be sent to the assistant", }, timezone: { type: "string", diff --git a/components/dust/dust.app.mjs b/components/dust/dust.app.mjs index 256ec1ed5429b..2a8dc14cf7b50 100644 --- a/components/dust/dust.app.mjs +++ b/components/dust/dust.app.mjs @@ -34,11 +34,6 @@ export default { })); }, }, - document: { - type: "string", - label: "Document", - description: "The content of the document to be uploaded", - }, }, methods: { _baseUrl() { From 78b98b97532eb5fbf54c70cedc41b748d654fb61 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Tue, 24 Sep 2024 12:57:17 -0300 Subject: [PATCH 5/7] some adjusts --- components/dust/actions/upsert-document/upsert-document.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/dust/actions/upsert-document/upsert-document.mjs b/components/dust/actions/upsert-document/upsert-document.mjs index 4beada52f972e..ec375bd9af4b4 100644 --- a/components/dust/actions/upsert-document/upsert-document.mjs +++ b/components/dust/actions/upsert-document/upsert-document.mjs @@ -43,7 +43,7 @@ export default { }, }); - $.export("$summary", `Successfully uploaded document to destination ${this.destination}`); + $.export("$summary", "Successfully uploaded document"); return response; }, }; From 2f11ccd984cc71fae3ec406bb82e55701f786e48 Mon Sep 17 00:00:00 2001 From: Leo Vu Date: Wed, 25 Sep 2024 10:28:52 +0700 Subject: [PATCH 6/7] Require content prop --- components/dust/actions/upsert-document/upsert-document.mjs | 1 - 1 file changed, 1 deletion(-) diff --git a/components/dust/actions/upsert-document/upsert-document.mjs b/components/dust/actions/upsert-document/upsert-document.mjs index ec375bd9af4b4..1ee85d8bf46ce 100644 --- a/components/dust/actions/upsert-document/upsert-document.mjs +++ b/components/dust/actions/upsert-document/upsert-document.mjs @@ -23,7 +23,6 @@ export default { type: "string", label: "Content", description: "The text content of the document to upsert.", - optional: true, }, lightDocumentOutput: { type: "boolean", From 19fa8e1d3233487f4f554aee664c077c0bad7c6e Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Thu, 26 Sep 2024 16:45:07 -0300 Subject: [PATCH 7/7] remove optional from prop email --- components/dust/actions/talk-assistant/talk-assistant.mjs | 1 - 1 file changed, 1 deletion(-) diff --git a/components/dust/actions/talk-assistant/talk-assistant.mjs b/components/dust/actions/talk-assistant/talk-assistant.mjs index a71198e9528a0..17ec47e2b9f01 100644 --- a/components/dust/actions/talk-assistant/talk-assistant.mjs +++ b/components/dust/actions/talk-assistant/talk-assistant.mjs @@ -35,7 +35,6 @@ export default { type: "string", label: "Email", description: "Put an email if needed.", - optional: true, }, }, async run({ $ }) {