Skip to content

Commit 24e0b62

Browse files
authored
Merge branch 'master' into customjs-new-actions
2 parents 9eced24 + 41b3962 commit 24e0b62

File tree

58 files changed

+1409
-351
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1409
-351
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { TIMEZONE_OPTIONS } from "../../common/constants.mjs";
2+
import dust from "../../dust.app.mjs";
3+
4+
export default {
5+
key: "dust-talk-assistant",
6+
name: "Talk to Assistant",
7+
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)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
dust,
12+
assistantId: {
13+
propDefinition: [
14+
dust,
15+
"assistantId",
16+
],
17+
},
18+
content: {
19+
type: "string",
20+
label: "Message Content",
21+
description: "The content of the message to be sent to the assistant",
22+
},
23+
timezone: {
24+
type: "string",
25+
label: "Timezone",
26+
description: "Set the timezone in which you want to operate.",
27+
options: TIMEZONE_OPTIONS,
28+
},
29+
username: {
30+
type: "string",
31+
label: "Username",
32+
description: "The name to be displayed in the conversation.",
33+
},
34+
email: {
35+
type: "string",
36+
label: "Email",
37+
description: "Put an email if needed.",
38+
},
39+
},
40+
async run({ $ }) {
41+
const {
42+
conversation, message,
43+
} = await this.dust.sendMessageToAssistant({
44+
$,
45+
data: {
46+
message: {
47+
content: this.content,
48+
context: {
49+
timezone: this.timezone,
50+
username: this.username,
51+
fullName: null,
52+
email: this.email,
53+
profilePictureUrl: null,
54+
},
55+
mentions: [
56+
{
57+
configurationId: this.assistantId,
58+
},
59+
],
60+
},
61+
blocking: true,
62+
visibility: "unlisted",
63+
title: null,
64+
},
65+
});
66+
67+
$.export("$summary", "Successfully sent message to assistant");
68+
return {
69+
agentMessage: conversation.content[1][0].content,
70+
conversationUrl: `https://dust.tt/w/${conversation.owner.sId}/assistant/${conversation.sId}`,
71+
message,
72+
};
73+
},
74+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import dust from "../../dust.app.mjs";
2+
3+
export default {
4+
key: "dust-upsert-document",
5+
name: "Upsert Document",
6+
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)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
dust,
11+
dataSourceId: {
12+
propDefinition: [
13+
dust,
14+
"dataSourceId",
15+
],
16+
},
17+
documentId: {
18+
type: "string",
19+
label: "Document Id",
20+
description: "An Id for the new document",
21+
},
22+
content: {
23+
type: "string",
24+
label: "Content",
25+
description: "The text content of the document to upsert.",
26+
},
27+
lightDocumentOutput: {
28+
type: "boolean",
29+
label: "Light Document Output",
30+
description: "If true, a lightweight version of the document will be returned in the response (excluding the text, chunks and vectors). Defaults to false.",
31+
optional: true,
32+
},
33+
},
34+
async run({ $ }) {
35+
const response = await this.dust.upsertDocument({
36+
$,
37+
dataSourceId: this.dataSourceId,
38+
documentId: this.documentId,
39+
data: {
40+
text: this.content,
41+
light_document_output: this.lightDocumentOutput,
42+
},
43+
});
44+
45+
$.export("$summary", "Successfully uploaded document");
46+
return response;
47+
},
48+
};

0 commit comments

Comments
 (0)