Build AI agents that can interact with business systems using OpenAI’s function calling and StackOne’s unified API access.

Overview

  • Function calling with business data access
  • Conversational agents with tool execution
  • Multi-step workflow automation
  • Real-time data integration
from openai import OpenAI
from stackone_ai import StackOneToolSet

# Initialize clients
client = OpenAI()
toolset = StackOneToolSet()

# Get StackOne tools and convert to OpenAI format
tools = toolset.get_tools('hris_*', account_id='your-account-id')
openai_tools = tools.to_openai()

# Create an AI agent with tool access
response = client.chat.completions.create(
    model="gpt-4",
    messages=[
        {
            "role": "system",
            "content": "You are an HR assistant with access to employee data."
        },
        {
            "role": "user", 
            "content": "How many employees are in engineering?"
        }
    ],
    functions=openai_tools,
    function_call="auto"
)

# Handle function calls
message = response.choices[0].message
if message.function_call:
    function_name = message.function_call.name
    function_args = json.loads(message.function_call.arguments)
    
    tool = tools.get_tool(function_name)
    result = tool.call(**function_args)
    print(f"Result: {result['data']}")

Complete Examples

GitHub Examples: For detailed implementations including conversational agents, async operations, and error handling:→ View OpenAI Integration ExamplesFor OpenAI function calling patterns and best practices, see the OpenAI documentation.