Skip to content

Support source citations / file links in Agent RAG responses #9331

@zsj1029

Description

@zsj1029

** Is your feature request related to a problem? Please describe.

After successfully using LocalAI's RAG Agent with uploaded documents, I noticed that when the Agent answers questions based on the Knowledge Base, it does not provide any source citations or links to the original file.
For example, with the document How to use localai.pdf, the response only gives the answer without mentioning the file name or allowing the user to click and view the source PDF. This makes it difficult for users to verify the information and jump back to the original document.
Describe the solution you'd like
When the RAG Agent retrieves information from a Collection, please add support for source citations in the final answer.
Desired behavior:

Include the original file name (e.g. How to use localai.pdf) as a citation.
Show citations either inline (e.g. [1]) or at the end of the answer under a Sources section.
Ideally, make the file name clickable in the UI so users can open the original PDF.

Even a simple format like:
【Source: How to use localai.pdf】
would be very helpful.

** Describe alternatives I've considered

Forcing citations via a detailed system prompt (works sometimes but inconsistent).
Using OpenWebUI as frontend (which has better citation support).

** Native support in LocalAI Agents would be much better.

Using LocalAI Agents + Knowledge Base (Collections) with PDF uploads.
Retrieval works well, but source attribution is missing.
This is a common and useful feature in other RAG tools.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions