Skip to main content

Python SDK for creating, managing, and deploying AI agents in Salesforce

Project description

Salesforce AgentForce SDK

PyPI version Python 3.9+ License: MIT

A Python SDK for creating, managing, and deploying AI agents and prompt templates in Salesforce.

Introduction

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.

Installation

pip install agentforce-sdk

Features

  • Create and manage AI agents in Salesforce
  • Generate and manage prompt templates with Salesforce field mappings
  • Support for various Salesforce field types and relationships
  • Automatic Apex class generation for related data queries
  • Template tuning for different LLM models
  • Multiple formats for defining agents (JSON, nested directory, modular directory)
  • MCP server for HTTP-based integration

Documentation

Comprehensive documentation for the SDK is available in the docs directory:

  • API Documentation: Detailed documentation for all SDK components, classes, and methods.
  • JSON Schemas: JSON schemas for validating agent definitions in various formats.

Examples

Prompt Template Examples

The SDK provides several examples demonstrating prompt template functionality:

Basic Template Generation

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:

  1. Connect to your Salesforce org
  2. Generate a prompt template with appropriate field mappings
  3. Save the template and any generated Apex classes to the specified output directory

Template with Apex Actions

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:

  1. Creating a template for account opportunity analysis
  2. Including Apex invocable actions for data manipulation
  3. Generating necessary Apex classes for the actions
  4. Saving the complete template with action mappings

Template Tuning

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:

  1. Load an existing template
  2. Optimize it for specific LLM models
  3. Add explicit instructions and validation rules
  4. Save the enhanced template

Agent Examples

The examples directory contains additional sample code for agent functionality:

Quick Start

from agent_sdk import Agentforce
from agent_sdk.core.auth import BasicAuth
from agent_sdk.core.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}")

Project Structure

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

Development

To contribute to the project:

  1. Clone the repository
  2. Install development dependencies: pip install -r requirements-dev.txt
  3. Run tests: pytest

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentforce_sdk-0.1.6.tar.gz (80.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentforce_sdk-0.1.6-py3-none-any.whl (97.1 kB view details)

Uploaded Python 3

File details

Details for the file agentforce_sdk-0.1.6.tar.gz.

File metadata

  • Download URL: agentforce_sdk-0.1.6.tar.gz
  • Upload date:
  • Size: 80.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for agentforce_sdk-0.1.6.tar.gz
Algorithm Hash digest
SHA256 bdf0b52b5471c202f1e41bedf4d2b40b68cbf9879fbfc025fda89365f1d3addd
MD5 3856b2dabc847117ff032cb8d8595f75
BLAKE2b-256 8955389c868117a99aa86cd5b8bce9481ba4b85f1ad65f390557ebca7bb83ab2

See more details on using hashes here.

File details

Details for the file agentforce_sdk-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: agentforce_sdk-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 97.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for agentforce_sdk-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b75121fff232f10cd25bc04b684bd6edb33b799b0bb537c4e51b75f6c24cac85
MD5 3cc06b3b4c9a5b7e2a1fb4c8324aff42
BLAKE2b-256 cf8ebdf84e098a11d120fc17e2061c53adc8679fb707df74407cbf7d8bb19bdf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page