Skip to content

QuestionAnswerAdvisor should be able to inject the document id and metadata into the prompt. #1294

Open
@BillFarber

Description

@BillFarber

QuestionAnswerAdvisor only inserts the contents of the Documents into the prompt. It would be helpful to be able to include the document id and metadata.

When inserting Documents into a PromptTemplate, the object's .toString() method is automatically, used which includes the id and metadata.

return "Document{id='" + this.id + "', metadata=" + this.metadata + ", content='" + this.content + "', media=" + this.media + "}";

However, with QuestionAnswerAdvisor, it's only possible to include the content:

String documentContext =(String)documents.stream().map(Content::getContent).collect(Collectors.joining(System.lineSeparator()));

It is frequently useful to include the Document id as well as the Document metadata in the prompt so the LLM can use that information. So, it would be helpful if there were a way to tell QAA to include that information.

For the time-being, I'm using a simple hack to make it happen:

Document tempDoc = new Document(uri, text, metadata);
return new Document(uri, tempDoc.toString(), metadata);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions