This commit is contained in:
Михаил Капелько
2024-05-19 22:39:10 +03:00
parent ee28d89f56
commit 02032cd0ab
2 changed files with 35 additions and 17 deletions

View File

@@ -2,6 +2,9 @@ from memory_Context import *
from llm import * from llm import *
# Greet the user # Greet the user
#
# Conditions:
# 1. Just launched
@llm_by_value @llm_by_value
def cli_greetUser( def cli_greetUser(
c: memory_Context c: memory_Context
@@ -18,6 +21,37 @@ def cli_greetUser(
return c return c
#} #}
# Show help (aka commands)
#
# Conditions:
# 1. Just launched
# 1. `h` or `help` was entered
@llm_by_value
def cli_showHelp(
c: memory_Context
) -> memory_Context:
if (
(
c.recentField == "didLaunch" and
c.didLaunch == True
) or
(
c.recentField == "input" and
c.input == "h"
) or
(
c.recentField == "input" and
c.input == "help"
)
):
c.outputHelp = "Commands:\n\te, exit, q, quit\n\t\tExit\n\th, help\n\t\tList commands\n\t1, 2, 3, ...\n\t\tSelect item\nEnter your choice:"
c.recentField = "outputHelp"
return c
#}
c.recentField = "none"
return c
#}
## Select item ## Select item
## ##
## Conditions: ## Conditions:
@@ -114,20 +148,3 @@ def cli_greetUser(
## c.recentField = "none" ## c.recentField = "none"
## return c ## return c
###} ###}
#
## Show help (aka commands)
#@llm_by_value
#def cli_showHelp(
# c: cli_Context
#) -> cli_Context:
# if (
# c.input == "h" or
# c.input == "help"
# ):
# c.outputHelp = "Commands:\n\te, exit, q, quit\n\t\tExit\n\th, help\n\t\tList commands\n\t1, 2, 3, ...\n\t\tSelect item\nEnter your choice:"
# c.recentField = "outputHelp"
# return c
# #}
# c.recentField = "none"
# return c
##}

View File

@@ -24,6 +24,7 @@ print(cli_test_greetUser())
ctrl = Controller(memory_createContext()) ctrl = Controller(memory_createContext())
ctrl.registerFunction(cli_greetUser) ctrl.registerFunction(cli_greetUser)
ctrl.registerFunction(cli_showHelp)
ctrl.registerCallback(lambda c: print(f"ИГР App.dbg ctx: '{c}'")) ctrl.registerCallback(lambda c: print(f"ИГР App.dbg ctx: '{c}'"))
def printOutput(c): def printOutput(c):