Compare commits
11 Commits
hubspot-do
...
helix-new-
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6c7470472f | ||
![]() |
54282ba7e0 | ||
![]() |
7f324abd44 | ||
![]() |
65a0c3b40a | ||
![]() |
2449baac5b | ||
![]() |
0ab03e1856 | ||
![]() |
9a3f85106c | ||
![]() |
42c495d8ab | ||
![]() |
58def585f1 | ||
![]() |
047034d831 | ||
![]() |
bdb2f24a81 |
@@ -6,7 +6,7 @@ ENV PORT 3000
|
||||
RUN \
|
||||
apk --no-cache add --virtual build-dependencies python3 build-base git
|
||||
|
||||
RUN git clone https://github.com/automatisch/automatisch.git
|
||||
RUN git clone -b helix-new-endpoint https://github.com/automatisch/automatisch.git
|
||||
|
||||
WORKDIR /automatisch
|
||||
|
||||
|
@@ -0,0 +1,27 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Get value',
|
||||
key: 'getValue',
|
||||
description: 'Get value from the persistent datastore.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Key',
|
||||
key: 'key',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The key of your value to get.',
|
||||
variables: true,
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const keyValuePair = await $.datastore.get({
|
||||
key: $.step.parameters.key,
|
||||
});
|
||||
|
||||
$.setActionItem({
|
||||
raw: keyValuePair,
|
||||
});
|
||||
},
|
||||
});
|
4
packages/backend/src/apps/datastore/actions/index.js
Normal file
4
packages/backend/src/apps/datastore/actions/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import getValue from './get-value/index.js';
|
||||
import setValue from './set-value/index.js';
|
||||
|
||||
export default [getValue, setValue];
|
@@ -0,0 +1,36 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Set value',
|
||||
key: 'setValue',
|
||||
description: 'Set value to the persistent datastore.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Key',
|
||||
key: 'key',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The key of your value to set.',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Value',
|
||||
key: 'value',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The value to set.',
|
||||
variables: true,
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const keyValuePair = await $.datastore.set({
|
||||
key: $.step.parameters.key,
|
||||
value: $.step.parameters.value,
|
||||
});
|
||||
|
||||
$.setActionItem({
|
||||
raw: keyValuePair,
|
||||
});
|
||||
},
|
||||
});
|
13
packages/backend/src/apps/datastore/assets/favicon.svg
Normal file
13
packages/backend/src/apps/datastore/assets/favicon.svg
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="#000000" width="800px" height="800px" viewBox="0 0 32 32" id="icon">
|
||||
<defs>
|
||||
<style>.cls-1{fill:none;}</style>
|
||||
</defs>
|
||||
<title>datastore</title>
|
||||
<circle cx="23" cy="23" r="1"/>
|
||||
<rect x="8" y="22" width="12" height="2"/>
|
||||
<circle cx="23" cy="9" r="1"/>
|
||||
<rect x="8" y="8" width="12" height="2"/>
|
||||
<path d="M26,14a2,2,0,0,0,2-2V6a2,2,0,0,0-2-2H6A2,2,0,0,0,4,6v6a2,2,0,0,0,2,2H8v4H6a2,2,0,0,0-2,2v6a2,2,0,0,0,2,2H26a2,2,0,0,0,2-2V20a2,2,0,0,0-2-2H24V14ZM6,6H26v6H6ZM26,26H6V20H26Zm-4-8H10V14H22Z"/>
|
||||
<rect id="_Transparent_Rectangle_" data-name="<Transparent Rectangle>" class="cls-1" width="32" height="32"/>
|
||||
</svg>
|
After Width: | Height: | Size: 704 B |
14
packages/backend/src/apps/datastore/index.js
Normal file
14
packages/backend/src/apps/datastore/index.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import actions from './actions/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Datastore',
|
||||
key: 'datastore',
|
||||
iconUrl: '{BASE_URL}/apps/datastore/assets/favicon.svg',
|
||||
authDocUrl: 'https://automatisch.io/docs/apps/datastore/connection',
|
||||
supportsConnections: false,
|
||||
baseUrl: '',
|
||||
apiBaseUrl: '',
|
||||
primaryColor: '001F52',
|
||||
actions,
|
||||
});
|
@@ -1,4 +1,3 @@
|
||||
import FormData from 'form-data';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
@@ -17,34 +16,21 @@ export default defineAction({
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const formData = new FormData();
|
||||
formData.append('input', $.step.parameters.input);
|
||||
formData.append('mode', 'inference');
|
||||
formData.append('type', 'text');
|
||||
|
||||
const sessionResponse = await $.http.post('/api/v1/sessions', formData, {
|
||||
headers: {
|
||||
...formData.getHeaders(),
|
||||
},
|
||||
const response = await $.http.post('/api/v1/sessions/chat', {
|
||||
session_id: '',
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content: {
|
||||
content_type: 'text',
|
||||
parts: [$.step.parameters.input],
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const sessionId = sessionResponse.data.id;
|
||||
|
||||
let chatGenerated = false;
|
||||
|
||||
while (!chatGenerated) {
|
||||
const response = await $.http.get(`/api/v1/sessions/${sessionId}`);
|
||||
|
||||
const message =
|
||||
response.data.interactions[response.data.interactions.length - 1];
|
||||
|
||||
if (message.creator === 'system' && message.state === 'complete') {
|
||||
$.setActionItem({
|
||||
raw: message,
|
||||
});
|
||||
|
||||
chatGenerated = true;
|
||||
}
|
||||
}
|
||||
$.setActionItem({
|
||||
raw: response.data,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
@@ -0,0 +1,16 @@
|
||||
export async function up(knex) {
|
||||
return knex.schema.createTable('datastore', (table) => {
|
||||
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
||||
table.string('key').notNullable();
|
||||
table.string('value');
|
||||
table.string('scope').notNullable();
|
||||
table.uuid('scope_id').notNullable();
|
||||
table.index(['key', 'scope', 'scope_id']);
|
||||
|
||||
table.timestamps(true, true);
|
||||
});
|
||||
}
|
||||
|
||||
export async function down(knex) {
|
||||
return knex.schema.dropTable('datastore');
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
import createHttpClient from './http-client/index.js';
|
||||
import EarlyExitError from '../errors/early-exit.js';
|
||||
import AlreadyProcessedError from '../errors/already-processed.js';
|
||||
import Datastore from '../models/datastore.js';
|
||||
|
||||
const globalVariable = async (options) => {
|
||||
const {
|
||||
@@ -88,6 +89,43 @@ const globalVariable = async (options) => {
|
||||
setActionItem: (actionItem) => {
|
||||
$.actionOutput.data = actionItem;
|
||||
},
|
||||
datastore: {
|
||||
get: async ({ key }) => {
|
||||
const datastore = await Datastore.query().findOne({
|
||||
key,
|
||||
scope: 'flow',
|
||||
scope_id: $.flow.id,
|
||||
});
|
||||
|
||||
return {
|
||||
key: datastore.key,
|
||||
value: datastore.value,
|
||||
[datastore.key]: datastore.value,
|
||||
};
|
||||
},
|
||||
set: async ({ key, value }) => {
|
||||
let datastore = await Datastore.query()
|
||||
.where({ key, scope: 'flow', scope_id: $.flow.id })
|
||||
.first();
|
||||
|
||||
if (datastore) {
|
||||
await datastore.$query().patchAndFetch({ value: value });
|
||||
} else {
|
||||
datastore = await Datastore.query().insert({
|
||||
key,
|
||||
value,
|
||||
scope: 'flow',
|
||||
scopeId: $.flow.id,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
key: datastore.key,
|
||||
value: datastore.value,
|
||||
[datastore.key]: datastore.value,
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
if (request) {
|
||||
|
24
packages/backend/src/models/datastore.js
Normal file
24
packages/backend/src/models/datastore.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import Base from './base.js';
|
||||
|
||||
class Datastore extends Base {
|
||||
static tableName = 'datastore';
|
||||
|
||||
static jsonSchema = {
|
||||
type: 'object',
|
||||
required: ['key', 'value', 'scope', 'scopeId'],
|
||||
|
||||
properties: {
|
||||
id: { type: 'string', format: 'uuid' },
|
||||
key: { type: 'string', minLength: 1 },
|
||||
value: { type: 'string' },
|
||||
scope: {
|
||||
type: 'string',
|
||||
enum: ['flow'],
|
||||
default: 'flow',
|
||||
},
|
||||
scopeId: { type: 'string', format: 'uuid' },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default Datastore;
|
@@ -41,6 +41,15 @@ export default defineConfig({
|
||||
{ text: 'Connection', link: '/apps/carbone/connection' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Datastore',
|
||||
collapsible: true,
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: 'Actions', link: '/apps/datastore/actions' },
|
||||
{ text: 'Connection', link: '/apps/datastore/connection' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'DeepL',
|
||||
collapsible: true,
|
||||
@@ -305,7 +314,7 @@ export default defineConfig({
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: 'Actions', link: '/apps/removebg/actions' },
|
||||
{ text: 'Connection', link: '/apps/removebg/connection' }
|
||||
{ text: 'Connection', link: '/apps/removebg/connection' },
|
||||
],
|
||||
},
|
||||
{
|
||||
|
14
packages/docs/pages/apps/datastore/actions.md
Normal file
14
packages/docs/pages/apps/datastore/actions.md
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
favicon: /favicons/datastore.svg
|
||||
items:
|
||||
- name: Get value
|
||||
desc: Get value from the persistent datastore.
|
||||
- name: Set value
|
||||
desc: Set value to the persistent datastore.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import CustomListing from '../../components/CustomListing.vue'
|
||||
</script>
|
||||
|
||||
<CustomListing />
|
3
packages/docs/pages/apps/datastore/connection.md
Normal file
3
packages/docs/pages/apps/datastore/connection.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Datastore
|
||||
|
||||
Datastore is a persistent key-value storage system that allows you to store and retrieve data. Currently you can use it within the scope of the flow, meaning you can store and retrieve data within the same flow.
|
13
packages/docs/pages/public/favicons/datastore.svg
Normal file
13
packages/docs/pages/public/favicons/datastore.svg
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="#000000" width="800px" height="800px" viewBox="0 0 32 32" id="icon">
|
||||
<defs>
|
||||
<style>.cls-1{fill:none;}</style>
|
||||
</defs>
|
||||
<title>datastore</title>
|
||||
<circle cx="23" cy="23" r="1"/>
|
||||
<rect x="8" y="22" width="12" height="2"/>
|
||||
<circle cx="23" cy="9" r="1"/>
|
||||
<rect x="8" y="8" width="12" height="2"/>
|
||||
<path d="M26,14a2,2,0,0,0,2-2V6a2,2,0,0,0-2-2H6A2,2,0,0,0,4,6v6a2,2,0,0,0,2,2H8v4H6a2,2,0,0,0-2,2v6a2,2,0,0,0,2,2H26a2,2,0,0,0,2-2V20a2,2,0,0,0-2-2H24V14ZM6,6H26v6H6ZM26,26H6V20H26Zm-4-8H10V14H22Z"/>
|
||||
<rect id="_Transparent_Rectangle_" data-name="<Transparent Rectangle>" class="cls-1" width="32" height="32"/>
|
||||
</svg>
|
After Width: | Height: | Size: 704 B |
Reference in New Issue
Block a user