Skip to content

Commit

Permalink
Merge pull request #35 from AnswerDotAI/fix-tool-use-bug
Browse files Browse the repository at this point in the history
fix tool use bug
  • Loading branch information
jph00 authored Oct 3, 2024
2 parents d171444 + 21d377c commit 30938b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
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

0 comments on commit 30938b9

Please sign in to comment.