|
- from memory_Context import *
- from llm import *
-
- # Exit
- #
- # Conditions:
- # 1. `e`, `exit`, `q`, or `quit` was entered
- @llm_by_value
- def cli_exit(
- c: memory_Context
- ) -> memory_Context:
- if (
- c.recentField == "input" and
- (
- c.input == "e" or
- c.input == "exit" or
- c.input == "q" or
- c.input == "quit"
- )
- ):
- c.exit = True
- c.recentField = "exit"
- return c
- #}
- c.recentField = "none"
- return c
- #}
-
- # Greet the user
- #
- # Conditions:
- # 1. Just launched
- @llm_by_value
- def cli_greetUser(
- c: memory_Context
- ) -> memory_Context:
- if (
- c.recentField == "didLaunch" and
- c.didLaunch == True
- ):
- c.outputGreeting = "OGS Memory Command Line Interface"
- c.recentField = "outputGreeting"
- return c
- #}
- c.recentField = "none"
- 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:
- ## 1. Id is digit, in bounds and not hidden
- #@llm_by_value
- #def cli_selectItem(
- # c: cli_Context
- #) -> cli_Context:
- # if (
- # c.input.isdigit()
- # ):
- # # User ids start with 1 while memory module has ids starting with 0
- # # Convert cli item id to memory item id
- # c.cMemory.selectedId = int(c.input) - 1
- # c.cMemory = memory_selectItem(c.cMemory)
- # c.recentField = "cMemory"
- # return c
- # #}
- # c.recentField = "none"
- # return c
- ##}
- #
- ## Ask user to select another item to have a pair of selected items
- #@llm_by_value
- #def cli_shouldPromptSelection(
- # c: cli_Context
- #) -> cli_Context:
- # if (
- # c.recentField == "cMemory" and
- # c.cMemory.recentField == "selectedItems" and
- # len(c.cMemory.selectedItems) == 1
- # ):
- # c.outputPromptSelection = "Select the second item now:"
- # c.recentField = "outputPromptSelection"
- # return c
- # #}
- # c.recentField = "none"
- # return c
- ##}
- #
- ## Report matched items
- #@llm_by_value
- #def cli_shouldReportMatchedItems(
- # c: cli_Context
- #) -> cli_Context:
- # if (
- # c.recentField == "cMemory" and
- # c.cMemory.recentField == "hiddenItems"
- # ):
- # c.outputMatchedItems = "Items matched! Go on:"
- # c.recentField = "outputMatchedItems"
- # return c
- # #}
- # c.recentField = "none"
- # return c
- ##}
- #
- ## Report mismatched items
- #@llm_by_value
- #def cli_shouldReportMismatchedItems(
- # c: cli_Context
- #) -> cli_Context:
- # if (
- # c.recentField == "cMemory" and
- # c.cMemory.recentField == "mismatchedItems"
- # ):
- # c.outputMatchedItems = "Wrong! Try again:"
- # c.recentField = "outputMismatchedItems"
- # return c
- # #}
- # c.recentField = "none"
- # return c
- ##}
- #
- ## Report selection of invalid item ids
- ##
- ## Conditions:
- ## 1. Index out of bounds: less than minimum
- ## 2. Index out of bounds: greater than maximum
- ## 3. Item is already hidden
- ##@llm_by_value
- ##def cli_shouldReportInvalidItemSelection(
- ## c: cli_Context
- ##) -> cli_Context:
- ## if (
- ## c.recentField == "cMemory" and
- ## c.cMemory.recentField == "selectedItems" and
- ## len(c.cMemory.selectedItems) == 1
- ## ):
- ## c.outputPromptSelection = "Select the second item now:"
- ## c.recentField = "outputPromptSelection"
- ## return c
- ## #}
- ## c.recentField = "none"
- ## return c
- ###}
|