-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrewai_integration.py
More file actions
55 lines (40 loc) · 1.61 KB
/
crewai_integration.py
File metadata and controls
55 lines (40 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""
This example demonstrates how to use StackOne tools with CrewAI.
CrewAI uses LangChain tools natively.
```bash
uv run examples/crewai_integration.py
```
"""
from crewai import Agent, Crew, Task
from stackone_ai import StackOneToolSet
account_id = "45072196112816593343"
employee_id = "c28xIQaWQ6MzM5MzczMDA2NzMzMzkwNzIwNA"
def crewai_integration():
toolset = StackOneToolSet()
tools = toolset.fetch_tools(actions=["bamboohr_*"], account_ids=[account_id])
# CrewAI uses LangChain tools natively
langchain_tools = tools.to_langchain()
assert len(langchain_tools) > 0, "Expected at least one LangChain tool"
for tool in langchain_tools:
assert hasattr(tool, "name"), "Expected tool to have name"
assert hasattr(tool, "description"), "Expected tool to have description"
assert hasattr(tool, "_run"), "Expected tool to have _run method"
agent = Agent(
role="HR Manager",
goal=f"What is the employee with the id {employee_id}?",
backstory="With over 10 years of experience in HR and employee management, "
"you excel at finding patterns in complex datasets.",
llm="gpt-5.4",
tools=langchain_tools,
max_iter=2,
)
task = Task(
description="What is the employee with the id c28xIQaWQ6MzM5MzczMDA2NzMzMzkwNzIwNA?",
agent=agent,
expected_output="A JSON object containing the employee's information",
)
crew = Crew(agents=[agent], tasks=[task])
result = crew.kickoff()
assert result is not None, "Expected result to be returned"
if __name__ == "__main__":
crewai_integration()