# ********************************************************************************* # SupportDev.py # note: this is a draft <—————> needs more logic & be adapted to use with Chainlit # ********************************************************************************* import inspect # -- contains static methods to be called when user enters "/help" class SupportDev: @staticmethod def help(): """Displays a list of available slash commands.""" return "Lists all available slash commands in a markdown table." @staticmethod def memory(): """saves files, session history, and zips them for download.""" return "Creates a backup of your session for download." @staticmethod def summary(): """Provides an on-demand summary of all questions and takeaways.""" return "Generates a summary of key discussions in this session." @staticmethod def traffic(): """tweak into traffic API integration""" return "Provides curated traffic info links." @staticmethod def stash(): """stashes text for later retrieval with /recall.""" return "Stores text snippets to retrieve later." @staticmethod def recall(): """recalls text previously stored with /stash.""" return "Fetches and displays stored text snippets." @staticmethod def how_to(): """guidance on using slash commands.""" return "Shows documentation on available slash commands." # -- to retreive all available slash commands from the SupportDev class. # -- to return a dictionary mapping each command to its description. def get_available_slash_commands(): return { f"/{name}": inspect.getdoc(func) for name, func in inspect.getmembers(SupportDev, predicate=inspect.isfunction) } # -- should execute a user's slash command by looking up the corresponding function in SupportDev. def _slash_command(command: str) -> None: command = command.lstrip("/") command_func = getattr(SupportDev, command, None) if command_func is None: print(f'Error: Unrecognized slash command "/{command}".') else: instruction = command_func() print(f'[System] The "/Slash Command" you are now executing is:" /{command}": "\n{instruction}\n") # **"Improve formatting using Markdown:" # -- to create an md table listing all slash commands+descriptions. def generate_markdown_table(): commands = get_available_slash_commands() markdown_table = "| **Slash Command** | **Description** |\n" markdown_table += "|--------------------|---------------|\n" for cmd, desc in commands.items(): markdown_table += f"| {cmd} | {desc} |\n" return markdown_table # print(generate_markdown_table()) !<—————to display in-line/Chainlit rule #if __name__ == "__main__": #print("Available Slash Commands:\n") #print(generate_markdown_table())