feat: add reasoning decorator to browser toolkit#3552
feat: add reasoning decorator to browser toolkit#3552YunfeiZHAO wants to merge 6 commits intomasterfrom
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
70fd99d to
ad53d20
Compare
ad53d20 to
9824198
Compare
…:camel-ai/camel into feat/browser_toolkit_reasoning_decorator
|
@YunfeiZHAO thanks! when this pr ready,feel free re-open it and we will review it! |
| async def wrapper(*args, reason: str = "", **kwargs): | ||
| result = await func(*args, **kwargs) | ||
| result["reason"] = reason | ||
| return result | ||
|
|
||
| wrapper.__signature__ = new_sig | ||
| wrapper.__doc__ = doc | ||
| return wrapper |
There was a problem hiding this comment.
Thanks @YunfeiZHAO for the PR. A few comments:
- Should we put
reasonto be the first arg sincereasonshoud generate before the agent action? - Why do we need
reasonin the return? It is already in the context as an input arg. If we also add it to the return it would double to token consumption without information gain.
|
discussed with @nitpicker55555 , this is a testing PR, we can close this cc @YunfeiZHAO |
Description
#3494
A decorator that enhances toolkit functions with reasoning capabilities by automatically adding a
reasonparameter and field to function signatures and return values, it will also update the function docstring for Args and Returns.Enables agents to provide explanations for their tool usage, improving transparency and debuggability of agent actions.
Features
reason: str = ""keyword-only parameter to the decorated functionreasonparameter in the Args sectionreasonfield in the Returns sectionreasonvalue into the returned dictionaryDictreturn type annotations; gracefully skips non-dict functions with a log messageUsage
example
examples/toolkits/browser_toolkit_with_reasoning.ipynb
Checklist
Go over all the following points, and put an
xin all the boxes that apply.Fixes #issue-numberin the PR description (required)pyproject.tomlanduv lockIf you are unsure about any of these, don't hesitate to ask. We are here to help!