-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,622 additions
and
0 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,9 @@ | ||
API_KEY=XXX | ||
TEST_DATASTORE_ID=XXX | ||
TEST_AGENT_ID=XXX | ||
API_URL=http://localhost:3000 | ||
|
||
# OAUTH_CONSUMER_KEY=YOUR_OAUTH_CONSUMER_KEY | ||
# OAUTH_CONSUMER_SECRET=YOUR_OAUTH_CONSUMER_SECRET | ||
# OAUTH_TOKEN=YOUR_OAUTH_TOKEN | ||
# OAUTH_TOKEN_SECRET=YOUR_OAUTH_TOKEN_SECRET |
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,62 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/ | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# environment variables file | ||
.env | ||
.environment | ||
|
||
# next.js build output | ||
.next |
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,4 @@ | ||
{ | ||
"id": 185359, | ||
"key": "App185359" | ||
} |
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,28 @@ | ||
const baseApiUrl = process.env.API_URL | ||
? process.env.API_URL | ||
: 'https://api.databerry.ai'; | ||
|
||
module.exports = { | ||
type: 'custom', | ||
test: { | ||
headers: { Authorization: 'Bearer {{bundle.authData.api_key}}' }, | ||
removeMissingValuesFrom: { params: true }, | ||
url: `${baseApiUrl}/api/external/me`, | ||
}, | ||
connectionLabel: (z, bundle) => { | ||
const { email } = bundle.inputData; | ||
return `User: ${email}`; | ||
}, | ||
fields: [ | ||
{ | ||
computed: false, | ||
key: 'api_key', | ||
required: false, | ||
label: 'Databerry API Key', | ||
type: 'password', | ||
helpText: | ||
'Your Databerry API Key can be found here https://app.databerry.ai/account', | ||
}, | ||
], | ||
customConfig: {}, | ||
}; |
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,81 @@ | ||
const http = require('https'); // require('http') if your URL is not https | ||
|
||
const FormData = require('form-data'); | ||
|
||
const zapier = require('zapier-platform-core'); | ||
|
||
zapier.tools.env.inject(); | ||
|
||
const baseApiUrl = process.env.API_URL | ||
? process.env.API_URL | ||
: 'https://api.databerry.ai'; | ||
|
||
// Getting a stream directly from http. This only works on core 10+. For core | ||
// 9.x compatible code, see uploadFile_v9.js. | ||
const makeDownloadStream = (url) => | ||
new Promise((resolve, reject) => { | ||
http | ||
.request(url, (res) => { | ||
// We can risk missing the first n bytes if we don't pause! | ||
res.pause(); | ||
resolve(res); | ||
}) | ||
.on('error', reject) | ||
.end(); | ||
}); | ||
|
||
const perform = async (z, bundle) => { | ||
// bundle.inputData.file will in fact be an URL where the file data can be | ||
// downloaded from which we do via a stream | ||
const stream = await makeDownloadStream(bundle.inputData.file, z); | ||
|
||
const form = new FormData(); | ||
form.append('file', stream); | ||
form.append('fileName', bundle.inputData.fileName || ''); | ||
|
||
// All set! Resume the stream | ||
stream.resume(); | ||
|
||
console.log('bundle.authData.api_key', bundle.authData); | ||
|
||
const response = await z.request({ | ||
url: `${baseApiUrl}/api/external/datastores/file-upload/${bundle.inputData.datastore_id}`, | ||
method: 'POST', | ||
body: form, | ||
headers: { | ||
Authorization: `Bearer ${bundle.authData.api_key}`, | ||
}, | ||
}); | ||
|
||
return response.data; | ||
}; | ||
|
||
module.exports = { | ||
key: 'datastore_file_upload', | ||
noun: 'File', | ||
display: { | ||
label: 'Upload File', | ||
description: 'Upload a new file to one of your Datastore.', | ||
}, | ||
operation: { | ||
inputFields: [ | ||
{ | ||
key: 'datastore_id', | ||
label: 'Datastore ID', | ||
type: 'string', | ||
helpText: 'The ID of your Datastore', | ||
dynamic: 'list_datastores.id.name', | ||
required: true, | ||
list: false, | ||
altersDynamicFields: false, | ||
}, | ||
{ key: 'fileName', required: false, type: 'string', label: 'File Name' }, | ||
{ key: 'file', required: true, type: 'file', label: 'File' }, | ||
], | ||
perform, | ||
sample: { | ||
file: 'SAMPLE FILE', | ||
fileName: 'test.pdf', | ||
}, | ||
}, | ||
}; |
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,56 @@ | ||
const zapier = require('zapier-platform-core'); | ||
|
||
zapier.tools.env.inject(); | ||
|
||
const baseApiUrl = process.env.API_URL | ||
? process.env.API_URL | ||
: 'https://api.databerry.ai'; | ||
|
||
module.exports = { | ||
display: { | ||
description: 'Query one of your Agent', | ||
hidden: false, | ||
label: 'Query Agent', | ||
}, | ||
key: 'query_agent', | ||
noun: 'Agent', | ||
operation: { | ||
inputFields: [ | ||
{ | ||
key: 'agent_id', | ||
label: 'Agent ID', | ||
type: 'string', | ||
helpText: 'The ID of your Agent', | ||
dynamic: 'list_agents.id.name', | ||
required: true, | ||
list: false, | ||
altersDynamicFields: false, | ||
}, | ||
{ | ||
key: 'query', | ||
label: 'Query', | ||
type: 'string', | ||
helpText: 'The query to send to the Agent', | ||
required: true, | ||
list: false, | ||
altersDynamicFields: false, | ||
}, | ||
], | ||
perform: { | ||
body: { query: '{{bundle.inputData.query}}' }, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Accept: 'application/json', | ||
Authorization: 'Bearer {{bundle.authData.api_key}}', | ||
}, | ||
method: 'POST', | ||
url: `${baseApiUrl}/api/external/agents/{{bundle.inputData.agent_id}}/query`, | ||
}, | ||
sample: { | ||
query: 'Hello', | ||
answer: | ||
'Hello! How may I assist you today? Please let me know if you have any questions or concerns related to our services or policies. If you need more information about our chat site app, you can check out our documentation at https://docs.databerry.ai/apps/chat-site. Additionally, if you have any questions about our privacy policy, you can find it at https://www.databerry.ai/privacy. Please let me know if there is anything else I can help you with.', | ||
}, | ||
outputFields: [{ key: 'answer', label: 'Answer', type: 'string' }], | ||
}, | ||
}; |
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,23 @@ | ||
const authentication = require('./authentication'); | ||
const listAgentsTrigger = require('./triggers/list_agents.js'); | ||
const listDatastoresTrigger = require('./triggers/list_datastores.js'); | ||
const queryAgentCreate = require('./creates/query_agent.js'); | ||
const queryDatastoreSearch = require('./searches/query_datastore.js'); | ||
const datastoreFileUpload = require('./creates/datastore_file_upload.js'); | ||
|
||
module.exports = { | ||
version: require('./package.json').version, | ||
platformVersion: require('zapier-platform-core').version, | ||
authentication: authentication, | ||
searches: { | ||
[queryDatastoreSearch.key]: queryDatastoreSearch, | ||
}, | ||
creates: { | ||
[queryAgentCreate.key]: queryAgentCreate, | ||
[datastoreFileUpload.key]: datastoreFileUpload, | ||
}, | ||
triggers: { | ||
[listAgentsTrigger.key]: listAgentsTrigger, | ||
[listDatastoresTrigger.key]: listDatastoresTrigger, | ||
}, | ||
}; |
Oops, something went wrong.
35e9b7c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
dashboard – ./
dashboard-git-main-databerry.vercel.app
dashboard-databerry.vercel.app
dashboard-nu-tawny.vercel.app
*.databerry.ai
app.databerry.ai
databerry.ai
www.databerry.ai