Python
Build AI agents with OpenAI Functions using the StackOne Python SDK
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']}")
Was this page helpful?