@goreal-ai/echo-pdk 0.2.2 → 0.2.3
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 +21 -0
- package/README.md +103 -0
- package/package.json +24 -13
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Echo PDK
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# @goreal-ai/echo-pdk
|
|
2
|
+
|
|
3
|
+
**Echo PDK Core** - A Domain Specific Language for dynamic prompt templating.
|
|
4
|
+
|
|
5
|
+
Echo enables developers to write logic directly in prompt templates, rendering only relevant context at runtime. This reduces tokens, cost, and LLM cognitive load.
|
|
6
|
+
|
|
7
|
+
## Why Echo?
|
|
8
|
+
|
|
9
|
+
Traditional LLM development sends "monolithic prompts" containing every possible rule and edge case. Echo solves this by:
|
|
10
|
+
|
|
11
|
+
- **Massive Token Reduction**: Only send relevant context (up to 75% cost savings)
|
|
12
|
+
- **Reduced Cognitive Load**: Sharper LLM focus = higher accuracy
|
|
13
|
+
- **Maintainable Code**: Modular, readable prompts instead of "spaghetti prompts"
|
|
14
|
+
- **Deterministic Control**: Logic lives in code, not AI interpretation
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @goreal-ai/echo-pdk
|
|
20
|
+
# or
|
|
21
|
+
pnpm add @goreal-ai/echo-pdk
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { createEcho } from '@goreal-ai/echo-pdk';
|
|
28
|
+
|
|
29
|
+
const echo = createEcho();
|
|
30
|
+
|
|
31
|
+
const template = `
|
|
32
|
+
Hello {{name}}!
|
|
33
|
+
|
|
34
|
+
[#IF {{role}} #equals(admin)]
|
|
35
|
+
You have full access to all features.
|
|
36
|
+
[ELSE]
|
|
37
|
+
Welcome to our platform.
|
|
38
|
+
[END IF]
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
const result = await echo.render(template, {
|
|
42
|
+
name: 'Alice',
|
|
43
|
+
role: 'admin'
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
console.log(result);
|
|
47
|
+
// Hello Alice!
|
|
48
|
+
// You have full access to all features.
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Syntax Reference
|
|
52
|
+
|
|
53
|
+
### Variables
|
|
54
|
+
```
|
|
55
|
+
{{variable}} # Basic variable
|
|
56
|
+
{{user.name}} # Nested access
|
|
57
|
+
{{value ?? "default"}} # Default value
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Conditionals
|
|
61
|
+
```
|
|
62
|
+
[#IF {{var}} #operator(value)]
|
|
63
|
+
content
|
|
64
|
+
[ELSE IF {{other}} #exists]
|
|
65
|
+
alternative
|
|
66
|
+
[ELSE]
|
|
67
|
+
fallback
|
|
68
|
+
[END IF]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Built-in Operators
|
|
72
|
+
|
|
73
|
+
| Operator | Alias | Description |
|
|
74
|
+
|----------|-------|-------------|
|
|
75
|
+
| `#equals(value)` | - | Exact match |
|
|
76
|
+
| `#contains(value)` | - | String/array contains |
|
|
77
|
+
| `#exists` | - | Variable is defined |
|
|
78
|
+
| `#matches(regex)` | - | Regex pattern match |
|
|
79
|
+
| `#greater_than(n)` | `#gt` | Greater than |
|
|
80
|
+
| `#less_than(n)` | `#lt` | Less than |
|
|
81
|
+
| `#one_of(a,b,c)` | `#in` | Value in list |
|
|
82
|
+
| `#ai_judge(question)` | - | LLM-evaluated condition |
|
|
83
|
+
|
|
84
|
+
### Composition
|
|
85
|
+
```
|
|
86
|
+
[#IMPORT ./sections/header.echo]
|
|
87
|
+
[#INCLUDE system_prompt]
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Related Packages
|
|
91
|
+
|
|
92
|
+
| Package | Description |
|
|
93
|
+
|---------|-------------|
|
|
94
|
+
| [@goreal-ai/echo-pdk-cli](https://www.npmjs.com/package/@goreal-ai/echo-pdk-cli) | Command-line interface |
|
|
95
|
+
| [@goreal-ai/echo-pdk-language](https://www.npmjs.com/package/@goreal-ai/echo-pdk-language) | Language definition and schema |
|
|
96
|
+
|
|
97
|
+
## Documentation
|
|
98
|
+
|
|
99
|
+
Full documentation available at [GitHub](https://github.com/GoReal-AI/echo-pdk)
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goreal-ai/echo-pdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Echo PDK core rendering engine - parser, evaluator, and renderer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -16,18 +16,19 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
|
-
"dist"
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md"
|
|
20
21
|
],
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
"typecheck": "tsc --noEmit",
|
|
29
|
-
"clean": "rm -rf dist"
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/GoReal-AI/echo-pdk.git",
|
|
25
|
+
"directory": "packages/core"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/GoReal-AI/echo-pdk/issues"
|
|
30
29
|
},
|
|
30
|
+
"homepage": "https://github.com/GoReal-AI/echo-pdk#readme",
|
|
31
|
+
"author": "GoReal.AI",
|
|
31
32
|
"dependencies": {
|
|
32
33
|
"chevrotain": "^11.0.0",
|
|
33
34
|
"yaml": "^2.3.0"
|
|
@@ -54,5 +55,15 @@
|
|
|
54
55
|
"parser",
|
|
55
56
|
"templating"
|
|
56
57
|
],
|
|
57
|
-
"license": "MIT"
|
|
58
|
-
|
|
58
|
+
"license": "MIT",
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "tsc",
|
|
61
|
+
"dev": "tsc --watch",
|
|
62
|
+
"test": "vitest run",
|
|
63
|
+
"test:watch": "vitest",
|
|
64
|
+
"lint": "eslint src --ext .ts",
|
|
65
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
66
|
+
"typecheck": "tsc --noEmit",
|
|
67
|
+
"clean": "rm -rf dist"
|
|
68
|
+
}
|
|
69
|
+
}
|