Skip to content

Is chat session supposed to be able to accept tools within the conversation / within a message? #52

@Mr-Ruben

Description

@Mr-Ruben

Is chat session supposed to be able to accept tools within the conversation / within a message?

# --- Code ---
chat=Chat(
    model="openai/gpt-4.1-mini",
    #tools=[make_joke], 
    tools=None, # This is the default value
)
chat(
    msg="Tell me a joke about 'Admin User' working in 'Jupyter notebooks'.",
    tools=[make_joke],
)

Returns TypeError: litellm.main.completion() got multiple values for keyword argument 'tools'

Which seems to me that tools is passed down, but then conflicts with tools=None which comes from Chat.

As it was not expected, it wasn't handled and causes the problem.

I don't see the need to have to specify the tools at the beginning of the session. That may be adding details/tools/context when it is not required/needed.

# --- Output ---
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[43], line 6
      1 chat=Chat(
      2     model="openai/gpt-4.1-mini",
      3     #tools=[make_joke], 
      4     tools=None,
      5 )
----> 6 chat(
      7     msg="Tell me a joke about 'Admin User' working in 'Jupyter notebooks'.",
      8     #tools=[make_joke],
      9     tools=[make_joke],
     10 )

File ~/.local/lib/python3.11/site-packages/lisette/core.py:307, in Chat.__call__(self, msg, prefill, temp, think, search, stream, max_steps, final_prompt, return_all, **kwargs)
    305 if stream: return result_gen              # streaming
    306 elif return_all: return list(result_gen)  # toolloop behavior
--> 307 else: return last(result_gen)

File ~/.local/lib/python3.11/site-packages/fastcore/basics.py:749, in last(x, f, negate, **kwargs)
    747 if f: x = filter_ex(x, f=f, negate=negate, gen=True, **kwargs)
    748 res = None
--> 749 for res in x: pass
    750 return res

File ~/.local/lib/python3.11/site-packages/lisette/core.py:269, in Chat._call(self, msg, prefill, temp, think, search, stream, max_steps, step, final_prompt, tool_choice, **kwargs)
    267 if _has_search(self.model) and (s:=ifnone(search,self.search)): kwargs['web_search_options'] = {"search_context_size": effort[s]}
    268 else: _=kwargs.pop('web_search_options',None)
--> 269 res = completion(model=self.model, messages=self._prep_msg(msg, prefill), stream=stream, 
    270                  tools=self.tool_schemas, reasoning_effort = effort.get(think), tool_choice=tool_choice,
    271                  # temperature is not supported when reasoning
    272                  temperature=None if think else ifnone(temp,self.temp),
    273                  **kwargs)
    274 if stream:
    275     if prefill: yield _mk_prefill(prefill)

TypeError: litellm.main.completion() got multiple values for keyword argument 'tools'

Regards, R.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions