Skip to content

Commit

Permalink
Fix last_content_without_template
Browse files Browse the repository at this point in the history
Fix last_content_without_template when the template looks like
"Tell me a joke about {subject} with less than 50 words."
where len(field_name_arr) < len(literal_text_arr).
  • Loading branch information
ziyi-curiousthing authored and SimFG committed Jan 12, 2024
1 parent 109d9ca commit b732ea2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gptcache/processor/pre.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _get_pattern_value(pattern_str: str, value_str: str):

pattern_values = {}
last_end = 0
for i, literal_text in enumerate(literal_text_arr):
for i, (literal_text, field_name) in enumerate(zip(literal_text_arr, field_name_arr)):
start = value_str.find(literal_text, last_end)
if i == len(literal_text_arr) - 1:
end = len(value_str)
Expand All @@ -69,7 +69,7 @@ def _get_pattern_value(pattern_str: str, value_str: str):
if start == -1 or end == -1:
break
start += len(literal_text)
pattern_values[field_name_arr[i]] = value_str[start:end]
pattern_values[field_name] = value_str[start:end]
last_end = end
return pattern_values

Expand Down

0 comments on commit b732ea2

Please sign in to comment.