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 athena-intelligence
2

Set Up Client

1from athena import GeneralAgentConfig, GeneralAgentRequest, Tool
2from athena.client import Athena
3from langchain_core.messages import HumanMessage
4from langchain_core.load import load
5
6athena = Athena(api_key="<YOUR_API_KEY>")
3

Run the Agent

1# Enable tools
2config = GeneralAgentConfig(
3 enabled_tools=[Tool.SEARCH, Tool.BROWSE]
4)
5
6# Create message
7messages = [{
8 "type": "human",
9 "content": "Use the search tool to search for information about Athena Intelligence and summarize the results."
10}]
11
12# Get response
13response = athena.agents.general.invoke(
14 request=GeneralAgentRequest(
15 config=config,
16 messages=messages
17 )
18).messages
19
20# Access the response dict directly
21latest_response = response[-1]["kwargs"]["content"]
4

Continue Conversation

Pass the full message list to maintain context between steps.

1# Add follow-up as LangChain message object
2new_messages = load(response) + [HumanMessage(content="Tell me more about what you found")]
3
4# Get response
5continued_response = athena.agents.general.invoke(
6 request=GeneralAgentRequest(
7 config=config,
8 messages=new_messages
9 )
10).messages
Built with