from upsonic import Agent, Task
from upsonic.tools.builtin_tools import CodeExecutionTool
from upsonic.models.openai import OpenAIResponsesModel
# Create model
model = OpenAIResponsesModel(
model_name="gpt-4o",
provider="openai"
)
# Create code execution tool
code_exec = CodeExecutionTool()
# Create task
task = Task(
description="Write a Python function to calculate factorial and test it with 5",
tools=[code_exec]
)
# Create agent
agent = Agent(model=model, name="Code Execution Agent")
# Execute
result = agent.do(task)
print(f"Result: {result}")