From 4944824544775d6c1d412948c92b24837ecf27e7 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Tue, 11 Jun 2024 10:36:35 -0700 Subject: [PATCH] enh: __user__ example --- .../workspace/Tools/CodeEditor.svelte | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/lib/components/workspace/Tools/CodeEditor.svelte b/src/lib/components/workspace/Tools/CodeEditor.svelte index 064115474..4b4f03d96 100644 --- a/src/lib/components/workspace/Tools/CodeEditor.svelte +++ b/src/lib/components/workspace/Tools/CodeEditor.svelte @@ -20,19 +20,26 @@ class Tools: # Use Sphinx-style docstrings to document your tools, they will be used for generating tools specifications # Please refer to function_calling_filter_pipeline.py file from pipelines project for an example - def get_environment_variable(self, variable_name: str) -> str: + def get_user_name_and_id(self, __user__: dict = {}) -> str: """ - Get the value of an environment variable. - :param variable_name: The name of the environment variable. - :return: The value of the environment variable or a message if it doesn't exist. + Get the user name and ID from the user object. """ - value = os.getenv(variable_name) - if value is not None: - return ( - f"The value of the environment variable '{variable_name}' is '{value}'" - ) - else: - return f"The environment variable '{variable_name}' does not exist." + + # Do not include :param for __user__ in the docstring as it should not be shown in the tool's documentation + # The user object will be passed as a parameter when the function is called + + print(__user__) + result = "" + + if "name" in __user__: + result += f"User: {__user__['name']}" + if "id" in __user__: + result += f" (ID: {__user__['id']})" + + if result == "": + result = "User: Unknown" + + return result def get_current_time(self) -> str: """