Exploring Large Action Models (LAMs) for Automated Workflow Processes

Thank you for reading this post, don't forget to subscribe!

While large language models (LLMs) are effective in generating text and media, Large Action Models (LAMs) push beyond simple generation—they perform complex tasks autonomously. Imagine an AI that not only generates content but also takes direct actions in workflows, such as managing customer relationship management (CRM) tasks, sending emails, or making real-time decisions.

LAMs are engineered to execute tasks across various environments by seamlessly integrating with tools, data, and systems. They adapt to user commands, making them ideal for applications in industries like marketing, customer service, and beyond.

Key Capabilities of LAMs

A standout feature of LAMs is their ability to perform function-calling tasks, such as selecting the appropriate APIs to meet user requirements. Salesforce’s xLAM models are designed to optimize these tasks, achieving high performance with lower resource demands—ideal for both mobile applications and high-performance environments.

The fc series models are specifically tuned for function-calling, enabling fast, precise, and structured responses by selecting the best APIs based on input queries.

Practical Examples Using Salesforce LAMs

In this article, we’ll explore:

  • Utilizing default examples in the Salesforce xLAM documentation.
  • Building APIs with Flask to replicate business processes.
  • Executing custom REST API calls for targeted actions.

Implementation: Setting Up the Model and API

Start by installing the necessary libraries:

pythonCopy code! pip install transformers==4.41.0 datasets==2.19.1 tokenizers==0.19.1 flask==2.2.5

Next, load the xLAM model and tokenizer:

pythonCopy codeimport json
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_name = "Salesforce/xLAM-7b-fc-r"
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto", torch_dtype="auto", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(model_name)

Now, define instructions and available functions.

Task Instructions:

The model will use function calls where applicable, based on user questions and available tools.

Format Example:

jsonCopy code{
  "tool_calls": [
    {"name": "func_name1", "arguments": {"argument1": "value1", "argument2": "value2"}}
  ]
}

Define available APIs:

pythonCopy codeget_weather_api = {
    "name": "get_weather",
    "description": "Retrieve weather details",
    "parameters": {"location": "string", "unit": "string"}
}

search_api = {
    "name": "search",
    "description": "Search for online information",
    "parameters": {"query": "string"}
}

Creating Flask APIs for Business Logic

We can use Flask to create APIs to replicate business processes.

pythonCopy codefrom flask import Flask, request, jsonify

app = Flask(__name__)

@app.route("/customer", methods=['GET'])
def get_customer():
    customer_id = request.args.get('customer_id')
    # Return dummy customer data
    return jsonify({"customer_id": customer_id, "status": "active"})

@app.route("/send_email", methods=['GET'])
def send_email():
    email = request.args.get('email')
    # Return dummy response for email send status
    return jsonify({"status": "sent"})

Testing the LAM Model and Flask APIs

Define queries to test LAM’s function-calling capabilities:

pythonCopy codequery = "What's the weather like in New York in fahrenheit?"
print(custom_func_def(query))
# Expected: {"tool_calls": [{"name": "get_weather", "arguments": {"location": "New York", "unit": "fahrenheit"}}]}

Function-Calling Models in Action

Using base_call_api, LAMs can determine the correct API to call and manage workflow processes autonomously.

pythonCopy codedef base_call_api(query):
    """Calls APIs based on LAM recommendations."""
    base_url = "http://localhost:5000/"
    json_response = json.loads(custom_func_def(query))
    api_url = json_response["tool_calls"][0]["name"]
    params = json_response["tool_calls"][0]["arguments"]
    response = requests.get(base_url + api_url, params=params)
    return response.json()

With LAMs, businesses can automate and streamline tasks in complex workflows, maximizing efficiency and empowering teams to focus on strategic initiatives.

Related Posts
Salesforce OEM AppExchange
Salesforce OEM AppExchange

Expanding its reach beyond CRM, Salesforce.com has launched a new service called AppExchange OEM Edition, aimed at non-CRM service providers. Read more

The Salesforce Story
The Salesforce Story

In Marc Benioff's own words How did salesforce.com grow from a start up in a rented apartment into the world's Read more

Salesforce Jigsaw
Salesforce Jigsaw

Salesforce.com, a prominent figure in cloud computing, has finalized a deal to acquire Jigsaw, a wiki-style business contact database, for Read more

Health Cloud Brings Healthcare Transformation
Health Cloud Brings Healthcare Transformation

Following swiftly after last week's successful launch of Financial Services Cloud, Salesforce has announced the second installment in its series Read more