GPTCache icon indicating copy to clipboard operation
GPTCache copied to clipboard

[Enhancement]: Caching Support for Agents

Open kennethleungty opened this issue 1 year ago • 3 comments

What would you like to be added?

While it is possible to cache each LLM call, I notice that there is no way to cache the entire thought process and subsequent output from an Agent call e.g., LLMSingleActionAgent from langchain. Any way that this can be achieved?

Why is this needed?

Agents will be increasingly important and heavily utilized

Anything else?

No response

kennethleungty avatar Apr 27 '23 03:04 kennethleungty

You can try to use the GPTCache api, which provides get and put methods. a simple example:

from gptcache.adapter.api import put, get, init_similar_cache

init_similar_cache()
put(question, answer)
get(similar_question)

Of course, you can also integrate GPTCache into other llm models or applications faster by this method

SimFG avatar Apr 27 '23 03:04 SimFG

You can try to use the GPTCache api, which provides get and put methods. a simple example:

from gptcache.adapter.api import put, get, init_similar_cache

init_similar_cache()
put(question, answer)
get(similar_question)

Of course, you can also integrate GPTCache into other llm models or applications faster by this method

I thought that won't help too much. @kennethleungty are you ask for context?

xiaofan-luan avatar Apr 30 '23 18:04 xiaofan-luan

now you can try to use the context processor to handle the long prompt, like:

from gptcache.processor.context.summarization_context import SummarizationContextProcess
from gptcache import cache

context_process = SummarizationContextProcess()
cache.init(
        pre_embedding_func=context_process.pre_process,
        ...
)

or selective context, like:

context_processor = SelectiveContextProcess()

SimFG avatar May 12 '23 03:05 SimFG