Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tool use bug #35

Merged
merged 1 commit into from
Oct 3, 2024
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
5 changes: 3 additions & 2 deletions 00_core.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1860,10 +1860,11 @@
" stop=None, # Stop sequence\n",
" tools:Optional[list]=None, # List of tools to make available to Claude\n",
" tool_choice:Optional[dict]=None, # Optionally force use of some tool\n",
" pr=None, # prompt\n",
" **kwargs):\n",
" \"Make a call to Claude.\"\n",
" if tools: kwargs['tools'] = [get_schema(o) for o in listify(tools)]\n",
" if tool_choice: kwargs['tool_choice'] = mk_tool_choice(tool_choice)\n",
" if tool_choice and pr: kwargs['tool_choice'] = mk_tool_choice(tool_choice)\n",
" msgs = self._precall(msgs, prefill, stop, kwargs)\n",
" if stream: return self._stream(msgs, prefill=prefill, max_tokens=maxtok, system=sp, temperature=temp, **kwargs)\n",
" res = self.c.messages.create(model=self.model, messages=msgs, max_tokens=maxtok, system=sp, temperature=temp, **kwargs)\n",
Expand Down Expand Up @@ -2244,7 +2245,7 @@
" **kw):\n",
" self._append_pr(pr)\n",
" res = self.c(self.h, stream=stream, prefill=prefill, sp=self.sp, temp=temp, maxtok=maxtok,\n",
" tools=self.tools, tool_choice=self.tool_choice, **kw)\n",
" tools=self.tools, tool_choice=self.tool_choice, pr=pr,**kw)\n",
" if stream: return self._stream(res)\n",
" self.h += mk_toolres(self.c.result, ns=self.tools, obj=self)\n",
" return res"
Expand Down
5 changes: 3 additions & 2 deletions claudette/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,11 @@ def __call__(self:Client,
stop=None, # Stop sequence
tools:Optional[list]=None, # List of tools to make available to Claude
tool_choice:Optional[dict]=None, # Optionally force use of some tool
pr=None, # prompt
**kwargs):
"Make a call to Claude."
if tools: kwargs['tools'] = [get_schema(o) for o in listify(tools)]
if tool_choice: kwargs['tool_choice'] = mk_tool_choice(tool_choice)
if tool_choice and pr: kwargs['tool_choice'] = mk_tool_choice(tool_choice)
msgs = self._precall(msgs, prefill, stop, kwargs)
if stream: return self._stream(msgs, prefill=prefill, max_tokens=maxtok, system=sp, temperature=temp, **kwargs)
res = self.c.messages.create(model=self.model, messages=msgs, max_tokens=maxtok, system=sp, temperature=temp, **kwargs)
Expand Down Expand Up @@ -304,7 +305,7 @@ def __call__(self:Chat,
**kw):
self._append_pr(pr)
res = self.c(self.h, stream=stream, prefill=prefill, sp=self.sp, temp=temp, maxtok=maxtok,
tools=self.tools, tool_choice=self.tool_choice, **kw)
tools=self.tools, tool_choice=self.tool_choice, pr=pr,**kw)
if stream: return self._stream(res)
self.h += mk_toolres(self.c.result, ns=self.tools, obj=self)
return res
Expand Down