-
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
2 changed files
with
29 additions
and
2 deletions.
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,27 @@ | ||
--- | ||
tags: [ai, sample, util, hidden, example, docs] | ||
--- | ||
|
||
# AI generate | ||
|
||
GritQL can generate new code based on some instruction using the `ai_generate` function. | ||
|
||
Just call ai_generate with your instructions to assign a value to a variable. Metavariables can be referenced in the instructions | ||
|
||
```grit | ||
language js | ||
`console.log($msg)` where { | ||
$level = ai_generate(`Based on this log message: $msg, generate a new log level of either "info", "warn", or "error" with only one word`), | ||
} => `logger.level("$level", $msg)` | ||
``` | ||
|
||
## Rewrites a basic console.log | ||
|
||
```js | ||
console.log('Hello, world!'); | ||
``` | ||
|
||
```js | ||
logger.level('info', '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