forked from activepieces/activepieces
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dust): add support for fragments
- Loading branch information
1 parent
362638b
commit 75ef596
Showing
4 changed files
with
83 additions
and
20 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"name": "@activepieces/piece-dust", | ||
"version": "0.0.4" | ||
} | ||
"version": "0.0.5" | ||
} |
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
49 changes: 49 additions & 0 deletions
49
packages/pieces/community/dust/src/lib/actions/add-context-to-conversation.ts
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,49 @@ | ||
import { createAction, Property } from '@activepieces/pieces-framework'; | ||
import { dustAuth } from '../..'; | ||
import { | ||
assistantProp, | ||
DUST_BASE_URL, | ||
getConversationContent, | ||
timezoneProp, | ||
usernameProp, | ||
} from 'packages/pieces/community/dust/src/lib/common'; | ||
import { | ||
httpClient, | ||
HttpMethod, | ||
HttpRequest, | ||
} from '@activepieces/pieces-common'; | ||
|
||
export const addContextToConversation = createAction({ | ||
// auth: check https://www.activepieces.com/docs/developers/piece-reference/authentication, | ||
name: 'addContextToConversation', | ||
displayName: 'Add context to conversation', | ||
description: | ||
'Create a new content fragment in a conversation. Content fragments are pieces of information that can be inserted in conversations and are passed as context to assistants to when they generate an answer.', | ||
auth: dustAuth, | ||
props: { | ||
conversationId: Property.ShortText({ | ||
displayName: 'Conversation ID', | ||
required: true, | ||
}), | ||
fragment: Property.LongText({ displayName: 'Fragment', required: true }), | ||
}, | ||
async run({ auth, propsValue }) { | ||
const request: HttpRequest = { | ||
method: HttpMethod.POST, | ||
url: `${DUST_BASE_URL}/${auth.workspaceId}/assistant/conversations/${propsValue.conversationId}/content_fragments`, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${auth.apiKey}`, | ||
}, | ||
body: JSON.stringify( | ||
{ | ||
content: propsValue.fragment, | ||
title: 'fragment', | ||
}, | ||
(key, value) => (typeof value === 'undefined' ? null : value) | ||
), | ||
}; | ||
await httpClient.sendRequest(request); | ||
return await getConversationContent(propsValue.conversationId, auth); | ||
}, | ||
}); |
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