Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
75 changes: 75 additions & 0 deletions components/dust/actions/talk-assistant/talk-assistant.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { TIMEZONE_OPTIONS } from "../../common/constants.mjs";
import dust from "../../dust.app.mjs";

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.1",
type: "action",
props: {
dust,
assistantId: {
propDefinition: [
dust,
"assistantId",
],
},
content: {
type: "string",
label: "Message Content",
description: "The content of the message to be sent to the assistant",
},
timezone: {
type: "string",
label: "Timezone",
description: "Set the timezone in which you want to operate.",
options: TIMEZONE_OPTIONS,
},
username: {
type: "string",
label: "Username",
description: "The name to be displayed in the conversation.",
},
email: {
type: "string",
label: "Email",
description: "Put an email if needed.",
optional: true,
},
},
async run({ $ }) {
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 {
agentMessage: conversation.content[1][0].content,
conversationUrl: `https://dust.tt/w/${conversation.owner.sId}/assistant/${conversation.sId}`,
message,
};
},
};
48 changes: 48 additions & 0 deletions components/dust/actions/upsert-document/upsert-document.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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.",
},
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");
return response;
},
};
Loading
Loading