forked from zilliztech/GPTCache
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: SimFG <[email protected]>
- Loading branch information
Showing
7 changed files
with
124 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# 🥳 Feature | ||
|
||
English | [中文](feature_cn.md) | ||
|
||
- Support the openai chat completion normal and stream request | ||
- Get top_k similar search results, it can be set when creating the data manager | ||
- Support the cache chain, see: `Cache#next_cache` | ||
|
||
```python | ||
bak_cache = Cache() | ||
bak_cache.init() | ||
cache.init(next_cache=bak_cache) | ||
``` | ||
|
||
- Whether to completely skip the current cache, that is, do not search the cache or save the Chat GPT results, see: `Cache#cache_enable_func` | ||
- In the cache initialization phase, no cache search is performed, but save the result returned by the chat gpt to cache, see: `cache_skip=True` in `create` request | ||
|
||
```python | ||
openai.ChatCompletion.create( | ||
model="gpt-3.5-turbo", | ||
messages=mock_messages, | ||
cache_skip=True, | ||
) | ||
``` | ||
|
||
- Like Lego bricks, custom assemble all modules, including: | ||
- pre-embedding function, get feature information in the original request, such as prompt, last message, etc. | ||
- embedding function, convert feature information into a vector for cache search, choose a model that fits your use case | ||
- data manager, cache data management, mainly dealing with the search and storage of cache data | ||
- cache similarity evaluation function, can use the distance of similar search or additional selection model to ensure that the answer is more accurate | ||
- post-process the cache answer list, first, random or custom combination |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# 🥳 功能 | ||
|
||
[English](feature.md) | 中文 | ||
|
||
- 支持openai普通和流式的聊天请求 | ||
- 支持top_k搜索,可以在DataManager创建时进行设置 | ||
- 支持多级缓存, 参考: `Cache#next_cache` | ||
|
||
```python | ||
bak_cache = Cache() | ||
bak_cache.init() | ||
cache.init(next_cache=bak_cache) | ||
``` | ||
|
||
- 是否跳过当前缓存,对于请求不进行缓存搜索也不保存chat gpt返回的结果,参考: `Cache#cache_enable_func` | ||
- 缓存系统初始化阶段,不进行缓存搜索,但是保存chat gpt返回的结果,参考: 使用`create`方法时设置`cache_skip=True`参数 | ||
|
||
```python | ||
openai.ChatCompletion.create( | ||
model="gpt-3.5-turbo", | ||
messages=mock_messages, | ||
cache_skip=True, | ||
) | ||
``` | ||
|
||
- 像积木一样,所有模块均可自定义,包括: | ||
- pre-embedding,获取原始请求中的特征信息,如最后一条消息,prompt等 | ||
- embedding,将特征信息转换成向量数据 | ||
- data manager,缓存数据管理,主要包括数据搜索和保存 | ||
- cache similarity evaluation,可以使用相似搜索的距离或者其他更适合使用场景的模型 | ||
- post-process,处理缓存答案列表,比如最相似的,随机或者自定义 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.