Observed since 20 Oct, 21:56 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Python SDK for creating, managing, and deploying AI agents in Salesforce
A Python SDK for creating, managing, and deploying AI agents and prompt templates in Salesforce.
The Salesforce AgentForce SDK provides a programmatic interface to Salesforce's Agent infrastructure, allowing developers to define and interact with agents using Python code. It also includes tools for generating and managing prompt templates with Salesforce field mappings.
pip install agentforce-sdk
The SDK has several dependencies that will be installed automatically, including:
requests: For HTTP requests to Salesforce APIssimple-salesforce: For Salesforce authentication and API accessaiohttp: For asynchronous HTTP operations, especially in deployment toolsjsonschema: For validating agent and template configurationspython-dotenv: For environment variable managementopenai: For LLM API integrationIf you encounter import errors when using deployment features, ensure that aiohttp is properly installed:
pip install aiohttp>=3.8.0
Comprehensive documentation for the SDK is available in the docs directory:
The SDK provides several examples demonstrating prompt template functionality:
The examples/generate_prompt_template_example.py script demonstrates how to generate a prompt template with Salesforce field mappings:
python examples/generate_prompt_template_example.py \
--username your_username \
--password your_password \
--security-token your_security_token \
--output_dir templates \
--model gpt-4
This will:
The examples/generate_template_with_apex_example.py script shows how to create a template that includes Apex invocable actions:
python examples/generate_template_with_apex_example.py \
--username your_username \
--password your_password \
--security-token your_security_token \
--output_dir templates \
--model gpt-4
This example demonstrates:
The examples/tune_prompt_template_example.py script demonstrates how to tune an existing template for different LLM models:
python examples/tune_prompt_template_example.py \
--username your_username \
--password your_password \
--security-token your_security_token \
--template-path templates/my_template.json \
--output_dir tuned_templates \
--model gpt-4
This example shows how to:
The examples/deploy_prompt_template_example.py script shows how to deploy a template to Salesforce:
python examples/deploy_prompt_template_example.py \
--username your_username \
--password your_password \
--security-token your_security_token \
--template-path templates/my_template.json \
--validate-only
This example demonstrates:
Common arguments across examples:
--username: Your Salesforce username (required)--password: Your Salesforce password (required)--security-token: Your Salesforce security token (optional)--output_dir: Directory to save generated files (default varies by example)--model: Model to use for generation/tuning (default: 'gpt-4')Example-specific arguments:
--template-path: Path to an existing template JSON file (for tuning and deployment)--validate-only: Only validate the deployment without actually deploying (deployment example)--description: Additional context for template tuning (tuning example)The examples generate various outputs depending on their function:
The examples directory contains additional sample code for agent functionality:
from agent_sdk import Agentforce
from agent_sdk.core.auth import BasicAuth
from agent_sdk.utils.prompt_templates.prompt_template_utils import PromptTemplateUtils
# Initialize authentication
auth = BasicAuth(username="your_username", password="your_password")
# Initialize the client
client = Agentforce(auth=auth)
# Generate a prompt template
prompt_utils = PromptTemplateUtils(client.sf)
template = prompt_utils.generate_prompt_template(
name="Account Health Analysis",
description="Generate a health analysis for an account",
output_dir="templates",
model="gpt-4"
)
print(f"Template saved to: {template}")
agent-sdk/
├── agent_sdk/
│ ├── core/
│ │ ├── agentforce.py
│ │ ├── auth.py
│ │ ├── base.py
│ │ └── prompt_template_utils.py
│ └── models/
│ ├── agent.py
│ └── prompt_template.py
├── examples/
│ ├── generate_prompt_template_example.py
│ └── [other examples]
└── README.md
You'll require poetry >= 2.0 for dependency management. To install it, follow the instructions on their website.
To contribute to the project:
poetry installpytestThis project is licensed under the Apache 2.0 License - see the LICENSE file for details.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.2.1 | 6 Jun 2025 | 9 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 21:56 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:894cae00766c0ef24e0cebe6a1253ea4d26f5e54b621f87d7ee531aeea364a3d