from hypertic import Agent, tool
from hypertic.memory import InMemory
from openai import OpenAI
from datetime import datetime
# Define a weather tool
@tool
def get_weather(city: str) -> str:
"""Get weather for a given city."""
return f"Sunny, 72°F in {city}"
# Define a date tool
@tool
def get_current_date() -> str:
"""Get the current date and time."""
return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
# Configure the model
model = OpenAI(
model="gpt-5.2",
max_tokens=1000,
temperature=0.5,
)
# Create in-memory memory (use PostgreSQL/MongoDB in production)
memory = InMemory()
# Create an agent with memory
agent = Agent(
model=model,
instructions="",
tools=[get_weather, get_current_date],
memory=memory
)
# Synchronous non-streaming
response = agent.run("What is today's date and how's the weather in San Francisco?")
print(response.content)