Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions notebook/agentchat_langchain.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
]
},
{
Expand Down Expand Up @@ -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",
")"
]
Expand Down
1 change: 1 addition & 0 deletions test/test_files/radius.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.81mm