@dxos/plugin-automation 0.6.14-main.69511f5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +8 -0
- package/README.md +15 -0
- package/dist/lib/browser/PromptContainer-RFMJXMUA.mjs +19 -0
- package/dist/lib/browser/PromptContainer-RFMJXMUA.mjs.map +7 -0
- package/dist/lib/browser/chunk-3TNRXJTD.mjs +14 -0
- package/dist/lib/browser/chunk-3TNRXJTD.mjs.map +7 -0
- package/dist/lib/browser/chunk-GGA62V7D.mjs +55 -0
- package/dist/lib/browser/chunk-GGA62V7D.mjs.map +7 -0
- package/dist/lib/browser/chunk-PSSWFA6A.mjs +217 -0
- package/dist/lib/browser/chunk-PSSWFA6A.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1135 -0
- package/dist/lib/browser/index.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -0
- package/dist/lib/browser/meta.mjs +9 -0
- package/dist/lib/browser/meta.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +16 -0
- package/dist/lib/browser/types/index.mjs.map +7 -0
- package/dist/lib/node/PromptContainer-FRSY6FNL.cjs +45 -0
- package/dist/lib/node/PromptContainer-FRSY6FNL.cjs.map +7 -0
- package/dist/lib/node/chunk-E2H3AGKB.cjs +240 -0
- package/dist/lib/node/chunk-E2H3AGKB.cjs.map +7 -0
- package/dist/lib/node/chunk-N5IDAUFU.cjs +76 -0
- package/dist/lib/node/chunk-N5IDAUFU.cjs.map +7 -0
- package/dist/lib/node/chunk-UPPUTAPL.cjs +37 -0
- package/dist/lib/node/chunk-UPPUTAPL.cjs.map +7 -0
- package/dist/lib/node/index.cjs +1137 -0
- package/dist/lib/node/index.cjs.map +7 -0
- package/dist/lib/node/meta.cjs +30 -0
- package/dist/lib/node/meta.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -0
- package/dist/lib/node/types/index.cjs +38 -0
- package/dist/lib/node/types/index.cjs.map +7 -0
- package/dist/lib/node-esm/PromptContainer-4VHFPEQH.mjs +20 -0
- package/dist/lib/node-esm/PromptContainer-4VHFPEQH.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HFTXKLRR.mjs +218 -0
- package/dist/lib/node-esm/chunk-HFTXKLRR.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-QAPWYK2P.mjs +16 -0
- package/dist/lib/node-esm/chunk-QAPWYK2P.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UT6QKU6J.mjs +56 -0
- package/dist/lib/node-esm/chunk-UT6QKU6J.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1136 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/meta.mjs +10 -0
- package/dist/lib/node-esm/meta.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +17 -0
- package/dist/lib/node-esm/types/index.mjs.map +7 -0
- package/dist/types/src/AutomationPlugin.d.ts +4 -0
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -0
- package/dist/types/src/components/AutomationPanel.d.ts +3 -0
- package/dist/types/src/components/AutomationPanel.d.ts.map +1 -0
- package/dist/types/src/components/Chain.d.ts +12 -0
- package/dist/types/src/components/Chain.d.ts.map +1 -0
- package/dist/types/src/components/PromptContainer.d.ts +6 -0
- package/dist/types/src/components/PromptContainer.d.ts.map +1 -0
- package/dist/types/src/components/PromptEditor/PromptEditor.d.ts +10 -0
- package/dist/types/src/components/PromptEditor/PromptEditor.d.ts.map +1 -0
- package/dist/types/src/components/PromptEditor/PromptEditor.stories.d.ts +6 -0
- package/dist/types/src/components/PromptEditor/PromptEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/PromptEditor/index.d.ts +2 -0
- package/dist/types/src/components/PromptEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/PromptEditor/prompt-extension.d.ts +4 -0
- package/dist/types/src/components/PromptEditor/prompt-extension.d.ts.map +1 -0
- package/dist/types/src/components/PromptEditor/types.d.ts +18 -0
- package/dist/types/src/components/PromptEditor/types.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/Form.d.ts +5 -0
- package/dist/types/src/components/TriggerEditor/Form.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +8 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +5 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/email.d.ts +4 -0
- package/dist/types/src/components/TriggerEditor/email.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/index.d.ts +2 -0
- package/dist/types/src/components/TriggerEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/invokation-handler.d.ts +5 -0
- package/dist/types/src/components/TriggerEditor/invokation-handler.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/meta.d.ts +25 -0
- package/dist/types/src/components/TriggerEditor/meta.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +6 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +7 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +9 -0
- package/dist/types/src/meta.d.ts.map +1 -0
- package/dist/types/src/presets.d.ts +9 -0
- package/dist/types/src/presets.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +17 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/src/types/chain.d.ts +71 -0
- package/dist/types/src/types/chain.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/types.d.ts +7 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/package.json +98 -0
- package/src/AutomationPlugin.tsx +149 -0
- package/src/components/AutomationPanel.tsx +21 -0
- package/src/components/Chain.tsx +66 -0
- package/src/components/PromptContainer.tsx +19 -0
- package/src/components/PromptEditor/PromptEditor.stories.tsx +64 -0
- package/src/components/PromptEditor/PromptEditor.tsx +222 -0
- package/src/components/PromptEditor/index.ts +5 -0
- package/src/components/PromptEditor/prompt-extension.ts +43 -0
- package/src/components/PromptEditor/types.tsx +28 -0
- package/src/components/TriggerEditor/Form.tsx +18 -0
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +82 -0
- package/src/components/TriggerEditor/TriggerEditor.tsx +346 -0
- package/src/components/TriggerEditor/email.ts +49 -0
- package/src/components/TriggerEditor/index.ts +5 -0
- package/src/components/TriggerEditor/invokation-handler.ts +110 -0
- package/src/components/TriggerEditor/meta.tsx +225 -0
- package/src/components/index.ts +12 -0
- package/src/index.ts +12 -0
- package/src/meta.ts +14 -0
- package/src/presets.ts +248 -0
- package/src/translations.ts +30 -0
- package/src/types/chain.ts +38 -0
- package/src/types/index.ts +6 -0
- package/src/types/types.ts +27 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type FC } from 'react';
|
|
6
|
+
|
|
7
|
+
import { create, getMeta as getEchoMeta } from '@dxos/echo-schema';
|
|
8
|
+
import { type FunctionTrigger } from '@dxos/functions/types';
|
|
9
|
+
import { GameType } from '@dxos/plugin-chess/types';
|
|
10
|
+
import { FileType } from '@dxos/plugin-ipfs/types';
|
|
11
|
+
import { DocumentType } from '@dxos/plugin-markdown';
|
|
12
|
+
import { type ScriptType } from '@dxos/plugin-script';
|
|
13
|
+
import { DiagramType } from '@dxos/plugin-sketch/types';
|
|
14
|
+
import { CollectionType, MessageType } from '@dxos/plugin-space';
|
|
15
|
+
import { Input } from '@dxos/react-ui';
|
|
16
|
+
import { safeParseInt } from '@dxos/util';
|
|
17
|
+
|
|
18
|
+
import { InputRow } from './Form';
|
|
19
|
+
import { chainPresets } from '../../presets';
|
|
20
|
+
import { type ChainPromptType } from '../../types';
|
|
21
|
+
import { ChainPresets } from '../Chain';
|
|
22
|
+
import { PromptEditor } from '../PromptEditor';
|
|
23
|
+
|
|
24
|
+
// TODO(burdon): Factor out deps (remove from package.json). Provide via plugins.
|
|
25
|
+
|
|
26
|
+
type TriggerId = string;
|
|
27
|
+
|
|
28
|
+
const stateInitialValues = {
|
|
29
|
+
schemas: [
|
|
30
|
+
// TODO(burdon): Get all schema from API.
|
|
31
|
+
DocumentType,
|
|
32
|
+
FileType,
|
|
33
|
+
GameType,
|
|
34
|
+
MessageType,
|
|
35
|
+
DiagramType,
|
|
36
|
+
CollectionType,
|
|
37
|
+
] as any[],
|
|
38
|
+
selectedSchema: {} as Record<TriggerId, any>,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// TODO(burdon): What is this for?
|
|
42
|
+
export const state = create<typeof stateInitialValues>(stateInitialValues);
|
|
43
|
+
|
|
44
|
+
//
|
|
45
|
+
// Trigger meta.
|
|
46
|
+
// TODO(burdon): Custom/generated UX to provide values to functions from types/other metadata.
|
|
47
|
+
//
|
|
48
|
+
|
|
49
|
+
type MetaProps<T> = { meta: T } & { triggerId?: string };
|
|
50
|
+
|
|
51
|
+
type MetaExtension<T> = {
|
|
52
|
+
initialValue?: () => T;
|
|
53
|
+
component: FC<MetaProps<T>>;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const USERFUNCTIONS_PRESET_META_KEY = 'dxos.org/service/function-preset';
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Create meta type from function.
|
|
60
|
+
* @param trigger - function trigger.
|
|
61
|
+
* @param script - function script.
|
|
62
|
+
*/
|
|
63
|
+
export const getFunctionMetaExtension = (
|
|
64
|
+
trigger: FunctionTrigger,
|
|
65
|
+
script?: ScriptType,
|
|
66
|
+
): MetaExtension<any> | undefined => {
|
|
67
|
+
if (script) {
|
|
68
|
+
const meta = getEchoMeta(script).keys.find((key) => key.source === USERFUNCTIONS_PRESET_META_KEY);
|
|
69
|
+
const extension = meta && metaExtensions[meta.id];
|
|
70
|
+
if (extension) {
|
|
71
|
+
return extension;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// TODO: try to infer by spec type?
|
|
75
|
+
return trigger?.function ? metaExtensions[trigger.function] : metaExtensions['dxos.org/function/gpt'];
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
//
|
|
79
|
+
// Default (generic).
|
|
80
|
+
// TODO(burdon): Create property editor.
|
|
81
|
+
//
|
|
82
|
+
|
|
83
|
+
type DefaultMeta = {};
|
|
84
|
+
|
|
85
|
+
const DefaultMetaProps = ({ meta }: MetaProps<DefaultMeta>) => {
|
|
86
|
+
return <></>;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
//
|
|
90
|
+
// Chess
|
|
91
|
+
//
|
|
92
|
+
|
|
93
|
+
type ChessMeta = { level?: number };
|
|
94
|
+
|
|
95
|
+
const ChessMetaProps = ({ meta }: MetaProps<ChessMeta>) => {
|
|
96
|
+
if (!meta) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<>
|
|
102
|
+
<InputRow label='Level'>
|
|
103
|
+
<Input.TextInput
|
|
104
|
+
type='number'
|
|
105
|
+
value={meta.level ?? 1}
|
|
106
|
+
onChange={(event) => (meta.level = safeParseInt(event.target.value))}
|
|
107
|
+
placeholder='Engine strength.'
|
|
108
|
+
/>
|
|
109
|
+
</InputRow>
|
|
110
|
+
</>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
//
|
|
115
|
+
// Email
|
|
116
|
+
//
|
|
117
|
+
|
|
118
|
+
type EmailWorkerMeta = { account?: string };
|
|
119
|
+
|
|
120
|
+
const EmailWorkerMetaProps = ({ meta }: MetaProps<EmailWorkerMeta>) => {
|
|
121
|
+
if (!meta) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<>
|
|
127
|
+
<InputRow label='Account'>
|
|
128
|
+
<Input.TextInput
|
|
129
|
+
value={meta.account ?? ''}
|
|
130
|
+
onChange={(event) => (meta.account = event.target.value)}
|
|
131
|
+
placeholder='https://'
|
|
132
|
+
/>
|
|
133
|
+
</InputRow>
|
|
134
|
+
</>
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
//
|
|
139
|
+
// Chain
|
|
140
|
+
//
|
|
141
|
+
|
|
142
|
+
type ChainPromptMeta = { model?: string; prompt?: ChainPromptType };
|
|
143
|
+
|
|
144
|
+
const ChainPromptMetaProps = ({ meta, triggerId }: MetaProps<ChainPromptMeta>) => {
|
|
145
|
+
const schema = triggerId ? state.selectedSchema[triggerId] : undefined;
|
|
146
|
+
if (!meta) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
<>
|
|
152
|
+
<InputRow label='Model'>
|
|
153
|
+
<Input.TextInput
|
|
154
|
+
value={meta.model ?? ''}
|
|
155
|
+
onChange={(event) => (meta.model = event.target.value)}
|
|
156
|
+
placeholder='llama2'
|
|
157
|
+
/>
|
|
158
|
+
</InputRow>
|
|
159
|
+
<InputRow label='Presets'>
|
|
160
|
+
<ChainPresets
|
|
161
|
+
presets={chainPresets}
|
|
162
|
+
onSelect={(preset) => {
|
|
163
|
+
meta.prompt = preset.createPrompt();
|
|
164
|
+
}}
|
|
165
|
+
/>
|
|
166
|
+
</InputRow>
|
|
167
|
+
{meta.prompt && (
|
|
168
|
+
<InputRow label='Prompt'>
|
|
169
|
+
<PromptEditor prompt={meta.prompt} schema={schema} />
|
|
170
|
+
</InputRow>
|
|
171
|
+
)}
|
|
172
|
+
</>
|
|
173
|
+
);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
//
|
|
177
|
+
// Embedding
|
|
178
|
+
//
|
|
179
|
+
|
|
180
|
+
type EmbeddingMeta = { model?: string; prompt?: ChainPromptType };
|
|
181
|
+
|
|
182
|
+
const EmbeddingMetaProps = ({ meta }: MetaProps<EmbeddingMeta>) => {
|
|
183
|
+
if (!meta) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<>
|
|
189
|
+
<InputRow label='Model'>
|
|
190
|
+
<Input.TextInput
|
|
191
|
+
value={meta.model ?? ''}
|
|
192
|
+
onChange={(event) => (meta.model = event.target.value)}
|
|
193
|
+
placeholder='llama2'
|
|
194
|
+
/>
|
|
195
|
+
</InputRow>
|
|
196
|
+
</>
|
|
197
|
+
);
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const metaExtensions: Record<string, MetaExtension<any>> = {
|
|
201
|
+
__DEFAULT__: {
|
|
202
|
+
initialValue: () => ({}),
|
|
203
|
+
component: DefaultMetaProps,
|
|
204
|
+
} satisfies MetaExtension<DefaultMeta>,
|
|
205
|
+
|
|
206
|
+
'dxos.org/function/chess': {
|
|
207
|
+
initialValue: () => ({ level: 2 }),
|
|
208
|
+
component: ChessMetaProps,
|
|
209
|
+
} satisfies MetaExtension<ChessMeta>,
|
|
210
|
+
|
|
211
|
+
'dxos.org/function/email-worker': {
|
|
212
|
+
initialValue: () => ({ account: 'hello@dxos.network' }),
|
|
213
|
+
component: EmailWorkerMetaProps,
|
|
214
|
+
} satisfies MetaExtension<EmailWorkerMeta>,
|
|
215
|
+
|
|
216
|
+
'dxos.org/function/gpt': {
|
|
217
|
+
initialValue: () => ({ model: 'llama2' }),
|
|
218
|
+
component: ChainPromptMetaProps,
|
|
219
|
+
} satisfies MetaExtension<ChainPromptMeta>,
|
|
220
|
+
|
|
221
|
+
'dxos.org/function/embedding': {
|
|
222
|
+
initialValue: () => ({ model: 'llama2' }),
|
|
223
|
+
component: EmbeddingMetaProps,
|
|
224
|
+
} satisfies MetaExtension<EmbeddingMeta>,
|
|
225
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { lazy } from 'react';
|
|
6
|
+
|
|
7
|
+
export const PromptContainer = lazy(() => import('./PromptContainer'));
|
|
8
|
+
|
|
9
|
+
export * from './AutomationPanel';
|
|
10
|
+
export * from './Chain';
|
|
11
|
+
export * from './PromptEditor';
|
|
12
|
+
export * from './TriggerEditor';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { AutomationPlugin } from './AutomationPlugin';
|
|
6
|
+
|
|
7
|
+
export default AutomationPlugin;
|
|
8
|
+
|
|
9
|
+
export * from './AutomationPlugin';
|
|
10
|
+
export * from './components';
|
|
11
|
+
export * from './presets';
|
|
12
|
+
export * from './types';
|
package/src/meta.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type PluginMeta } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
export const AUTOMATION_PLUGIN = 'dxos.org/plugin/automation';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
id: AUTOMATION_PLUGIN,
|
|
11
|
+
name: 'Automation',
|
|
12
|
+
description: 'Automation workflows.',
|
|
13
|
+
icon: 'ph--magic-wand--regular',
|
|
14
|
+
} satisfies PluginMeta;
|
package/src/presets.ts
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { create } from '@dxos/echo-schema';
|
|
6
|
+
|
|
7
|
+
import { ChainInputType, ChainPromptType } from './types';
|
|
8
|
+
|
|
9
|
+
export const str = (...text: (string | undefined | boolean)[]): string =>
|
|
10
|
+
text
|
|
11
|
+
.filter((value) => value !== undefined && value !== false)
|
|
12
|
+
.flat()
|
|
13
|
+
.join('\n');
|
|
14
|
+
|
|
15
|
+
export type Preset = {
|
|
16
|
+
id: string;
|
|
17
|
+
title: string;
|
|
18
|
+
createPrompt: () => ChainPromptType;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const chainPresets: Preset[] = [
|
|
22
|
+
{
|
|
23
|
+
id: 'dxos.org/prompt/translate',
|
|
24
|
+
title: 'Translate',
|
|
25
|
+
createPrompt: () =>
|
|
26
|
+
create(ChainPromptType, {
|
|
27
|
+
command: 'say',
|
|
28
|
+
template: str(
|
|
29
|
+
// prettier-ignore
|
|
30
|
+
'Translate the following into {language}:',
|
|
31
|
+
'',
|
|
32
|
+
'---',
|
|
33
|
+
'',
|
|
34
|
+
'{input}',
|
|
35
|
+
),
|
|
36
|
+
inputs: [
|
|
37
|
+
{
|
|
38
|
+
type: ChainInputType.VALUE,
|
|
39
|
+
name: 'language',
|
|
40
|
+
value: 'japanese',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: ChainInputType.PASS_THROUGH,
|
|
44
|
+
name: 'input',
|
|
45
|
+
},
|
|
46
|
+
// TODO(burdon): Message.
|
|
47
|
+
// {
|
|
48
|
+
// type: ChainInputType.CONTEXT,
|
|
49
|
+
// name: 'input',
|
|
50
|
+
// value: 'object.text',
|
|
51
|
+
// },
|
|
52
|
+
],
|
|
53
|
+
}),
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 'dxos.org/prompt/chess',
|
|
57
|
+
title: 'Chess',
|
|
58
|
+
createPrompt: () =>
|
|
59
|
+
create(ChainPromptType, {
|
|
60
|
+
command: 'hint',
|
|
61
|
+
template: str(
|
|
62
|
+
// prettier-ignore
|
|
63
|
+
'You are a machine that is an expert chess player.',
|
|
64
|
+
'',
|
|
65
|
+
'The move history of the current game is: {history}',
|
|
66
|
+
'',
|
|
67
|
+
'Suggest the next move and very briefly explain your strategy in a couple of sentences.',
|
|
68
|
+
),
|
|
69
|
+
inputs: [
|
|
70
|
+
{
|
|
71
|
+
type: ChainInputType.CONTEXT,
|
|
72
|
+
name: 'history',
|
|
73
|
+
value: 'object.pgn',
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
}),
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: 'dxos.org/prompt/mermaid',
|
|
80
|
+
title: 'Mermaid',
|
|
81
|
+
createPrompt: () =>
|
|
82
|
+
create(ChainPromptType, {
|
|
83
|
+
command: 'draw',
|
|
84
|
+
template: str(
|
|
85
|
+
// prettier-ignore
|
|
86
|
+
'Create a simplified mermaid graph representing the text below.',
|
|
87
|
+
'Do not explain anything.',
|
|
88
|
+
'',
|
|
89
|
+
'---',
|
|
90
|
+
'',
|
|
91
|
+
'{input}',
|
|
92
|
+
),
|
|
93
|
+
inputs: [
|
|
94
|
+
{
|
|
95
|
+
type: ChainInputType.PASS_THROUGH,
|
|
96
|
+
name: 'input',
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
}),
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: 'dxos.org/prompt/list',
|
|
103
|
+
title: 'List',
|
|
104
|
+
createPrompt: () =>
|
|
105
|
+
create(ChainPromptType, {
|
|
106
|
+
command: 'list',
|
|
107
|
+
template: str(
|
|
108
|
+
// prettier-ignore
|
|
109
|
+
'You are a machine that only replies with valid, iterable RFC8259 compliant JSON in your responses.',
|
|
110
|
+
'Your entire response should be a single array of JSON objects.',
|
|
111
|
+
'',
|
|
112
|
+
'Your entire response should be a map where the key is the type and the value is a single array of JSON objects conforming to the following types:',
|
|
113
|
+
'',
|
|
114
|
+
'{schema}',
|
|
115
|
+
'',
|
|
116
|
+
'---',
|
|
117
|
+
'',
|
|
118
|
+
'{question}',
|
|
119
|
+
),
|
|
120
|
+
inputs: [
|
|
121
|
+
{
|
|
122
|
+
type: ChainInputType.SCHEMA,
|
|
123
|
+
name: 'schema',
|
|
124
|
+
value: 'example.com/type/project',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
type: ChainInputType.PASS_THROUGH,
|
|
128
|
+
name: 'question',
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
}),
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
id: 'dxos.org/prompt/base',
|
|
135
|
+
title: 'RAG',
|
|
136
|
+
createPrompt: () =>
|
|
137
|
+
create(ChainPromptType, {
|
|
138
|
+
command: 'rag',
|
|
139
|
+
template: str(
|
|
140
|
+
// prettier-ignore
|
|
141
|
+
"Very briefly answer the question based only on the following context and say if you don't know the answer.",
|
|
142
|
+
// 'answer the question using the following context as well as your training data:',
|
|
143
|
+
'',
|
|
144
|
+
'{context}',
|
|
145
|
+
'',
|
|
146
|
+
'---',
|
|
147
|
+
'',
|
|
148
|
+
'question: {question}',
|
|
149
|
+
),
|
|
150
|
+
inputs: [
|
|
151
|
+
{
|
|
152
|
+
type: ChainInputType.RETRIEVER,
|
|
153
|
+
name: 'context',
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
type: ChainInputType.CONTEXT,
|
|
157
|
+
name: 'question',
|
|
158
|
+
value: 'object.text',
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
}),
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
id: 'dxos.org/prompt/lookup',
|
|
165
|
+
title: 'Lookup',
|
|
166
|
+
createPrompt: () =>
|
|
167
|
+
create(ChainPromptType, {
|
|
168
|
+
command: 'lookup',
|
|
169
|
+
template: str(
|
|
170
|
+
// prettier-ignore
|
|
171
|
+
'Lookup and very briefly summarize the following topic in one or two sentences:',
|
|
172
|
+
'',
|
|
173
|
+
'---',
|
|
174
|
+
'',
|
|
175
|
+
'{input}',
|
|
176
|
+
),
|
|
177
|
+
inputs: [
|
|
178
|
+
{
|
|
179
|
+
type: ChainInputType.CONTEXT,
|
|
180
|
+
name: 'input',
|
|
181
|
+
value: 'text',
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
}),
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
id: 'dxos.org/prompt/extract',
|
|
188
|
+
title: 'Extract',
|
|
189
|
+
createPrompt: () =>
|
|
190
|
+
create(ChainPromptType, {
|
|
191
|
+
command: 'extract',
|
|
192
|
+
template: str(
|
|
193
|
+
// prettier-ignore
|
|
194
|
+
'List all people and companies mentioned in the text below.',
|
|
195
|
+
'',
|
|
196
|
+
'You are a machine that only replies with valid, iterable RFC8259 compliant JSON in your responses.',
|
|
197
|
+
'Your entire response should be a map where the key is the type and the value is a single array of JSON objects conforming to the following types:',
|
|
198
|
+
'',
|
|
199
|
+
'{contact}',
|
|
200
|
+
'{company}',
|
|
201
|
+
'',
|
|
202
|
+
'---',
|
|
203
|
+
'',
|
|
204
|
+
'{input}',
|
|
205
|
+
),
|
|
206
|
+
inputs: [
|
|
207
|
+
{
|
|
208
|
+
type: ChainInputType.SCHEMA,
|
|
209
|
+
name: 'contact',
|
|
210
|
+
value: 'example.com/type/contact',
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
type: ChainInputType.SCHEMA,
|
|
214
|
+
name: 'company',
|
|
215
|
+
value: 'example.com/type/organization',
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
type: ChainInputType.CONTEXT,
|
|
219
|
+
name: 'input',
|
|
220
|
+
value: 'text',
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
}),
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
id: 'dxos.org/prompt/discord',
|
|
227
|
+
title: 'Summarize',
|
|
228
|
+
createPrompt: () =>
|
|
229
|
+
create(ChainPromptType, {
|
|
230
|
+
command: 'summarize',
|
|
231
|
+
template: str(
|
|
232
|
+
// prettier-ignore
|
|
233
|
+
'Summarize what the team is working on and format it as a markdown table without any explanation.',
|
|
234
|
+
'',
|
|
235
|
+
'---',
|
|
236
|
+
'',
|
|
237
|
+
'{context}',
|
|
238
|
+
),
|
|
239
|
+
inputs: [
|
|
240
|
+
{
|
|
241
|
+
type: ChainInputType.RESOLVER,
|
|
242
|
+
name: 'context',
|
|
243
|
+
value: 'discord.messages.recent',
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
}),
|
|
247
|
+
},
|
|
248
|
+
];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { AUTOMATION_PLUGIN } from './meta';
|
|
6
|
+
|
|
7
|
+
export default [
|
|
8
|
+
{
|
|
9
|
+
'en-US': {
|
|
10
|
+
[AUTOMATION_PLUGIN]: {
|
|
11
|
+
'plugin name': 'Automation',
|
|
12
|
+
'object placeholder': 'New prompt',
|
|
13
|
+
'create object label': 'Create prompt',
|
|
14
|
+
'create trigger label': 'Create trigger',
|
|
15
|
+
'create stack section label': 'Create prompt',
|
|
16
|
+
'command placeholder': 'Enter slash command...',
|
|
17
|
+
'template placeholder': 'Enter template...',
|
|
18
|
+
'value placeholder': 'Enter value...',
|
|
19
|
+
'select preset template placeholder': 'Select preset',
|
|
20
|
+
|
|
21
|
+
// 'create object label': 'Create rule',
|
|
22
|
+
// 'create stack section label': 'Create rule',
|
|
23
|
+
// 'command placeholder': 'Enter command...',
|
|
24
|
+
// 'template placeholder': 'Enter template...',
|
|
25
|
+
// 'value placeholder': 'Enter value...',
|
|
26
|
+
// 'select preset template placeholder': 'Select preset',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { ref, S, TypedObject } from '@dxos/echo-schema';
|
|
6
|
+
|
|
7
|
+
// TODO(burdon): Change to S.Literal (and discriminated union).
|
|
8
|
+
export enum ChainInputType {
|
|
9
|
+
VALUE = 0,
|
|
10
|
+
PASS_THROUGH = 1,
|
|
11
|
+
RETRIEVER = 2,
|
|
12
|
+
FUNCTION = 3,
|
|
13
|
+
QUERY = 4,
|
|
14
|
+
RESOLVER = 5,
|
|
15
|
+
CONTEXT = 6,
|
|
16
|
+
SCHEMA = 7,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const ChainInputSchema = S.mutable(
|
|
20
|
+
S.Struct({
|
|
21
|
+
name: S.String,
|
|
22
|
+
type: S.optional(S.Enums(ChainInputType)),
|
|
23
|
+
value: S.optional(S.String),
|
|
24
|
+
}),
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export type ChainInput = S.Schema.Type<typeof ChainInputSchema>;
|
|
28
|
+
|
|
29
|
+
export class ChainPromptType extends TypedObject({ typename: 'dxos.org/type/ChainPrompt', version: '0.1.0' })({
|
|
30
|
+
command: S.optional(S.String),
|
|
31
|
+
template: S.String,
|
|
32
|
+
inputs: S.optional(S.mutable(S.Array(ChainInputSchema))),
|
|
33
|
+
}) {}
|
|
34
|
+
|
|
35
|
+
export class ChainType extends TypedObject({ typename: 'dxos.org/type/Chain', version: '0.1.0' })({
|
|
36
|
+
name: S.optional(S.String),
|
|
37
|
+
prompts: S.optional(S.mutable(S.Array(ref(ChainPromptType)))),
|
|
38
|
+
}) {}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
GraphBuilderProvides,
|
|
7
|
+
IntentResolverProvides,
|
|
8
|
+
MetadataRecordsProvides,
|
|
9
|
+
SurfaceProvides,
|
|
10
|
+
TranslationsProvides,
|
|
11
|
+
} from '@dxos/app-framework';
|
|
12
|
+
import { type SchemaProvides } from '@dxos/plugin-client';
|
|
13
|
+
|
|
14
|
+
import { AUTOMATION_PLUGIN } from '../meta';
|
|
15
|
+
|
|
16
|
+
const AUTOMATION_ACTION = `${AUTOMATION_PLUGIN}/action`;
|
|
17
|
+
|
|
18
|
+
export enum AutomationAction {
|
|
19
|
+
CREATE = `${AUTOMATION_ACTION}/create`,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type AutomationPluginProvides = SurfaceProvides &
|
|
23
|
+
IntentResolverProvides &
|
|
24
|
+
MetadataRecordsProvides &
|
|
25
|
+
TranslationsProvides &
|
|
26
|
+
GraphBuilderProvides &
|
|
27
|
+
SchemaProvides;
|