GPTCache icon indicating copy to clipboard operation
GPTCache copied to clipboard

[Bug]: GPTCache only caches and consider "user" role part message for OpenAI

Open qdaoming opened this issue 2 years ago • 2 comments

Current Behavior

OpenAI prompt contains user role and system role message, as example below: message = [ {"role": "system", "content": " You are AI assistant to help answer question"}, {"role": "user", "content": "What is capital of USA?" } ]

But gptCache only consider and caches "user" role part. If two messages have same "user" msg but different "system" msg, they will be considered the same item, and the cached result will be used by both.

Expected Behavior

If two messages have same "user" msg but different "system" msg, they MUST not be considered the same cache item.

Steps To Reproduce

No response

Environment

Ubuntu 22.04 x64

Anything else?

No response

qdaoming avatar Aug 29 '23 12:08 qdaoming

@qdaoming you can try to use the different pre_process_fun, like: all_content image

SimFG avatar Aug 30 '23 02:08 SimFG

@SimFG Thanks! Using this function works. I thought that it should be enabled by default.

qdaoming avatar Sep 04 '23 10:09 qdaoming