From 02032cd0abc3544948c66b1cbb6fb21d72167cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Sun, 19 May 2024 22:39:10 +0300 Subject: [PATCH] d --- v4/cli.py | 51 ++++++++++++++++++++++++++++++++++----------------- v4/main.py | 1 + 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/v4/cli.py b/v4/cli.py index 8eb1d08..72b585d 100644 --- a/v4/cli.py +++ b/v4/cli.py @@ -2,6 +2,9 @@ from memory_Context import * from llm import * # Greet the user +# +# Conditions: +# 1. Just launched @llm_by_value def cli_greetUser( c: memory_Context @@ -18,6 +21,37 @@ def cli_greetUser( 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 ## ## Conditions: @@ -114,20 +148,3 @@ def cli_greetUser( ## c.recentField = "none" ## 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 -##} diff --git a/v4/main.py b/v4/main.py index cfb2a06..e0bdfd2 100644 --- a/v4/main.py +++ b/v4/main.py @@ -24,6 +24,7 @@ print(cli_test_greetUser()) ctrl = Controller(memory_createContext()) ctrl.registerFunction(cli_greetUser) +ctrl.registerFunction(cli_showHelp) ctrl.registerCallback(lambda c: print(f"ИГР App.dbg ctx: '{c}'")) def printOutput(c):