From 28961f0d2c6d5cbb25e7eed6c5ee3ec884b031fd Mon Sep 17 00:00:00 2001 From: monst Date: Tue, 10 Oct 2023 18:56:20 +0200 Subject: [PATCH] Document regex --- app/services/guidance_wrapper.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/services/guidance_wrapper.py b/app/services/guidance_wrapper.py index 82160189..d1eb9bce 100644 --- a/app/services/guidance_wrapper.py +++ b/app/services/guidance_wrapper.py @@ -31,8 +31,11 @@ def query(self) -> dict: ValueError: if handlebars do not generate 'response' """ + # Perform a regex search to find the names of the variables being generated + # by the handlebars template + # This regex matches strings like: {{gen 'response' temperature=0.0 max_tokens=500}} + # and extracts the variable name 'response' import re - pattern = r'{{(?:gen|geneach|set) [\'"]([^\'"]+)[\'"]$}}' var_names = re.findall(pattern, self.handlebars)