import json
from openai import OpenAI
from stackone_ai import StackOneToolSet
# Initialise clients
client = OpenAI()
toolset = StackOneToolSet()
# Fetch StackOne tools and convert to OpenAI format
tools = toolset.fetch_tools(
actions=['bamboohr_get_employee', 'bamboohr_list_employees'],
account_ids=['your-account-id']
)
openai_tools = tools.to_openai()
# Create an AI agent with tool access
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{
"role": "system",
"content": "You are an HR assistant with access to employee data."
},
{
"role": "user",
"content": "How many employees are in engineering?"
}
],
tools=openai_tools,
tool_choice="auto"
)
# Handle tool calls
message = response.choices[0].message
if message.tool_calls:
for tool_call in message.tool_calls:
tool = tools.get_tool(tool_call.function.name)
if tool:
result = tool.execute(tool_call.function.arguments)
print(f"Result: {result}")