-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* dust init * [Components] dust #14021 Actions - Talk to Assistant - Upsert Document * pnpm update * some adjusts * some adjusts * Require content prop * remove optional from prop email --------- Co-authored-by: Leo Vu <[email protected]>
- Loading branch information
1 parent
2cf235b
commit 08b948b
Showing
6 changed files
with
809 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
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.", | ||
}, | ||
}, | ||
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
48
components/dust/actions/upsert-document/upsert-document.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}, | ||
}; |
Oops, something went wrong.