Skip to content

Commit

Permalink
Added example .txt file for agentchat_langchain sample notebook (micr…
Browse files Browse the repository at this point in the history
…osoft#373)

* Added example .txt file for agentchat_langchain sample notebook

* Update radius.txt

---------

Co-authored-by: Chi Wang <[email protected]>
  • Loading branch information
jasondotparse and sonichi authored Nov 2, 2023
1 parent f96a6f0 commit 1d078fe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
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

0 comments on commit 1d078fe

Please sign in to comment.