zilliztech / GPTCache

Semantic cache for LLMs. Fully integrated with LangChain and llama_index.
https://gptcache.readthedocs.io
MIT License
6.96k stars 490 forks source link

[Bug]: OpenAI Azure key doesn't seem to be supported even now #512

Closed gssakash closed 11 months ago

gssakash commented 11 months ago

Current Behavior

from dotenv import load_dotenv
import time
import os
from gptcache import cache
from gptcache.adapter import openai
from gptcache.embedding import OpenAI
from gptcache.manager import CacheBase, VectorBase, get_data_manager
from gptcache.similarity_evaluation.distance import SearchDistanceEvaluation

load_dotenv()
openai_embd = OpenAI()

cache_base = CacheBase('sqlite')
vector_base = VectorBase('chromadb', dimension=openai_embd.dimension)

data_manager = get_data_manager(cache_base, vector_base)

cache.init(embedding_func=openai_embd.to_embeddings, data_manager=data_manager, similarity_evaluation=SearchDistanceEvaluation())
cache.set_azure_openai_key()

In the above code, I get an error from GPTCache saying AttributeError : 'Cache' object has no attribute 'set_azure_openai_key'.

But then it works when I replace the last line with cache.set_openai_key(). I assume the issue is because of like 2 checks not passing in this PR

Expected Behavior

Ideally on initializing this, the code should run as normal and allow me to interact with GPT and make the necessary API calls to it.

Steps To Reproduce

1. In the Python environment have Python 3.11.4
2. Install GPTCache 
3. Try out the code above and you should see the error

Environment

Python 3.11.4
GPTCache 0.1.38

Anything else?

It'll be great to know by when this can be fixed and please let me know if there are any issues with my code.

SimFG commented 11 months ago

@gssakash because there is no official release yet which includes this fix. And it is expected to be released tomorrow. You can install the dev version according to the source code.

SimFG commented 11 months ago

@gssakash the 0.1.39 has been released, and you can try it. Looking forward to your feedback.

SimFG commented 11 months ago

@gssakash I will close the issue. And If you have other problem, please create a new issue