Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix last_content_without_template #599

Merged
merged 1 commit into from
Jan 12, 2024
Merged

Fix last_content_without_template #599

merged 1 commit into from
Jan 12, 2024

Conversation

ziyi-curiousthing
Copy link

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).
Existing implementation error out like the following:

Traceback (most recent call last):
  File "/Users/zz/src/GPTCache/sbert_match.py", line 62, in <module>
    response = openai.ChatCompletion.create(
  File "/Users/zz/src/GPTCache/gptcache/adapter/openai.py", line 125, in create
    return adapt(
  File "/Users/zz/src/GPTCache/gptcache/adapter/adapter.py", line 55, in adapt
    pre_embedding_res = time_cal(
  File "/Users/zz/src/GPTCache/gptcache/utils/time.py", line 9, in inner
    res = func(*args, **kwargs)
  File "/Users/zz/src/GPTCache/gptcache/processor/pre.py", line 134, in last_content_without_template
    pattern_value = _get_pattern_value(cache_config.template, last_content_str)
  File "/Users/zz/src/GPTCache/gptcache/processor/pre.py", line 72, in _get_pattern_value
    pattern_values[field_name_arr[i]] = value_str[start:end]
IndexError: list index out of range

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).
@sre-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ziyi-curiousthing
To complete the pull request process, please assign cxie after the PR has been reviewed.
You can assign the PR to them by writing /assign @cxie in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sre-ci-robot
Copy link
Collaborator

Welcome @ziyi-curiousthing! It looks like this is your first PR to zilliztech/GPTCache 🎉

@SimFG
Copy link
Collaborator

SimFG commented Jan 11, 2024

@ziyi-curiousthing thanks your contribution!

@ziyi-curiousthing
Copy link
Author

@SimFG It looks like unittest is failing due to missing dependency. I am not sure how to fix it.

@SimFG
Copy link
Collaborator

SimFG commented Jan 12, 2024

@ziyi-curiousthing i will check it

@SimFG SimFG merged commit b732ea2 into zilliztech:dev Jan 12, 2024
3 of 6 checks passed
@ziyi-curiousthing ziyi-curiousthing deleted the bugfix/fix-last_content_without_template branch January 12, 2024 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants