Skip to content

Commit

Permalink
feat(guide): now can interactive simply
Browse files Browse the repository at this point in the history
  • Loading branch information
snowyu committed Sep 1, 2024
1 parent 457490b commit bcbf065
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The role messages can be formatted using Jinja2 templates and advanced replaceme
* **Internal Instruction Replacement:** Call internal instructions similarly (e.g., `@$instruction(param1=value1)`).
* **Regular Expression Replacement:** Use `/RegExp/[RegOpts]:Answer[:index_or_group_name]` for pattern-based replacement on the `Answer` variable.

### [V. Programmable Prompt Engine Language Script Capabilities](./lang-script.md)
### [Programmable Prompt Engine Language - Script Capabilities](./lang-script.md)

* **Chaining Outputs:** The `->` operator connect script outputs to subsequent instructions or scripts, creating complex workflows.
* **Instruction Invocation:** The `$` prefix calls script instructions (e.g., `$fn: {param1:value1}`).
Expand Down
24 changes: 14 additions & 10 deletions guide/guide.ai.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ IsServerRunning: Please make sure the brain(LLM) server has been started. Are yo
# call input to get the preferLang from user and assign it to the preferLang variable.
preferLang: "@input(inputType='AutoComplete', content='Which language do you prefer?', choices=languages, limit=10)"
# `#` prefix means format the template string immediately and assign it to the variable.
GiveMeGoodBrain: "\\n[Start Guide]An expert should have a good brain(LLM)."
GiveMeGoodBrain: "\n[Start Guide]An expert should have a good brain(LLM)."
- $if: "preferLang !== 'en'"
then:
# - $set:
Expand All @@ -47,12 +47,16 @@ IsServerRunning: Please make sure the brain(LLM) server has been started. Are yo
else:
- -> $echo(content=GiveMeGoodBrain)
- -> $print
# call guide_lib_list to get the catalog from the README.md and assign it to the catalog variable.
- -> guide_lib_list(file="README.md") -> $set('catalog', content)
# echo the catalog summary as the latest content
- $echo: ?=catalog.summary
# call translator to translate the content to the preferLang and assign it to the question variable.
- -> translator(content=content+"\nPlease select what you want to know:", target=preferLang) -> $set('question')
# call user-defined js instruction `toChoices` to get the choices from the catalog and pass it the the `choices` argument of the input.
# the input will list the catalog as the choices. The user can select the file to explain.
- -> $toChoices(files=catalog.files) -> input(inputType='AutoComplete', content=question, choices=content, limit=10, memoized=false) -> guide_lib_explain(file=content, lang=preferLang)
- $set:
selected: ''
- $while: "selected !== 'quit'"
do:
# call guide_lib_list to get the catalog from the README.md and assign it to the catalog variable.
- -> guide_lib_list(file="README.md") -> $set('catalog', content)
# echo the catalog summary as the latest content
- $echo: ?=catalog.summary
# call translator to translate the content to the preferLang and assign it to the question variable.
- -> translator(content=content+"\nPlease select what you want to know:", target=preferLang) -> $set('question')
# call user-defined js instruction `toChoices` to get the choices from the catalog and pass it the the `choices` argument of the input.
# the input will list the catalog as the choices. The user can select the file to explain.
- -> $toChoices(files=catalog.files) -> input(inputType='AutoComplete', content=question, choices=content, limit=10, memoized=false) -> $set('selected') -> guide_lib_explain(file=content, lang=preferLang, memoized=false)

0 comments on commit bcbf065

Please sign in to comment.