BeeAI Framework Example
Description
Create an example implementation that demonstrates how to integrate the BeeAI Framework with IBM watsonx Agent Connect, similar to the existing LangGraph and CrewAI examples on the connect.watson-orchestrate.ibm.com/examples page.
The BeeAI Framework example should follow a similar structure as the other examples, showing how to implement the required API endpoints for Agent Connect integration.
Acceptance Criteria
- Code successfully implements the Agent Connect API with BeeAI Framework
- All functionality is demonstrated with examples
- Code is well-structured/follows best practices
- Documentation clearly explains the integration approach
Reference
- https://connect.watson-orchestrate.ibm.com/examples
Plan is to use RequirementAgent example here cc @Tomas2D
I am on point to share code snippet with @geneknit on Monday when we do the release
How can we submit a BeeAI example to their documentation? @jenna-winkler
@geneknit can you please connect us with the right person?
I will pass the example, feel free to comment.
from collections.abc import Callable
from typing import Any
from fastapi import Header
import beeai_framework.adapters.watsonx_orchestrate._api as watsonx_orchestrate_api
from beeai_framework.adapters.watsonx_orchestrate.serve.agent import (
WatsonxOrchestrateServerAgent,
)
from beeai_framework.adapters.watsonx_orchestrate.serve.api import WatsonxOrchestrateAPI
from beeai_framework.adapters.watsonx_orchestrate.serve.server import (
WatsonxOrchestrateServer,
WatsonxOrchestrateServerConfig,
)
from beeai_framework.agents.experimental import RequirementAgent
from beeai_framework.backend import ChatModel
from beeai_framework.tools.think import ThinkTool
class AgentConnectFrameworkAPI(WatsonxOrchestrateAPI):
def __init__(
self,
*,
create_agent: Callable[[], WatsonxOrchestrateServerAgent],
api_key: str | None = None,
fast_api_kwargs: dict[str, Any] | None = None,
) -> None:
super().__init__(
create_agent=create_agent,
api_key=api_key,
fast_api_kwargs=fast_api_kwargs,
stateful=True,
)
# add Agent Connect Framework specific routes
self._router.add_api_route(
"/v1/chat",
self.handler,
methods=["POST"],
response_model=watsonx_orchestrate_api.ChatCompletionResponse,
)
self._router.add_api_route(
"/v1/agents",
self.discover_agents,
methods=["GET"],
response_model=dict[str, Any],
)
# Custom handler for chat completions to suppurt custom thread_id header
async def handler(
self,
request: watsonx_orchestrate_api.ChatCompletionRequestBody,
thread_id: str = Header(None, alias="X-THREAD-ID"),
api_key: str | None = Header(None, alias="X-API-Key"),
) -> Any:
return await super().handler(request, thread_id, api_key=api_key)
def discover_agents(self) -> dict[str, Any]:
"""
Returns a dictionary describing available agents and their capabilities.
"""
return {
"agents": [
{
"name": "BeeAI framework Example Agent",
"description": "A simple BeeAI agent that demonstrates Agent Connect integration",
"provider": {
"organization": "Your Organization",
"url": "https://your-organization.com",
},
"version": "1.0.0",
"documentation_url": "https://framework.beeai.dev",
"capabilities": {"streaming": True},
}
]
}
agent = RequirementAgent(llm=ChatModel.from_name("ollama:llama3.1"), tools=[ThinkTool()])
# Create the server with the custom API and configuration
server = WatsonxOrchestrateServer(
api_cls=AgentConnectFrameworkAPI,
config=WatsonxOrchestrateServerConfig(port=8000),
)
# Register the agent with the server
server.register(agent)
# Start the server
server.serve()
This has been passed on to the team and is being added: IBM Agent Connect - BeeAI Framework Example
Will close once we see its added
Update from the team
Hi all, FYI, we want to update the docs by Aug 14th—date due to other deliverables, lots of parallel work, appreciate the understanding
The BeeAI Framework example is published. closing....