1. Setup
First, make sure you have thelyzr_agent_api package installed. If not, install it using:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
lyzr_agent_api package installed. If not, install it using:
pip install lyzr_agent_api
from lyzr_agent_api.client import AgentAPI
from lyzr_agent_api.models.environment import EnvironmentConfig, FeatureConfig
from lyzr_agent_api.models.agents import AgentConfig
from lyzr_agent_api.models.chat import ChatRequest
client = AgentAPI(x_api_key="LYZR-AGENT-API-KEY")
environment_config = EnvironmentConfig(
name="Test Environment",
features=[
FeatureConfig(
type="SHORT_TERM_MEMORY",
config={},
priority=0,
)
],
tools=[],
llm_config={
"provider": "ibm",
"model": "watsonx/ibm/granite-13b-chat-v2",
"config": {
"temperature": 0.5,
"top_p": 0.9,
},
"env": {
"WATSONX_URL": "", # Your watsonx.ai base URL
"WATSONX_APIKEY": "", # IBM cloud API key
"WATSONX_TOKEN": "" # IAM auth token
"WATSONX_PROJECT_ID": "" # Project ID of your watsonx instance
"WATSONX_DEPLOYMENT_SPACE_ID": "" # ID of your deployment space to use deployed models
}
},
)
environment = client.create_environment_endpoint(json_body=environment_config)
print(environment) # This will include the environment ID.
agent_config = AgentConfig(
env_id="your-environment-id", # Replace with the actual environment ID obtained from previous step
system_prompt="Act like an experienced financial advisor with 20 years of expertise in wealth management, retirement planning, and investment strategies. Your clients range from individuals to small business owners seeking guidance on optimizing their financial health. Provide comprehensive, step-by-step advice that takes into account both short-term needs and long-term goals.",
name="Financial Advisor Agent",
agent_description="This agent provides expert financial guidance, offering tailored strategies for wealth management, retirement planning, and investment growth.",
)
agent = client.create_agent_endpoint(json_body=agent_config)
print(agent) # This will include the agent ID.
response = client.chat_with_agent(
json_body=ChatRequest(
user_id="user-id",
agent_id="your-agent-id", # Replace with the actual agent ID obtained from previous step
message="What are the best investment strategies for balancing short-term liquidity needs with long-term wealth growth?",
session_id="session-id",
)
)
print(response) # This will display the agent's response to your query.