View this page in the latest version of Appian. a!callLanguageModel() Function Share Share via LinkedIn Reddit Email Copy Link Print On This Page Function a!callLanguageModel( prompt, messages, isStreaming ) 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 independently to process AI responses in your expressions, or pair it with the Chat component to build conversational AI experiences for end users. 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. This function can be used in multiple contexts: In an interface: Use it within the saveInto parameter of an a!chatField() component to build interactive chat experiences for end users. In a process model: Use it in a script task to generate AI responses as part of automated workflows. In an expression rule: Use it anywhere you need to call a language model and process the response programmatically, without requiring a chat interface. Function behavior The function operates in two modes depending on the isStreaming parameter: Non-streaming mode (default): The function waits for the complete response from the language model and returns the full message text. Streaming mode: When isStreaming is set to true, the function executes asynchronously in the background. Instead of waiting for the complete response, it immediately returns results to the a!chatField() component in real-time. Note: Supports US English text only. Parameters Keyword Type Description prompt Text The prompt that is passed to the language model. messages List of Map A list of maps that define the conversation history. Each map must include the keys messageContent (Text) and role (Text: "USER" or "ASSISTANT"). isStreaming Boolean Determines if the language model is called with streaming enabled. When true, this function returns a UUID for use in a!chatField. Default: false. 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. In streaming mode, the function executes asynchronously and provides real-time updates to the chat interface. Use streaming mode for better user experience in chat interfaces, as responses appear progressively rather than all at once. Streaming functionality is automatically handled by the a!chatField() component when used together. You can also use this function in a process model via a script task. When AI Guardrails are enabled and a Block action triggers, the function returns the administrator-configured block message as the response text (non-streaming mode). Developers can check whether the response is a guardrail block message and handle it accordingly in their application logic. 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 32 33 34 35 36 37 38 a!localVariables( local!messages: {}, local!roles: {}, local!modelResponse: "", a!chatField( title: "Chat", messages: a!forEach( local!messages, a!chatMessage( messageContent: fv!item, role: local!roles[fv!index] ) ), placeholder: "Ask a question...", saveInto: { /* 1. Append the user's message */ a!save(local!messages, append(local!messages, save!value)), a!save(local!roles, append(local!roles, "USER")), /* 2. Call the language model */ a!save( local!modelResponse, a!callLanguageModel( messages: a!forEach( local!messages, a!map( messageContent: fv!item, role: local!roles[fv!index] ) ), prompt: "You are a helpful assistant." ) ), /* 3. Append the model's response */ a!save(local!messages, append(local!messages, local!modelResponse)), a!save(local!roles, append(local!roles, "ASSISTANT")) } ) ) Feature compatibility The table below lists this function's compatibility with various features in Appian. Feature Compatibility Note Portals Incompatible Offline Interfaces 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. Event Consumer Filter Conditions Incompatible Cannot be used in filter conditions. Event Consumer Event Handlers Incompatible Cannot be used in event handler expressions. Feedback Was this page helpful? SHARE FEEDBACK Loading...