SL LLMs With Context icon

SL LLMs With Context

StrangeLogic LLM Node With Context

SL LLMs With Context

AI-generated

Overview

This node integrates with a large language model (LLM) API to generate text completions based on user prompts while maintaining conversational context. It is designed to keep track of conversation history using a context ID and time period, allowing for more coherent multi-turn interactions with the LLM.

Common scenarios where this node is beneficial include:

  • Building chatbots or virtual assistants that remember previous messages.
  • Generating context-aware responses in customer support automation.
  • Creating interactive storytelling or role-playing applications where the conversation evolves over time.

For example, you can start a conversation with an initial system message, then send user prompts sequentially. The node appends each response to the context, so the LLM can generate replies informed by the entire conversation history.

Properties

Name Meaning
Model Type Selects the LLM model to use. Options include various Gemini, Gemma, Llama, Mistral, Mixtral, and WizardLM models.
Prompt The user input prompt or message to which the LLM should respond.
Temperature Controls randomness in the generated response; higher values produce more diverse outputs.
Max Tokens Maximum length (in tokens) of the generated response.
Top P Nucleus sampling parameter controlling the diversity of token selection (probability mass).
Top K Limits token selection to the top K most likely tokens at each step.
Saftey Settings : Hate Block Level of filtering for hate speech content (None, Low, Medium, High). Available only for certain Gemini models.
Saftey Settings : Harrasment Block Level of filtering for harassment content (None, Low, Medium, High). Available only for certain Gemini models.
Saftey Settings : Sexual Block Level of filtering for sexual content (None, Low, Medium, High). Available only for certain Gemini models.
Saftey Settings : Dangerous Content Block Level of filtering for dangerous content (None, Low, Medium, High). Available only for certain Gemini models.
Context ID Identifier string used to associate and retrieve conversation context from memory/cache.
Context Period (Seconds) Duration in seconds to keep the conversation context in memory before it expires.
Initial Context Optional initial message to seed the conversation context before user prompts begin.

Output

The node outputs a JSON object containing the full response from the LLM API under the json field. This includes:

  • The generated text completion(s) in a choices array, where each choice has a text property with the LLM's reply.
  • If an error occurs during the API request, an error message is included instead.

The output does not include binary data.

Dependencies

  • Requires an external LLM API service accessible via HTTP POST requests.
  • Needs an API key credential configured in n8n to authenticate requests.
  • Uses an internal in-memory cache to store conversation contexts keyed by the Context ID.

Troubleshooting

  • No credentials returned!: Indicates missing or misconfigured API authentication credentials. Ensure the API key credential is properly set up.
  • API request failures: Network issues or invalid parameters may cause errors. Check the API endpoint URL, credentials, and parameter values.
  • Context not maintained: If conversation context seems lost, verify the Context ID is consistent across executions and the Context Period is sufficiently long.
  • Safety settings ignored: Safety filters apply only to specific Gemini models; selecting other models will disable these options.
  • To handle errors gracefully, enable "Continue On Fail" in the node settings to prevent workflow interruption.

Links and References

Discussion