zilliztech / GPTCache

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

Updated embedding to work with OpenAI's Python v1.3+ and with Azure O… #569

Open jmahmood opened 7 months ago

jmahmood commented 7 months ago

Hi!

This is meant to correct problems with embedding in the latest versions of the OpenAI Python Library and GPTCache.

The latest versions of the OpenAI Python API do not include the .api_base function; even if you manually override it, this leads to other issues. Moreover, the best practice now is to instantiate a client and to use it instead of the global context.

The Azure OpenAI part has further complications related to "Azure Deployments" and different os.environ variables.

Rather than keep track of these within GPTCache, my suggestion is that it might make sense to have the user pass in an instance of the OpenAI client object.

I have access to both OpenAI and Azure OpenAI so I can offer additional help with that if necessary.

One of the issues I am running into is that there is an async version of the OpenAI objects; obviously we can't use async with those. Is there a method you have in mind to deal with this, or would you prefer only to work with the synchronous items?

I am in the process of testing this, so if you are interested but would like to make chances, please don't hesitate to let me know.

sre-ci-robot commented 7 months ago

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jmahmood To complete the pull request process, please assign xiaofan-luan after the PR has been reviewed. You can assign the PR to them by writing /assign @xiaofan-luan 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: - **[OWNERS](https://github.com/zilliztech/GPTCache/blob/dev/OWNERS)** Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment