diff --git a/notebook/agentchat_langchain.ipynb b/notebook/agentchat_langchain.ipynb index f1eac5f49351..a756bc3afd12 100644 --- a/notebook/agentchat_langchain.ipynb +++ b/notebook/agentchat_langchain.ipynb @@ -205,6 +205,7 @@ "from langchain.tools import BaseTool\n", "from typing import Optional, Type\n", "import math\n", + "import os\n", "\n", "class CircumferenceToolInput(BaseModel):\n", " radius: float = Field()\n", @@ -215,7 +216,22 @@ " args_schema: Type[BaseModel] = CircumferenceToolInput\n", "\n", " def _run(self, radius: float):\n", - " return float(radius) * 2.0 * math.pi" + " return float(radius) * 2.0 * math.pi\n", + " \n", + "def get_file_path_of_example():\n", + " # Get the current working directory\n", + " current_dir = os.getcwd()\n", + "\n", + " # Go one directory up\n", + " parent_dir = os.path.dirname(current_dir)\n", + "\n", + " # Move to the target directory\n", + " target_folder = os.path.join(parent_dir, \"test\")\n", + "\n", + " # Construct the path to your target file\n", + " file_path = os.path.join(target_folder, \"test_files/radius.txt\")\n", + " \n", + " return file_path" ] }, { @@ -355,7 +371,7 @@ "\n", "user_proxy.initiate_chat(\n", " chatbot,\n", - " message=\"Read the file with the path 'Test.txt', then calculate the circumference of a circle that has a radius of that files contents.\", #\" 7.81mm\" in the file\n", + " message=f\"Read the file with the path {get_file_path_of_example()}, then calculate the circumference of a circle that has a radius of that files contents.\", #7.81mm in the file\n", " llm_config=llm_config,\n", ")" ] diff --git a/test/test_files/radius.txt b/test/test_files/radius.txt new file mode 100644 index 000000000000..e69a5131fd4f --- /dev/null +++ b/test/test_files/radius.txt @@ -0,0 +1 @@ +7.81mm