diff --git a/app/services/guidance_functions.py b/app/services/guidance_functions.py new file mode 100644 index 00000000..18e6f9dc --- /dev/null +++ b/app/services/guidance_functions.py @@ -0,0 +1,3 @@ +def truncate(history: list[any], max_length: int): + return history[-max_length:] + diff --git a/app/services/guidance_wrapper.py b/app/services/guidance_wrapper.py index 43f94177..6c7243bb 100644 --- a/app/services/guidance_wrapper.py +++ b/app/services/guidance_wrapper.py @@ -2,6 +2,7 @@ from app.config import LLMModelConfig from app.models.dtos import Content, ContentType +from app.services.guidance_functions import truncate class GuidanceWrapper: @@ -30,6 +31,7 @@ def query(self) -> Content: template = guidance(self.handlebars) result = template( llm=self._get_llm(), + truncate=truncate, **self.parameters, )