This repository contains the IBM i Bee Agent for the Bee Agent Framework.
- π₯ Safely execute SQL queries using Mapepire
- π Get complete visibility into agents' decisions using our MLFlow integration thanks to Bee Observe.
- π Fully fledged TypeScript project setup with linting and formatting.
- Clone this repository
git clone https://github.com/ajshedivy/bee-agent-ibmi.git
- Install dependencies
npm ci
. - Configure your project by filling in missing values in the
.env
file (default LLM provider is locally hostedOllama
). - Run the agent
npm run start src/agent.ts
To run an agent with a custom prompt, simply do this npm run start src/agent.ts <<< 'Hello Bee!'
npm run start src/agent.ts <<< "what employee has the highest salary?"
Result:
> start
> NODE_OPTIONS='--no-deprecation' npm exec tsx src/agent.ts
User π€ : what employee has the highest salary?
Agent π€ (thought) : The user wants to find the employee with the highest salary. I can do this by querying the 'EMPLOYEE' table and sorting the results by salary in descending order.
Agent π€ (tool_name) : IBMiTool
Agent π€ (tool_input) : {"query":"SELECT EMPNO, FIRSTNME, LASTNAME, SALARY FROM EMPLOYEE ORDER BY SALARY DESC LIMIT 1"}
Agent π€ (tool_output) : {"success":true,"result":[{"EMPNO":"000010","FIRSTNME":"CHRISTINE","LASTNAME":"HAAS","SALARY":52750}]}
Agent π€ (final_answer) : The employee with the highest salary is Christine Haas with a salary of $52,750.
Agent π€ : The employee with the highest salary is Christine Haas with a salary of $52,750.
We can add to this example by asking to find the employee with the highest salary in each department:
npm run start src/agent.ts <<< "what employee has the highest salary in each department?"
Result:
> start
> NODE_OPTIONS='--no-deprecation' npm exec tsx src/agent.ts
User π€ : what employee has the highest salary in each department?
Agent π€ (thought) : The user wants to find the employee with the highest salary in each department. I can do this by joining the 'EMPLOYEE' and 'DEPARTMENT' tables and using a subquery to find the maximum salary for each department.
Agent π€ (tool_name) : IBMiTool
Agent π€ (tool_input) : {"query":"SELECT E.EMPNO, E.FIRSTNME, E.LASTNAME, E.JOB, E.SALARY FROM EMPLOYEE E INNER JOIN DEPARTMENT D ON E.WORKDEPT = D.DEPTNO WHERE E.SALARY = (SELECT MAX(E2.SALARY) FROM EMPLOYEE E2 INNER JOIN DEPARTMENT D2 ON E2.WORKDEPT = D2.DEPTNO WHERE D2.DEPTNO = D.DEPTNO)"}
Agent π€ (tool_output) : {"success":true,"result":[{"EMPNO":"000010","FIRSTNME":"CHRISTINE","LASTNAME":"HAAS","JOB":"PRES","SALARY":52750},{"EMPNO":"000020","FIRSTNME":"MICHAEL","LASTNAME":"THOMPSON","JOB":"MANAGER","SALARY":41250},{"EMPNO":"000030","FIRSTNME":"SALLY","LASTNAME":"KWAN","JOB":"MANAGER","SALARY":38250},{"EMPNO":"000060","FIRSTNME":"IRVING","LASTNAME":"STERN","JOB":"MANAGER","SALARY":32250},{"EMPNO":"000070","FIRSTNME":"EVA","LASTNAME":"PULASKI","JOB":"MANAGER","SALARY":36170},{"EMPNO":"000050","FIRSTNME":"JOHN","LASTNAME":"GEYER","JOB":"MANAGER","SALARY":40175},{"EMPNO":"000090","FIRSTNME":"EILEEN","LASTNAME":"HENDERSON","JOB":"MANAGER","SALARY":29750},{"EMPNO":"000100","FIRSTNME":"THEODORE","LASTNAME":"SPENSER","JOB":"MANAGER","SALARY":26150}]}
Agent π€ (final_answer) : Here are the employees with the highest salary in each department:
- President: Christine Haas with a salary of $52,750
- Manager: Michael Thompson with a salary of $41,250
- Manager: Sally Kwan with a salary of $38,250
- Manager: Irving Stern with a salary of $32,250
- Manager: Eva Pulaski with a salary of $36,170
- Manager: John Geyer with a salary of $40,175
- Manager: Eileen Henderson with a salary of $29,750
- Manager: Theodore Spenser with a salary of $26,150
Agent π€ : Here are the employees with the highest salary in each department:
- President: Christine Haas with a salary of $52,750
- Manager: Michael Thompson with a salary of $41,250
- Manager: Sally Kwan with a salary of $38,250
- Manager: Irving Stern with a salary of $32,250
- Manager: Eva Pulaski with a salary of $36,170
- Manager: John Geyer with a salary of $40,175
- Manager: Eileen Henderson with a salary of $29,750
- Manager: Theodore Spenser with a salary of $26,150
The Agent is able to find the employee with the highest salary in each department by correctly joining the EMPLOYEE
and DEPARTMENT
tables ππͺ
Click to expand
π See the documentation to learn more.
- JavaScript runtime NodeJS > 18 (ideally installed via nvm).
- Container system like Rancher Desktop, Podman (VM must be rootfull machine) or Docker.
- LLM Provider either external WatsonX (OpenAI, Groq, ...) or local ollama.
[!NOTE]
Docker distribution with support for compose is required, the following are supported:
The Bee Code Interpreter is a gRPC service that an agent uses to execute an arbitrary Python code safely.
- Start all services related to the
Code Interpreter
npm run infra:start --profile=code_interpreter
- Run the agent
npm run start src/agent_code_interpreter.ts
[!NOTE]
Code Interpreter runs on
http://127.0.0.1:50051
.
Get complete visibility of the agent's inner workings via our observability stack.
- The MLFlow is used as UI for observability.
- The Bee Observe is the observability service (API) for gathering traces from Bee Agent Framework.
- The Bee Observe Connector is the observability connector that sends traces from Bee Agent Framework to Bee Observe.
- Start all services related to Bee Observe
npm run infra:start --profile=observe
- Run the agent
npm run start src/agent_observe.ts
- See visualized trace in MLFlow web application
http://127.0.0.1:8080/#/experiments/0
[!TIP]
Configuration file is infra/observe/.env.docker.