Allow chat history to be sent to AI engine (#6128)

# Description of Changes
Add an extra parameter to every agent to receive the conversation
history in addition to the current message. This will make it possible
to answer followup questions from the AI without needing to give full
context in your message.
This commit is contained in:
James Brunton
2026-04-21 15:03:10 +00:00
committed by GitHub
parent f779085d75
commit 2a856fbc19
14 changed files with 116 additions and 19 deletions
+8 -1
View File
@@ -12,6 +12,7 @@ from stirling.contracts import (
PdfQuestionNotFoundResponse,
PdfQuestionRequest,
PdfQuestionResponse,
format_conversation_history,
)
from stirling.services import AppRuntime
@@ -70,7 +71,13 @@ class PdfQuestionAgent:
for selection in file_text.pages
]
pages = "\n\n".join(sections)
return f"Files: {file_names}\nQuestion: {request.question}\nExtracted page text:\n{pages}"
history = format_conversation_history(request.conversation_history)
return (
f"Conversation history:\n{history}\n"
f"Files: {file_names}\n"
f"Question: {request.question}\n"
f"Extracted page text:\n{pages}"
)
def _has_page_text(self, page_text: list[ExtractedFileText]) -> bool:
return any(selection.text.strip() for file_text in page_text for selection in file_text.pages)