Build with Agents

This example shows a multi-step workflow with the General Agent, the default agent in Spaces.

Key features:

  • Use prebuilt tools like web browsing and search
  • Compatible with LangChain message objects
  • Support for multi-step conversations
1

Install Package

!pip install -U athenaintel
2

Set Up Client

from athena import GeneralAgentConfig, GeneralAgentRequest
from athena.client import Athena
from langchain_core.messages import HumanMessage
from langchain_core.load import load
athena = Athena(api_key="<YOUR_API_KEY>")
3

Run the Agent

# Enable tools
config = GeneralAgentConfig(
enabled_tools=["search", "browse"]
)
# Create message
messages = [{
"type": "human",
"content": "Use the search tool to search for information about Athena Intelligence and summarize the results."
}]
# Get response
response = athena.agents.general.invoke(
request=GeneralAgentRequest(
config=config,
messages=messages
)
).messages
# Access the response text directly
latest_response = response[-1].content
4

Continue Conversation

Pass the full message list to maintain context between steps.

# Add follow-up as LangChain message object
new_messages = load(response) + [HumanMessage(content="Tell me more about what you found")]
# Get response
continued_response = athena.agents.general.invoke(
request=GeneralAgentRequest(
config=config,
messages=new_messages
)
).messages