OpenAI API + GPTCache, similar search cache: not work in flask web API project #532
Eric-Huang-LiQiang
started this conversation in
General
Replies: 1 comment
-
Can you show the way that you use the GPTCache in your application |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Dear Team,
GPTCache is a wonderful project that has exactly the functionality I need. I can run the OpenAI API + GPTCache similar search cache example program. However, when I tried to apply GPTCache's similar search cache to my actual project, I found that it was not working, even though I had copied the example code.
I have built an API program using Flask, and the example program is executed when the program starts up. I expect to have semantic caching implemented every time a client accesses my API.
How can I check if the example code is working properly?
Those code will be executed when Flask web api go live;
from gptcache import cache
from gptcache.adapter import openai
from gptcache.embedding import Onnx
from gptcache.manager import CacheBase, VectorBase, get_data_manager
from gptcache.similarity_evaluation.distance import SearchDistanceEvaluation
print("Cache loading.....")
onnx = Onnx()
data_manager = get_data_manager(CacheBase("sqlite"), VectorBase("faiss", dimension=onnx.dimension))
cache.init(
embedding_func=onnx.to_embeddings,
data_manager=data_manager,
similarity_evaluation=SearchDistanceEvaluation(),
)
cache.set_openai_key()
Beta Was this translation helpful? Give feedback.
All reactions