-
Notifications
You must be signed in to change notification settings - Fork 18
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
3 changed files
with
165 additions
and
1 deletion.
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,121 @@ | ||
# AI transform | ||
|
||
GritQL can use AI to transform a target variable based on some instruction using the `ai_transform` function. | ||
|
||
tags: #ai, #sample, #util, #hidden, #example | ||
|
||
```grit | ||
language yaml | ||
pattern pair($key, $value) { | ||
block_mapping_pair(key=contains $key, $value) | ||
} | ||
or { | ||
`- $task` where { | ||
$task <: block_mapping(items=some pair(key=`across`)), | ||
$task => ai_transform(match=$task, instruct="Replace this `across` task with `in_parallel` tasks, distributing the values across each child like `in_parallel: | ||
- task: task-1 | ||
- task: task-2`") | ||
} | ||
} | ||
``` | ||
|
||
## Handles a basic transform - currently | ||
|
||
```yaml | ||
jobs: | ||
- name: build-and-use-image | ||
plan: | ||
- across: | ||
- var: name | ||
values: | ||
- file1 | ||
- file2 | ||
- file3 | ||
task: create-file | ||
config: | ||
platform: linux | ||
image_resource: | ||
type: registry-image | ||
source: { repository: busybox } | ||
run: | ||
path: touch | ||
args: | ||
- manifests/((.:name)) | ||
outputs: | ||
- name: manifests | ||
file: input.yaml | ||
- task: list-file | ||
config: | ||
platform: linux | ||
image_resource: | ||
type: registry-image | ||
source: { repository: busybox } | ||
inputs: | ||
- name: manifests | ||
run: | ||
path: ls | ||
args: | ||
- manifests | ||
``` | ||
```yaml | ||
jobs: | ||
- name: build-and-use-image | ||
plan: | ||
- in_parallel: | ||
- task: task-1 | ||
config: | ||
platform: linux | ||
image_resource: | ||
type: registry-image | ||
source: { repository: busybox } | ||
run: | ||
path: touch | ||
args: | ||
- manifests/file1 | ||
outputs: | ||
- name: manifests | ||
|
||
- task: task-2 | ||
config: | ||
platform: linux | ||
image_resource: | ||
type: registry-image | ||
source: { repository: busybox } | ||
run: | ||
path: touch | ||
args: | ||
- manifests/file2 | ||
outputs: | ||
- name: manifests | ||
|
||
- task: task-3 | ||
config: | ||
platform: linux | ||
image_resource: | ||
type: registry-image | ||
source: { repository: busybox } | ||
run: | ||
path: touch | ||
args: | ||
- manifests/file3 | ||
outputs: | ||
- name: manifests | ||
|
||
file: input.yaml | ||
- task: list-file | ||
config: | ||
platform: linux | ||
image_resource: | ||
type: registry-image | ||
source: { repository: busybox } | ||
inputs: | ||
- name: manifests | ||
run: | ||
path: ls | ||
args: | ||
- manifests | ||
``` |
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,25 @@ | ||
# AI transform - JS | ||
|
||
GritQL can use AI to transform a target variable based on some instruction using the `ai_transform` function. | ||
|
||
tags: #ai, #hidden, #test | ||
|
||
```grit | ||
language js | ||
`console.log($_)` as $log where { | ||
$log => ai_transform(match=$log, instruct="Use console.error instead") | ||
} | ||
``` | ||
|
||
## Proof of sanity | ||
|
||
```js | ||
const { grit } = require('grit'); | ||
console.log('Hello world!'); | ||
``` | ||
|
||
```js | ||
const { grit } = require('grit'); | ||
console.error('Hello world!'); | ||
``` |
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