Skip to content

Commit

Permalink
Bump to v1.1.7 (#31)
Browse files Browse the repository at this point in the history
* Use OpenAI package `v1.30.1` or higher

* Include the v1.1.7 patch

* Refactoring to add/use _disabled attribute on tools

---------

Co-authored-by: Matthew Printz <[email protected]>
  • Loading branch information
fivegrant and mattprintz authored May 21, 2024
1 parent f21145a commit fb197fd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
17 changes: 11 additions & 6 deletions archytas/react.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from archytas.tools import ask_user
from archytas.tool_utils import make_tool_dict
import asyncio
import inspect
import json
import pdb
import sys
Expand Down Expand Up @@ -90,6 +91,7 @@ def __init__(
if allow_ask_user:
tools.append(ask_user)
tools.append(self)
self._raw_tools = tools
self.tools = make_tool_dict(tools)

if thought_handler is Undefined:
Expand Down Expand Up @@ -119,24 +121,27 @@ def __init__(
self.last_tool_name = ""

def update_prompt(self):
tool_list = list(self.tools.values())
self.prompt = build_prompt(tool_list)
self.prompt = build_prompt(self._raw_tools)
self.system_message["content"] = self.prompt

def disable(self, *tool_names):
if len(tool_names) == 0:
return
for tool_name in tool_names:
if tool_name in self.tools:
self.tools.pop(tool_name)
setattr(self.tools[tool_name], '_disabled', True)
elif "." not in tool_name:
matches = [name for name in self.tools.keys() if name.endswith(f".{tool_name}")]
if len(matches) > 1:
raise ValueError(f"Ambiguous name: Multiple tools called '{tool_name}'")
elif len(matches) == 1:
self.tools.pop(matches[0])
subtool_name = matches[0]
method = self.tools[subtool_name]

setattr(method.__func__, '_disabled', True)

self.update_prompt()


def thought_callback(self, thought: str, tool_name: str, tool_input: str) -> None:
if self.verbose:
Expand Down
8 changes: 7 additions & 1 deletion archytas/tool_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ def get_prompt_description(obj: Callable | type | Any):
# get the list of arguments
chunks = []
tab = " "
if getattr(obj, '_disabled', False):
return ""

if inspect.isfunction(obj) or inspect.ismethod(obj):
args_list, ret, desc, injections = get_tool_signature(obj)
Expand Down Expand Up @@ -212,7 +214,11 @@ def get_prompt_description(obj: Callable | type | Any):
############### EXAMPLES ###############
# TODO: examples need to be parsed...
else:
tool_methods = collect_tools_from_object(obj)
tool_methods = [
tool_method
for tool_method in collect_tools_from_object(obj)
if not getattr(tool_method, "_disabled", False)
]
if tool_methods:
############### NAME/DESCRIPTION ###############
if inspect.isclass(obj):
Expand Down
12 changes: 6 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "archytas"
version = "1.1.6"
version = "1.1.7"
description = "A library for pairing LLM agents with tools so they perform open ended tasks"
authors = ["David Andrew Samson <[email protected]>", "Matthew Printz <[email protected]>"]
readme = "README.md"
Expand All @@ -15,7 +15,7 @@ chat-repl = "archytas.repl:start_repl"

[tool.poetry.dependencies]
python = "^3.10"
openai = "^1.3.9"
openai = "^1.30.1"
tenacity = "^8.2.2"
rich = "^13.3.4"
docstring-parser = "^0.15"
Expand Down

0 comments on commit fb197fd

Please sign in to comment.