dirac-lang 0.1.23 → 0.1.25
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/dist/{chunk-APWJJXNI.js → chunk-7OUYWIZV.js} +55 -14
- package/dist/{chunk-RGS2XK6T.js → chunk-OUMUIBK3.js} +1 -1
- package/dist/cli.js +15 -3
- package/dist/index.js +2 -2
- package/dist/{interpreter-UZDVASAW.js → interpreter-MTIIHIIQ.js} +1 -1
- package/dist/test-runner.js +1 -1
- package/lib/index.di +9 -0
- package/package.json +13 -1
- package/.env.example +0 -8
- package/COMMUNITY.md +0 -465
- package/CONDITIONAL-TAGS.md +0 -172
- package/EXCEPTION-HANDLING.md +0 -156
- package/LIBRARIES.md +0 -172
- package/LLM-VALIDATION.md +0 -128
- package/NAMESPACES.md +0 -366
- package/PROMOTION.md +0 -257
- package/QUICKSTART-LIBRARY.md +0 -93
- package/TEST-COVERAGE.md +0 -113
- package/TESTING.md +0 -162
- package/config.test.yml +0 -5
- package/dirac-http/examples/demo.di +0 -9
- package/dirac-http/lib/index.di +0 -12
- package/examples/add-demo.di +0 -74
- package/examples/add.bk +0 -11
- package/examples/advanced-math-demo.di +0 -53
- package/examples/calculator.di +0 -32
- package/examples/compact-test.di +0 -6
- package/examples/comprehensive.bk +0 -29
- package/examples/defvar-variable-demo.di +0 -18
- package/examples/direct-call.di +0 -17
- package/examples/disk-analysis.di +0 -16
- package/examples/exception-demo.di +0 -82
- package/examples/executable-hello.di +0 -7
- package/examples/execute-demo.di +0 -38
- package/examples/file-manager.di +0 -77
- package/examples/file-stats.di +0 -18
- package/examples/hello.bk +0 -1
- package/examples/hello.di +0 -5
- package/examples/if-comparison.di +0 -91
- package/examples/if-cstyle-test.di +0 -149
- package/examples/if-vs-testif.di +0 -56
- package/examples/import-demo.di +0 -31
- package/examples/inline-test.bk +0 -7
- package/examples/llm-agent.di +0 -32
- package/examples/llm-basic.di +0 -12
- package/examples/llm-command-more.di +0 -6
- package/examples/llm-command-no-exec.di +0 -13
- package/examples/llm-command.di +0 -6
- package/examples/llm-complex.di +0 -141
- package/examples/llm-feedback-debug.di +0 -30
- package/examples/llm-feedback-demo.di +0 -19
- package/examples/llm-feedback-math.di +0 -22
- package/examples/llm-feedback-simple.di +0 -16
- package/examples/llm-feedback-sub.di +0 -22
- package/examples/llm-no-feedback.di +0 -10
- package/examples/llm-recursive.di +0 -31
- package/examples/llm-reflection-test.di +0 -19
- package/examples/llm-simple-test.di +0 -12
- package/examples/llm-subs.di +0 -132
- package/examples/llm-use-subs.di +0 -6
- package/examples/llm-validate-test.di +0 -18
- package/examples/loop.di +0 -12
- package/examples/math-test.di +0 -22
- package/examples/minimal-test.di +0 -13
- package/examples/mongodb-context-test.di +0 -27
- package/examples/mongodb-count-events.di +0 -8
- package/examples/mongodb-import-demo.di +0 -25
- package/examples/mongodb-simple-test.di +0 -18
- package/examples/nl-agent.di +0 -47
- package/examples/parameters-demo.di +0 -68
- package/examples/params-meta-test.di +0 -17
- package/examples/params-test.di +0 -10
- package/examples/recipe-chain.di +0 -38
- package/examples/recursive-llm.di +0 -44
- package/examples/sample-library/README.md +0 -152
- package/examples/sample-library/examples/demo.di +0 -34
- package/examples/sample-library/lib/index.di +0 -65
- package/examples/sample-library/package.json +0 -31
- package/examples/scope-test-nested.di +0 -60
- package/examples/scope-test.di +0 -55
- package/examples/seamless.di +0 -45
- package/examples/shell-test.bk +0 -10
- package/examples/simple-import.di +0 -13
- package/examples/simple-recursive.di +0 -26
- package/examples/story-builder.di +0 -45
- package/examples/subroutine.di +0 -23
- package/examples/system-llm.di +0 -21
- package/examples/system-simple.di +0 -3
- package/examples/system-test.di +0 -8
- package/examples/tag-check-test.di +0 -139
- package/examples/task-assistant.di +0 -27
- package/examples/test-if-demo.di +0 -110
- package/examples/test-parameters.di +0 -50
- package/examples/try-catch-test.di +0 -118
- package/examples/two-styles.di +0 -28
- package/examples/var-debug.di +0 -6
- package/examples/var-inline.di +0 -4
- package/examples/var-test2.di +0 -6
- package/examples/variable-replace.di +0 -25
- package/examples/variable-simple.di +0 -16
- package/examples/variable-test.di +0 -22
- package/examples/whitespace-test.di +0 -24
- package/filePath +0 -1
- package/greeting.txt +0 -1
- package/src/cli.ts +0 -140
- package/src/index.ts +0 -33
- package/src/llm/ollama.ts +0 -58
- package/src/runtime/braket-parser.ts +0 -234
- package/src/runtime/interpreter.ts +0 -203
- package/src/runtime/parser.ts +0 -155
- package/src/runtime/session.ts +0 -325
- package/src/tags/assign.ts +0 -37
- package/src/tags/attr.ts +0 -64
- package/src/tags/available-subroutines.ts +0 -70
- package/src/tags/call.ts +0 -259
- package/src/tags/catch.ts +0 -24
- package/src/tags/defvar.ts +0 -115
- package/src/tags/environment.ts +0 -21
- package/src/tags/eval.ts +0 -71
- package/src/tags/exception.ts +0 -20
- package/src/tags/execute.ts +0 -52
- package/src/tags/expr.ts +0 -128
- package/src/tags/foreach.ts +0 -170
- package/src/tags/if.ts +0 -191
- package/src/tags/import.ts +0 -66
- package/src/tags/index.ts +0 -41
- package/src/tags/input.ts +0 -182
- package/src/tags/llm.ts +0 -415
- package/src/tags/loop.ts +0 -43
- package/src/tags/mongodb.ts +0 -70
- package/src/tags/output.ts +0 -53
- package/src/tags/parameters.ts +0 -81
- package/src/tags/require_module.ts +0 -19
- package/src/tags/subroutine.ts +0 -75
- package/src/tags/system.ts +0 -93
- package/src/tags/tag-check.ts +0 -176
- package/src/tags/test-if.ts +0 -112
- package/src/tags/throw.ts +0 -26
- package/src/tags/try.ts +0 -19
- package/src/tags/variable.ts +0 -25
- package/src/test-runner.ts +0 -300
- package/src/types/index.ts +0 -128
- package/src/utils/llm-adapter.ts +0 -113
- package/src/utils/tag-validator.ts +0 -231
- package/test-available-extends.di +0 -28
- package/test-available-simple.di +0 -12
- package/test-available-subroutines.di +0 -16
- package/test-call.di +0 -9
- package/test-extend-basic.di +0 -17
- package/test-extend-chain.di +0 -26
- package/test-extend-debug.di +0 -17
- package/test-extend-debug2.di +0 -15
- package/test-extend-person.di +0 -17
- package/test-extend-simple.di +0 -11
- package/test-extend-zhi.di +0 -23
- package/test-extend.di +0 -19
- package/test-extend2.di +0 -26
- package/test-extend3-fixed.di +0 -23
- package/test-extend3-trouble.di +0 -23
- package/test-extend3.di +0 -21
- package/test-factorial.di +0 -19
- package/test-input-debug.di +0 -19
- package/test-nested-debug.di +0 -7
- package/test-nested-debug2.di +0 -8
- package/test-no-extend.di +0 -16
- package/test-simple-call.di +0 -7
- package/test-simple.di +0 -6
- package/tests/README.md +0 -69
- package/tests/assign-basic.test.di +0 -7
- package/tests/assign-from-eval.test.di +0 -7
- package/tests/available-subroutines-foreach.test.di +0 -32
- package/tests/basic-output.test.di +0 -5
- package/tests/call-basic.test.di +0 -11
- package/tests/call-with-output.test.di +0 -10
- package/tests/comments-before-content.test.di +0 -6
- package/tests/defvar-multiple.test.di +0 -8
- package/tests/environment-basic.test.di +0 -22
- package/tests/environment-nonexistent.test.di +0 -5
- package/tests/environment-with-defvar.test.di +0 -15
- package/tests/eval-basic.test.di +0 -6
- package/tests/eval-with-variables.test.di +0 -8
- package/tests/exception-basic.test.di +0 -10
- package/tests/expr-basic.test.di +0 -11
- package/tests/extend-basic.test.di +0 -19
- package/tests/extend-inheritance-chain.test.di +0 -26
- package/tests/extend-multiple-nested.test.di +0 -24
- package/tests/extend-self.test.di +0 -19
- package/tests/extend-with-parameters.test.di +0 -14
- package/tests/generate-dirac.test.di +0 -22
- package/tests/if-conditional.test.di +0 -17
- package/tests/if-else.test.di +0 -11
- package/tests/if-with-variables.test.di +0 -8
- package/tests/import-basic.test.di +0 -6
- package/tests/input-file-all.test.di +0 -5
- package/tests/input-file-line.test.di +0 -15
- package/tests/input-file-loop.test.di +0 -12
- package/tests/input-stdin-all.test.di +0 -8
- package/tests/input-stdin-all.txt +0 -1
- package/tests/llm-validate.test.di +0 -17
- package/tests/loop-basic.test.di +0 -9
- package/tests/loop-nested.test.di +0 -10
- package/tests/loop-with-eval.test.di +0 -8
- package/tests/no-root-element.test.di +0 -6
- package/tests/output-file.test.di +0 -19
- package/tests/output-multiple.test.di +0 -9
- package/tests/parameters-basic.test.di +0 -6
- package/tests/require-module-basic.test.di +0 -7
- package/tests/subroutine-basic.test.di +0 -9
- package/tests/subroutine-multiple-params.test.di +0 -10
- package/tests/subroutine-nested-calls.test.di +0 -32
- package/tests/subroutine-sequential-calls.test.di +0 -36
- package/tests/system-background.test.di +0 -39
- package/tests/system-basic.test.di +0 -5
- package/tests/tag-check.test.di +0 -27
- package/tests/test-if-basic.test.di +0 -8
- package/tests/test-input.txt +0 -3
- package/tests/try-catch-basic.test.di +0 -10
- package/tests/try-catch-eval-error.test.di +0 -10
- package/tests/variable-basic.test.di +0 -6
- package/tests/variable-interpolation.test.di +0 -7
- package/tools/create-library.sh +0 -175
- package/tsconfig.json +0 -19
- /package/{examples/lib → lib}/advanced-math.di +0 -0
- /package/{examples/lib → lib}/fileops.di +0 -0
- /package/{examples/lib → lib}/math.di +0 -0
- /package/{examples/lib → lib}/mongodb.di +0 -0
package/examples/llm-complex.di
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
<dirac>
|
|
2
|
-
<!-- UI Control Services -->
|
|
3
|
-
<!-- These subroutines are exposed as natural language endpoints -->
|
|
4
|
-
|
|
5
|
-
<subroutine name="background"
|
|
6
|
-
description="Change the background color, do not generate other tags like <changeBackground /> use precise tag"
|
|
7
|
-
param-color="string:required:Background color:red|blue|green|yellow|orange|purple|pink|white|black">
|
|
8
|
-
<parameters select="@color"/>
|
|
9
|
-
|
|
10
|
-
<eval>
|
|
11
|
-
console.log('Changing background color to: ' + color);
|
|
12
|
-
</eval>
|
|
13
|
-
</subroutine>
|
|
14
|
-
|
|
15
|
-
<subroutine name="set-text-size"
|
|
16
|
-
description="Adjust the text size"
|
|
17
|
-
param-size="string:required:Font size:12px|14px|16px|18px|20px|24px">
|
|
18
|
-
<parameters select="@size" />
|
|
19
|
-
<eval>
|
|
20
|
-
console.log("change text size to "+size );
|
|
21
|
-
document.body.style.fontSize = '${size}';
|
|
22
|
-
</eval>
|
|
23
|
-
</subroutine>
|
|
24
|
-
|
|
25
|
-
<subroutine name="reset-styles"
|
|
26
|
-
description="Reset all styles to default">
|
|
27
|
-
<eval>
|
|
28
|
-
console.log("reset all styles back");
|
|
29
|
-
document.body.style.backgroundColor = 'white';
|
|
30
|
-
document.body.style.fontSize = '16px';
|
|
31
|
-
</eval>
|
|
32
|
-
</subroutine>
|
|
33
|
-
|
|
34
|
-
<subroutine name="text-color"
|
|
35
|
-
description="Change the text color"
|
|
36
|
-
param-color="string:required:Text color:black|white|red|blue|green">
|
|
37
|
-
<parameters select="@color" />
|
|
38
|
-
<eval>
|
|
39
|
-
console.log("change color of text to "+color);
|
|
40
|
-
document.body.style.color = '${color}';
|
|
41
|
-
</eval>
|
|
42
|
-
</subroutine>
|
|
43
|
-
|
|
44
|
-
<!-- Event Generation Examples -->
|
|
45
|
-
|
|
46
|
-
<subroutine name="click-button"
|
|
47
|
-
description="Simulate clicking a button"
|
|
48
|
-
param-selector="string:optional:CSS selector (default: #submit-button)">
|
|
49
|
-
<eval>
|
|
50
|
-
const selector = '${selector}' || '#submit-button';
|
|
51
|
-
const element = document.querySelector(selector);
|
|
52
|
-
if (element) {
|
|
53
|
-
const clickEvent = new MouseEvent('click', {
|
|
54
|
-
bubbles: true,
|
|
55
|
-
cancelable: true,
|
|
56
|
-
view: window
|
|
57
|
-
});
|
|
58
|
-
element.dispatchEvent(clickEvent);
|
|
59
|
-
} else {
|
|
60
|
-
throw new Error('Element not found: ' + selector);
|
|
61
|
-
}
|
|
62
|
-
</eval>
|
|
63
|
-
</subroutine>
|
|
64
|
-
|
|
65
|
-
<subroutine name="type-text"
|
|
66
|
-
description="Type text into an input field"
|
|
67
|
-
param-text="string:required:Text to type"
|
|
68
|
-
param-field="string:optional:Which field:name|email">
|
|
69
|
-
<parameters select="@text" />
|
|
70
|
-
<parameters select="@field" />
|
|
71
|
-
<eval>
|
|
72
|
-
const _field = typeof field !== 'undefined' && field ? field : 'name';
|
|
73
|
-
const selector = _field === 'email' ? '#email-input' : '#name-input';
|
|
74
|
-
const input = document.querySelector(selector);
|
|
75
|
-
if (input) {
|
|
76
|
-
input.value = text;
|
|
77
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
78
|
-
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
79
|
-
} else {
|
|
80
|
-
throw new Error('Input not found: ' + selector);
|
|
81
|
-
}
|
|
82
|
-
</eval>
|
|
83
|
-
</subroutine>
|
|
84
|
-
|
|
85
|
-
<subroutine name="check-terms"
|
|
86
|
-
description="Check or uncheck the terms checkbox"
|
|
87
|
-
param-checked="string:optional:Check state:true|false">
|
|
88
|
-
<eval>
|
|
89
|
-
const shouldCheck = '${checked}' !== 'false';
|
|
90
|
-
const checkbox = document.querySelector('#terms-checkbox');
|
|
91
|
-
if (checkbox) {
|
|
92
|
-
checkbox.checked = shouldCheck;
|
|
93
|
-
checkbox.dispatchEvent(new Event('change', { bubbles: true }));
|
|
94
|
-
} else {
|
|
95
|
-
throw new Error('Checkbox not found');
|
|
96
|
-
}
|
|
97
|
-
</eval>
|
|
98
|
-
</subroutine>
|
|
99
|
-
|
|
100
|
-
<subroutine name="clear-input"
|
|
101
|
-
description="Clear an input field"
|
|
102
|
-
param-field="string:optional:Which field:name|email">
|
|
103
|
-
<eval>
|
|
104
|
-
const field = '${field}' || 'name';
|
|
105
|
-
const selector = field === 'email' ? '#email-input' : '#name-input';
|
|
106
|
-
const input = document.querySelector(selector);
|
|
107
|
-
if (input) {
|
|
108
|
-
input.value = '';
|
|
109
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
110
|
-
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
111
|
-
} else {
|
|
112
|
-
throw new Error('Input not found: ' + selector);
|
|
113
|
-
}
|
|
114
|
-
</eval>
|
|
115
|
-
</subroutine>
|
|
116
|
-
|
|
117
|
-
<!--
|
|
118
|
-
<subroutine name="modify-file"
|
|
119
|
-
description="modify a file based on pattern and replacement field "
|
|
120
|
-
param-filename="string|required"
|
|
121
|
-
param-pattern="string|required"
|
|
122
|
-
param-replace="string|required"
|
|
123
|
-
>
|
|
124
|
-
<parameters select="@filename" />
|
|
125
|
-
<parameters select="@pattern" />
|
|
126
|
-
<parameters select="@replace" />
|
|
127
|
-
<system>
|
|
128
|
-
sed -e 's/${pattern}/${replace}/g' ${filename}
|
|
129
|
-
</system>
|
|
130
|
-
</subroutine>
|
|
131
|
-
-->
|
|
132
|
-
|
|
133
|
-
<llm noextra="true" execute="false">
|
|
134
|
-
<system>
|
|
135
|
-
ls -tl
|
|
136
|
-
</system>
|
|
137
|
-
find me the file with name hello.di and modify the pattern of World with Zhi
|
|
138
|
-
use the command <modify-file I listed to do this.
|
|
139
|
-
</llm>
|
|
140
|
-
|
|
141
|
-
</dirac>
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env dirac
|
|
2
|
-
<!-- Test: Feedback with math calculation - DEBUG VERSION -->
|
|
3
|
-
|
|
4
|
-
<dirac>
|
|
5
|
-
<subroutine name="add" description="addition of two numbers" param-a="number:required:first argument::2" param-b="number:required:second argument::3">
|
|
6
|
-
<output>DEBUG: a=<variable name="a" />, b=<variable name="b" />
|
|
7
|
-
</output>
|
|
8
|
-
<expr eval="plus">
|
|
9
|
-
<arg><variable name="a" /></arg>
|
|
10
|
-
<arg><variable name="b" /></arg>
|
|
11
|
-
</expr>
|
|
12
|
-
</subroutine>
|
|
13
|
-
|
|
14
|
-
<llm
|
|
15
|
-
execute="true"
|
|
16
|
-
feedback="true"
|
|
17
|
-
autocorrect="true"
|
|
18
|
-
max-iterations="3"
|
|
19
|
-
replace-tick="true"
|
|
20
|
-
output-var="generated_code">
|
|
21
|
-
Calculate 5 + 3 using the add subroutine and display the result.
|
|
22
|
-
</llm>
|
|
23
|
-
|
|
24
|
-
<output>
|
|
25
|
-
|
|
26
|
-
Generated code was:
|
|
27
|
-
<variable name="generated_code" />
|
|
28
|
-
</output>
|
|
29
|
-
|
|
30
|
-
</dirac>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env dirac
|
|
2
|
-
<!-- Test: LLM feedback mode
|
|
3
|
-
Description: Test the feedback loop where LLM generates code, sees output, and can iterate
|
|
4
|
-
Expected: Should output "Hello from feedback loop!" and eventually say "DONE"
|
|
5
|
-
-->
|
|
6
|
-
|
|
7
|
-
<dirac>
|
|
8
|
-
<llm
|
|
9
|
-
execute="true"
|
|
10
|
-
feedback="true"
|
|
11
|
-
max-iterations="2"
|
|
12
|
-
validate="true"
|
|
13
|
-
autocorrect="true"
|
|
14
|
-
max-retries="2"
|
|
15
|
-
replace-tick="true"
|
|
16
|
-
no-extra="true">
|
|
17
|
-
Use the output tag to print "Hello from feedback loop!"
|
|
18
|
-
</llm>
|
|
19
|
-
</dirac>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env dirac
|
|
2
|
-
<!-- Test: Feedback with math calculation -->
|
|
3
|
-
|
|
4
|
-
<dirac>
|
|
5
|
-
<subroutine name="add" description="addition of two numbers " param-a="number:required:first argument::1st arg" param-b="number:required:second argument::2nd arg">
|
|
6
|
-
<expr eval="plus">
|
|
7
|
-
<arg><variable name="a" /></arg>
|
|
8
|
-
<arg><variable name="b" /></arg>
|
|
9
|
-
</expr>
|
|
10
|
-
</subroutine>
|
|
11
|
-
|
|
12
|
-
<llm
|
|
13
|
-
execute="true"
|
|
14
|
-
feedback="true"
|
|
15
|
-
validate="true"
|
|
16
|
-
autocorrect="true"
|
|
17
|
-
max-iterations="3"
|
|
18
|
-
replace-tick="true">
|
|
19
|
-
Calculate 5 + 3 using the add subroutine and display the result.
|
|
20
|
-
</llm>
|
|
21
|
-
|
|
22
|
-
</dirac>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env dirac
|
|
2
|
-
<!-- Test: Simple feedback mode without validation -->
|
|
3
|
-
|
|
4
|
-
<dirac>
|
|
5
|
-
<subroutine name="greet" param-name="string">
|
|
6
|
-
<output>Hello, <variable name="name" />!</output>
|
|
7
|
-
</subroutine>
|
|
8
|
-
|
|
9
|
-
<llm
|
|
10
|
-
execute="true"
|
|
11
|
-
feedback="true"
|
|
12
|
-
max-iterations="2"
|
|
13
|
-
replace-tick="true">
|
|
14
|
-
Call greet with name="Feedback Test"
|
|
15
|
-
</llm>
|
|
16
|
-
</dirac>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env dirac
|
|
2
|
-
<!-- Test: LLM feedback mode with subroutine
|
|
3
|
-
Description: Test feedback loop with a simple subroutine
|
|
4
|
-
Expected: Should call print-message and see the feedback loop work
|
|
5
|
-
-->
|
|
6
|
-
|
|
7
|
-
<dirac>
|
|
8
|
-
<subroutine name="print-message" param-text="string">
|
|
9
|
-
<output><variable name="text" /></output>
|
|
10
|
-
</subroutine>
|
|
11
|
-
|
|
12
|
-
<llm
|
|
13
|
-
execute="true"
|
|
14
|
-
feedback="true"
|
|
15
|
-
max-iterations="2"
|
|
16
|
-
validate="true"
|
|
17
|
-
autocorrect="true"
|
|
18
|
-
max-retries="2"
|
|
19
|
-
replace-tick="true">
|
|
20
|
-
Call print-message with text="Hello from feedback loop!"
|
|
21
|
-
</llm>
|
|
22
|
-
</dirac>
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
<!-- Recursive LLM - LLM calling Dirac calling LLM -->
|
|
2
|
-
<dirac>
|
|
3
|
-
<!-- Define a subroutine that gets stock info -->
|
|
4
|
-
<subroutine name="getStockPrice">
|
|
5
|
-
<parameters>
|
|
6
|
-
<variable name="symbol" passby="value" />
|
|
7
|
-
</parameters>
|
|
8
|
-
|
|
9
|
-
<LLM output="price" maxTokens="50">
|
|
10
|
-
What is the current approximate stock price of ${symbol}?
|
|
11
|
-
Respond with just a number (e.g., "150.23").
|
|
12
|
-
</LLM>
|
|
13
|
-
|
|
14
|
-
<output>${symbol}: $${price}</output>
|
|
15
|
-
</subroutine>
|
|
16
|
-
|
|
17
|
-
<!-- LLM decides which stocks to check -->
|
|
18
|
-
<LLM output="response">
|
|
19
|
-
List 3 major tech stocks to check, one per line.
|
|
20
|
-
Format: SYMBOL only (e.g., "AAPL")
|
|
21
|
-
</LLM>
|
|
22
|
-
|
|
23
|
-
<output>Checking stocks from LLM: ${response} </output>
|
|
24
|
-
|
|
25
|
-
<!-- In the future, this could parse ${response} and call getStockPrice for each -->
|
|
26
|
-
<call name="getStockPrice">
|
|
27
|
-
<parameters>
|
|
28
|
-
<variable value="AAPL" />
|
|
29
|
-
</parameters>
|
|
30
|
-
</call>
|
|
31
|
-
</dirac>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<dirac>
|
|
2
|
-
<subroutine name="inventory" description="Show you the inventory" >
|
|
3
|
-
you have reachded the inventory
|
|
4
|
-
</subroutine>
|
|
5
|
-
|
|
6
|
-
<subroutine name="order" description="Places an order for an item." param-item="string:required:Item name" param-quantity="number:required:Quantity">
|
|
7
|
-
<parameters select="@item"/>
|
|
8
|
-
<parameters select="@quantity"/>
|
|
9
|
-
<output>
|
|
10
|
-
this is my item: <variable name="item" />
|
|
11
|
-
and <variable name="quantity" />
|
|
12
|
-
</output>
|
|
13
|
-
</subroutine>
|
|
14
|
-
|
|
15
|
-
<llm execute="true">Show me my inventory</llm>
|
|
16
|
-
<llm execute="true">Order 2 apples</llm>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
</dirac>
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<dirac>
|
|
2
|
-
<defvar name="topic" value="test" />
|
|
3
|
-
<output>Topic is: <variable name="topic" /></output>
|
|
4
|
-
<output> </output>
|
|
5
|
-
|
|
6
|
-
<LLM output="response" maxTokens="50" noextra="true">
|
|
7
|
-
Say hello
|
|
8
|
-
</LLM>
|
|
9
|
-
|
|
10
|
-
<output>Response: <variable name="response" /></output>
|
|
11
|
-
<output> </output>
|
|
12
|
-
</dirac>
|
package/examples/llm-subs.di
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
<dirac>
|
|
2
|
-
<!-- UI Control Services -->
|
|
3
|
-
<!-- These subroutines are exposed as natural language endpoints -->
|
|
4
|
-
|
|
5
|
-
<subroutine name="background"
|
|
6
|
-
description="Change the background color, do not generate other tags like <changeBackground /> use precise tag"
|
|
7
|
-
param-color="string:required:Background color:red|blue|green|yellow|orange|purple|pink|white|black">
|
|
8
|
-
<parameters select="@color"/>
|
|
9
|
-
|
|
10
|
-
<eval>
|
|
11
|
-
console.log('Changing background color to: ' + color);
|
|
12
|
-
</eval>
|
|
13
|
-
</subroutine>
|
|
14
|
-
|
|
15
|
-
<subroutine name="set-text-size"
|
|
16
|
-
description="Adjust the text size"
|
|
17
|
-
param-size="string:required:Font size:12px|14px|16px|18px|20px|24px">
|
|
18
|
-
<parameters select="@size" />
|
|
19
|
-
<eval>
|
|
20
|
-
console.log("change text size to "+size );
|
|
21
|
-
document.body.style.fontSize = '${size}';
|
|
22
|
-
</eval>
|
|
23
|
-
</subroutine>
|
|
24
|
-
|
|
25
|
-
<subroutine name="reset-styles"
|
|
26
|
-
description="Reset all styles to default">
|
|
27
|
-
<eval>
|
|
28
|
-
console.log("reset all styles back");
|
|
29
|
-
document.body.style.backgroundColor = 'white';
|
|
30
|
-
document.body.style.fontSize = '16px';
|
|
31
|
-
</eval>
|
|
32
|
-
</subroutine>
|
|
33
|
-
|
|
34
|
-
<subroutine name="text-color"
|
|
35
|
-
description="Change the text color"
|
|
36
|
-
param-color="string:required:Text color:black|white|red|blue|green">
|
|
37
|
-
<parameters select="@color" />
|
|
38
|
-
<eval>
|
|
39
|
-
console.log("change color of text to "+color);
|
|
40
|
-
document.body.style.color = '${color}';
|
|
41
|
-
</eval>
|
|
42
|
-
</subroutine>
|
|
43
|
-
|
|
44
|
-
<!-- Event Generation Examples -->
|
|
45
|
-
|
|
46
|
-
<subroutine name="click-button"
|
|
47
|
-
description="Simulate clicking a button"
|
|
48
|
-
param-selector="string:optional:CSS selector (default: #submit-button)">
|
|
49
|
-
<eval>
|
|
50
|
-
const selector = '${selector}' || '#submit-button';
|
|
51
|
-
const element = document.querySelector(selector);
|
|
52
|
-
if (element) {
|
|
53
|
-
const clickEvent = new MouseEvent('click', {
|
|
54
|
-
bubbles: true,
|
|
55
|
-
cancelable: true,
|
|
56
|
-
view: window
|
|
57
|
-
});
|
|
58
|
-
element.dispatchEvent(clickEvent);
|
|
59
|
-
} else {
|
|
60
|
-
throw new Error('Element not found: ' + selector);
|
|
61
|
-
}
|
|
62
|
-
</eval>
|
|
63
|
-
</subroutine>
|
|
64
|
-
|
|
65
|
-
<subroutine name="type-text"
|
|
66
|
-
description="Type text into an input field"
|
|
67
|
-
param-text="string:required:Text to type"
|
|
68
|
-
param-field="string:optional:Which field:name|email">
|
|
69
|
-
<parameters select="@text" />
|
|
70
|
-
<parameters select="@field" />
|
|
71
|
-
<eval>
|
|
72
|
-
const _field = typeof field !== 'undefined' && field ? field : 'name';
|
|
73
|
-
const selector = _field === 'email' ? '#email-input' : '#name-input';
|
|
74
|
-
const input = document.querySelector(selector);
|
|
75
|
-
if (input) {
|
|
76
|
-
input.value = text;
|
|
77
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
78
|
-
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
79
|
-
} else {
|
|
80
|
-
throw new Error('Input not found: ' + selector);
|
|
81
|
-
}
|
|
82
|
-
</eval>
|
|
83
|
-
</subroutine>
|
|
84
|
-
|
|
85
|
-
<subroutine name="check-terms"
|
|
86
|
-
description="Check or uncheck the terms checkbox"
|
|
87
|
-
param-checked="string:optional:Check state:true|false">
|
|
88
|
-
<eval>
|
|
89
|
-
const shouldCheck = '${checked}' !== 'false';
|
|
90
|
-
const checkbox = document.querySelector('#terms-checkbox');
|
|
91
|
-
if (checkbox) {
|
|
92
|
-
checkbox.checked = shouldCheck;
|
|
93
|
-
checkbox.dispatchEvent(new Event('change', { bubbles: true }));
|
|
94
|
-
} else {
|
|
95
|
-
throw new Error('Checkbox not found');
|
|
96
|
-
}
|
|
97
|
-
</eval>
|
|
98
|
-
</subroutine>
|
|
99
|
-
|
|
100
|
-
<subroutine name="clear-input"
|
|
101
|
-
description="Clear an input field"
|
|
102
|
-
param-field="string:optional:Which field:name|email">
|
|
103
|
-
<eval>
|
|
104
|
-
const field = '${field}' || 'name';
|
|
105
|
-
const selector = field === 'email' ? '#email-input' : '#name-input';
|
|
106
|
-
const input = document.querySelector(selector);
|
|
107
|
-
if (input) {
|
|
108
|
-
input.value = '';
|
|
109
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
110
|
-
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
111
|
-
} else {
|
|
112
|
-
throw new Error('Input not found: ' + selector);
|
|
113
|
-
}
|
|
114
|
-
</eval>
|
|
115
|
-
</subroutine>
|
|
116
|
-
|
|
117
|
-
<!--
|
|
118
|
-
<subroutine name="modify-file"
|
|
119
|
-
description="modify a file based on pattern and replacement field "
|
|
120
|
-
param-filename="string|required"
|
|
121
|
-
param-pattern="string|required"
|
|
122
|
-
param-replace="string|required"
|
|
123
|
-
>
|
|
124
|
-
<parameters select="@filename" />
|
|
125
|
-
<parameters select="@pattern" />
|
|
126
|
-
<parameters select="@replace" />
|
|
127
|
-
<system>
|
|
128
|
-
sed -e 's/${pattern}/${replace}/g' ${filename}
|
|
129
|
-
</system>
|
|
130
|
-
</subroutine>
|
|
131
|
-
-->
|
|
132
|
-
</dirac>
|
package/examples/llm-use-subs.di
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<dirac>
|
|
2
|
-
<subroutine name="greet" description="Greet someone by name" param-name="string:required:The person's name">
|
|
3
|
-
<output>Hello, <variable name="name" />!</output>
|
|
4
|
-
</subroutine>
|
|
5
|
-
|
|
6
|
-
<subroutine name="calculate" description="Calculate a simple math expression" param-expression="string:required:Math expression to calculate">
|
|
7
|
-
<output>Result: <variable name="expression" /></output>
|
|
8
|
-
</subroutine>
|
|
9
|
-
|
|
10
|
-
<output>Testing LLM with tag validation...</output>
|
|
11
|
-
<output> </output>
|
|
12
|
-
|
|
13
|
-
<llm execute="true" validate="true" autocorrect="true" max-retries="2" maxTokens="200">
|
|
14
|
-
Greet the user named Alice
|
|
15
|
-
</llm>
|
|
16
|
-
|
|
17
|
-
<output> </output>
|
|
18
|
-
</dirac>
|
package/examples/loop.di
DELETED
package/examples/math-test.di
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env dirac
|
|
2
|
-
<dirac>
|
|
3
|
-
<import src="./lib/math.di" />
|
|
4
|
-
|
|
5
|
-
<output>Math Library Test </output>
|
|
6
|
-
|
|
7
|
-
<defvar name="x" value="8" />
|
|
8
|
-
<output>Square of ${x}: </output>
|
|
9
|
-
<call name="SQUARE" />
|
|
10
|
-
<output> </output>
|
|
11
|
-
|
|
12
|
-
<defvar name="a" value="15" />
|
|
13
|
-
<defvar name="b" value="25" />
|
|
14
|
-
<output>${a} + ${b} = </output>
|
|
15
|
-
<call name="ADD" />
|
|
16
|
-
<output> </output>
|
|
17
|
-
|
|
18
|
-
<defvar name="num" value="6" />
|
|
19
|
-
<output>Factorial of ${num}: </output>
|
|
20
|
-
<call name="FACTORIAL" />
|
|
21
|
-
<output> </output>
|
|
22
|
-
</dirac>
|
package/examples/minimal-test.di
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env dirac
|
|
2
|
-
<!-- Simple llm context test -->
|
|
3
|
-
<dirac>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<!-- Import the MongoDB extension library -->
|
|
7
|
-
<import src="./lib/mongodb.di" />
|
|
8
|
-
|
|
9
|
-
<defvar name="myllmcontext" />
|
|
10
|
-
|
|
11
|
-
<defvar name="mongo_output" >
|
|
12
|
-
<MONGODB database="betting" collection="events" action="count" >{"type.name":"Pass" }</MONGODB>
|
|
13
|
-
</defvar>
|
|
14
|
-
|
|
15
|
-
<output>I have : <variable name="mongo_output" />: records</output>
|
|
16
|
-
|
|
17
|
-
<llm execute="true" context="myllmcontext"> I have a mongodb, the database name is betting,\n and the collection name is events,
|
|
18
|
-
in the collection there is a field called type.name, can you select the records with type.name as Pass, and limit result to 5. give me the command to retrieve them </llm>
|
|
19
|
-
|
|
20
|
-
The context was used: <variable name="myllmcontext" />
|
|
21
|
-
|
|
22
|
-
<eval name="contextString">
|
|
23
|
-
return JSON.stringify(myllmcontext, null, 2);
|
|
24
|
-
</eval>
|
|
25
|
-
<output>${contextString}</output>
|
|
26
|
-
|
|
27
|
-
</dirac>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env dirac
|
|
2
|
-
<!-- Demo: Using MongoDB extension library -->
|
|
3
|
-
<dirac>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<subroutine name="MONGODB">
|
|
7
|
-
<parameters select="@database" />
|
|
8
|
-
<parameters select="@collection" />
|
|
9
|
-
<defvar name="body"><parameters select="*"/></defvar>
|
|
10
|
-
<!-- <defvar name="body">some body</defvar> -->
|
|
11
|
-
|
|
12
|
-
<output>database is: <variable name="database" /> </output>
|
|
13
|
-
<output>collection is: <variable name="collection" /> </output>
|
|
14
|
-
<output>query is: <variable name="body" /> </output>
|
|
15
|
-
<output>from dirac </output>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
</subroutine>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<MONGODB database="betting" collection="events" action="find">
|
|
22
|
-
hi, this is a test
|
|
23
|
-
</MONGODB>
|
|
24
|
-
|
|
25
|
-
</dirac>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env dirac
|
|
2
|
-
<!-- Simple MongoDB extension test -->
|
|
3
|
-
<dirac>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<!-- Import the MongoDB extension library -->
|
|
7
|
-
<import src="./lib/mongodb.di" />
|
|
8
|
-
|
|
9
|
-
<!--
|
|
10
|
-
<MONGODB database="betting" collection="events" action="find">{ "type.name": "Pass" }</MONGODB>
|
|
11
|
-
-->
|
|
12
|
-
|
|
13
|
-
<output>Testing MongoDB count: </output>
|
|
14
|
-
|
|
15
|
-
<MONGODB database="betting" collection="events" action="count">{ "type.name": "Pass" }</MONGODB>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
</dirac>
|