docs: Add FAQ section for common questions#1446
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds a comprehensive FAQ section to the README.md, covering installation, comparisons, and core concepts of the BeeAI framework. A review comment identified that the custom tool implementation example was incorrect and provided actionable code suggestions for both decorator-based and class-based approaches to ensure framework compatibility.
| Create a custom Tool by extending the base Tool class: | ||
| ```python | ||
| from beeai_framework.tools import Tool | ||
| class MyTool(Tool): | ||
| async def run(self, input_data): | ||
| # Your logic here | ||
| return result | ||
| ``` |
There was a problem hiding this comment.
The example provided for creating a custom tool is incorrect and would not function if implemented as shown. In the BeeAI Framework, the Tool class is an abstract base class that requires defining name, description, and input_schema as properties. Furthermore, the method to override for the tool's logic is _run (which receives input, options, and context), not run. Overriding run directly bypasses the framework's validation and execution logic.
For an FAQ, it is recommended to showcase the @tool decorator approach instead, as it is much more concise and handles schema generation automatically.
Recommended Example (Decorator):
from beeai_framework.tools import tool
@tool
def my_tool(input_data: str) -> str:
"""Description of my tool"""
# Your logic here
return "result"Corrected Class-based Example:
from beeai_framework.tools import Tool
from pydantic import BaseModel
class MyInput(BaseModel):
input_data: str
class MyTool(Tool):
name = "my_tool"
description = "Description of my tool"
input_schema = MyInput
async def _run(self, input, options, context):
return f"Processed {input.input_data}"There was a problem hiding this comment.
Can you address this comment please? @meichuanyi
There was a problem hiding this comment.
Friendly ping @meichuanyi — this one is just waiting on the custom-tool example fix noted above (the Tool subclass example as written wouldn't run). Also, DCO is currently failing, so the commits will need a Signed-off-by line. Happy to help if anything is unclear!
This PR adds a FAQ section to the README, covering common questions about:
Checklist