Free cookie consent management tool by TermsFeed

a!callLanguageModel() Function

On This Page

Function

a!callLanguageModel( prompt )

Allows users to call the Appian provided default language model.

The a!callLanguageModel() function allows you to call the Appian-provided default language model. You can use this function to connect your Chat component to Appian's built-in conversational AI capabilities.

This function is typically used within the saveInto parameter of an a!chatField() component. When a user submits a message, this function sends the prompt and message history to the model and returns the model's generated response.

Note:  Supports US English text only.

Note:  This function is not supported in self-managed environments. For a list of AI features available in self-managed environments, see Set Up Appian AI for Appian on Kubernetes.

Parameters

Keyword Type Description

prompt

Text

The prompt that is passed to the language model.

Considerations

This function uses the Appian-provided default AI model. If you want to use your own AI model, see the Use the chat component with your preferred AI mode topic on the Chat Component page.

Example

This example shows how to use a!callLanguageModel with the saveInto parameter in aa!chatField.

When a user sends a message, the message is added to the local!messages variable. Then, a!callLanguageModel runs with the full message history as context. The AI model's response is saved to local!modelResponse and added to the local!messages list, which updates the interface with the new response.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
a!localVariables(
  /* local!messages are ideally loaded from a database to persist history */
  local!messages: {},
  local!modelResponse,
  a!chatField(
    title: "Chat",
    messages: local!messages,
    placeholder: "Ask a question...",
    saveInto: {
      /* 1. Append the user's new message (from saveInto) to the history */
      a!save(
        local!messages,
        append(local!messages, save!value)
      ),

      /* 2. Call the language model with the updated message list */
      a!save(
        local!modelResponse,
        a!callLanguageModel(
          prompt: "You are a helpful assistant. Here is my question, with the message history before it: " & local!messages,
        )
      ),

      /* 3. Append the model's response to the message list */
      a!save(
        local!messages,
        append(local!messages, local!modelResponse)
      )
    }
  )
)

Feature compatibility

The table below lists this function's compatibility with various features in Appian.
Feature Compatibility Note
Portals Incompatible
Offline Mobile Incompatible
Sync-Time Custom Record Fields Incompatible
Real-Time Custom Record Fields Incompatible

Custom record fields that evaluate in real time must be configured using one or more Custom Field functions.

Process Reports Incompatible

Cannot be used to configure a process report.

Process Events Incompatible

Cannot be used to configure a process event node, such as a start event or timer event.

Process Autoscaling Incompatible

Cannot be used in autoscaled processes.

Feedback