Skip to content

Commit

Permalink
Add truncate function
Browse files Browse the repository at this point in the history
  • Loading branch information
Hialus committed Jul 19, 2023
1 parent 649c9f7 commit b2abb60
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/services/guidance_functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def truncate(history: list[any], max_length: int):
return history[-max_length:]

2 changes: 2 additions & 0 deletions app/services/guidance_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -30,6 +31,7 @@ def query(self) -> Content:
template = guidance(self.handlebars)
result = template(
llm=self._get_llm(),
truncate=truncate,
**self.parameters,
)

Expand Down

0 comments on commit b2abb60

Please sign in to comment.