Build an assistant with retrieval
Create a Context library, verify retrieval, attach it to an Assistant Action, test session memory, and deploy the result.
Prerequisites
You need a Klu workspace with an LLM provider and model configured under Connections. You also need one or more source files, an API endpoint, or a database query whose content you are allowed to use.
Create a Context library
Context is a workspace-level library of indexed documents. An Action retrieves relevant documents from an attached Context when it runs.
- Select Context in the workspace sidebar.
- Click Add Context.
- Enter a Context Name and, optionally, Description (Optional).
- Click Create Context.
Klu opens the new library on its Sources tab.
Add Context sources
On the Sources tab, choose one of these paths:
- Click Add Files or drop files into the upload area.
- Click Add Source, select API, and provide the URL, method, and headers required by the endpoint.
- Click Add Source, select Database, select or create a database provider, and enter the query or provider-specific configuration.
Click Add Source to save an API or database source. A website URL by itself is not a supported source in this flow.
Source ingestion runs asynchronously. The source list shows its indexing status. If a source remains unprocessed after you correct its configuration, select it, open Bulk Actions, and choose Reindex Selected. Processing errors must be fixed at the source before retrieval can succeed.
Test retrieval
After the library has at least one source, Klu adds Documents and Retrieval Test tabs.
- Open Documents and confirm that indexed content appears.
- Open Retrieval Test.
- Enter a representative question in Context Input.
- Keep Response Mode, Max Response Length, and Docs to Retrieve at their defaults for the first test.
- Click Test.
The result shows the retrieved material for your query. Try a question that should match a known passage and one that should not. If no relevant documents return, inspect the source status and indexed documents before changing retrieval limits. Increasing Docs to Retrieve can broaden the candidate set, but it cannot recover content that was never indexed.
Create the Assistant Action
- Select Studio in the sidebar.
- Select Assistant in the Studio toolbar.
- Choose a provider and model in the left panel.
- Add a
systemmessage if the selected model supports it:
System message
Answer the user's question using the retrieved Context.
If the Context does not contain the answer, say that you do not have enough information. Do not invent an answer.
Keep the response concise and cite source metadata or links when they are present in the retrieved material.
- Add a
usertemplate message:
User message
{{question}}
- Under Tools, use Context to select the library you tested. If no library exists, Studio shows Add Context instead.
- Click Save. Enter an Action Name and select an existing App, or select New App and enter an App Name. When you create an App here, Klu uses its name for the first Action as well.
The Context selection is part of the saved Action version. Updating a Context changes its indexed content; changing which Context libraries the Action uses requires another Action save.
Test a conversation
The left side of Assistant mode defines reusable template messages. The main area contains messages for the current conversation.
Klu creates the first session when you save the Action.
- Enter a question in the
questionvariable input. - Click Run.
- Add another message with Message, ask a follow-up that depends on the first turn, and click Run again.
- Click New Session, ask the original question again, and click Run to verify that the previous conversation is absent.
Klu keeps the messages in the current session. The short session ID appears beside the session controls. Use its menu to switch sessions, Duplicate current session, or See all sessions. Click New Session before testing an unrelated conversation so previous messages do not affect the result.
Session controls appear after the Action is saved. A session preserves conversation history, while Context retrieval supplies relevant indexed documents for each run; they solve different parts of the assistant's state.
Deploy the assistant
- Save your latest Studio changes.
- Click Deploy and choose Preview, Staging, or Production.
- Open the deployment menu again and select API.
- In the Publish dialog, choose Shareable URL, Python SDK, Typescript SDK, or cURL Request.
Use the generated Action GUID and integration example for the deployed Action. Production continues to run its deployed version until you save and deploy a newer version. Run a fresh-session check through the selected integration before sending users to it.