From 70331b2567977b254c43c5225e3b9fe5d63db062 Mon Sep 17 00:00:00 2001 From: kunyuan Date: Mon, 29 Jan 2024 12:44:28 +0800 Subject: [PATCH] :dizzy: Upgrade version to v0.7.0 --- README.md | 30 ++++++------------------------ README_EN.md | 22 +--------------------- openai_forward/__init__.py | 2 +- openai_forward/__main__.py | 2 +- openai_forward/settings.py | 1 - openai_forward/webui/run.py | 2 +- 6 files changed, 10 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 5290c89..7ff1284 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ > [!IMPORTANT] > -> 在v0.7.0以后在配置方面会有较大调整,并与之前版本不兼容。通过UI配置起来会更加方便,且提供了更强大的配置选项。当前可通过源码部署体验alpha版 +> 在v0.7.0以后在配置方面会有较大调整,并与之前版本不兼容。通过UI配置起来会更加方便,且提供了更强大的配置选项。 **OpenAI-Forward** 是为大型语言模型实现的高效转发服务。其核心功能包括 @@ -54,7 +54,7 @@ ### News -- v0.7.0版本后支持通过WebUI进行配置管理(开发中) +- 🎉🎉🎉 v0.7.0版本后支持通过WebUI进行配置管理 - gpt-1106版本已适配 - 缓存后端切换为高性能数据库后端:[🗲 FlaxKV](https://github.com/KenyonY/flaxkv) @@ -212,18 +212,15 @@ curl --location 'https://api.openai-forward.com/v1/images/generations' \ ### 代理其它云端模型 - **场景1:** - 使用通用转发,由环境变量中`EXTRA_BASE_URL`与`EXTRA_ROUTE_PREFIX` 两变量控制,可对任意来源服务进行转发, - 可获得请求速率控制与token速率控制;但通用转发不支持自定义秘钥、实时日志和缓存AI响应. + 使用通用转发,可对任意来源服务进行转发, + 可获得请求速率控制与token速率控制;但通用转发不支持自定义秘钥. - **场景2:** 可通过 [LiteLLM](https://github.com/BerriAI/litellm) 可以将 众多云模型的 API 格式转换为 openai - 的api格式,然后使用openai风格转发(即`OPENAI_BASE_URL`) + 的api格式,然后使用openai风格转发 (更多) -### 代理ChatGPT - -[参考](./deploy.md) @@ -275,10 +272,6 @@ curl --location 'https://api.openai-forward.com/v1/images/generations' \ ### 智能缓存 -缓存可选择数据库后端,需安装相应的环境: - -- 配置环境变量中`CACHE_BACKEND`以使用相应的数据库后端进行存储。 可选值`LMDB`、`LEVELDB` -- 配置`CACHE_CHAT_COMPLETION`为`true`以缓存/v1/chat/completions 结果。 **Python** @@ -316,12 +309,7 @@ curl https://smart.openai.com/v1/chat/completions \
Click for more details -需要配置 OPENAI_API_KEY 和 FORWARD_KEY, 如 - -```bash -OPENAI_API_KEY=sk-******* -FORWARD_KEY=fk-****** # 这里fk-token由我们自己定义 -``` +见.env文件 **用例:** @@ -341,7 +329,6 @@ FORWARD_KEY=fk-****** # 这里fk-token由我们自己定义 ### 对话日志 -默认不记录对话日志,若要开启需设置环境变量`LOG_CHAT=true`
Click for more details @@ -386,11 +373,6 @@ aifd convert 欢迎通过提交拉取请求或在仓库中提出问题来为此项目做出贡献。 -## 赞助者与支持者 - - - - ## 许可证 diff --git a/README_EN.md b/README_EN.md index 7caa82d..b55a3fa 100644 --- a/README_EN.md +++ b/README_EN.md @@ -46,7 +46,6 @@ > > Significant configuration adjustments will be made after version v0.7.0, making it incompatible with previous versions. > Configuring through the UI will be more convenient, and more powerful configuration options are provided. -> The alpha version can currently be experienced through source code deployment. @@ -218,9 +217,6 @@ curl --location 'https://api.openai-forward.com/v1/images/generations' \ - **Applicable scenarios:** To be used in conjunction with projects such as [LocalAI](https://github.com/go-skynet/LocalAI) and [api-for-open-llm](https://github.com/xusenlinzy/api-for-open-llm). -- **How to operate:** - Using LocalAI as an example, if the LocalAI service has been deployed at http://localhost:8080, you only need to set `OPENAI_BASE_URL=http://localhost:8080` in the environment variable or in the .env file. - After that, you can access LocalAI through http://localhost:8000. (More) @@ -257,8 +253,7 @@ You can create a .env file in the project's run directory to customize configura | Environment Variable | Description | Default Value | |-----------------------|-------------------------------------------------------------------------------------------------|:----------------------:| -| OPENAI_BASE_URL | Set base address for OpenAI-style API | https://api.openai.com | -| OPENAI_ROUTE_PREFIX | Define a route prefix for the OPENAI_BASE_URL interface address | / | +| FORWARD_CONFIG | | [{"base_url":"https://api.openai.com","route":"/","type":"openai"}] | | OPENAI_API_KEY | Configure API key in OpenAI style, supports using multiple keys separated by commas | None | | FORWARD_KEY | Set a custom key for proxying, multiple keys can be separated by commas. If not set (not recommended), it will directly use `OPENAI_API_KEY` | None | | EXTRA_BASE_URL | Configure the base URL for additional proxy services | None | @@ -279,9 +274,6 @@ Detailed configuration descriptions can be seen in the [.env.example](.env.examp ### Caching -- Configure `CACHE_BACKEND` in the environment variable to use the respective database backend for storage. Options are `LMDB`, and `LEVELDB`. -- Set `CACHE_CHAT_COMPLETION` to `true` to cache /v1/chat/completions results. - **Python** ```diff from openai import OpenAI @@ -315,12 +307,6 @@ curl https://smart.openai.com/v1/chat/completions \
Click for more details -Configure OPENAI_API_KEY and FORWARD_KEY, for example: - -```bash -OPENAI_API_KEY=sk-******* -FORWARD_KEY=fk-****** # Here, the fk-token is customized -``` **Use case:** @@ -382,12 +368,6 @@ You'll get `chat_openai.json`: ## Contributions Feel free to make contributions to this module by submitting pull requests or raising issues in the repository. -## Backer and Sponsor - - - - - ## License OpenAI-Forward is licensed under the [MIT](https://opensource.org/license/mit/) license. diff --git a/openai_forward/__init__.py b/openai_forward/__init__.py index 9931ed4..396415e 100644 --- a/openai_forward/__init__.py +++ b/openai_forward/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.7.0-alpha" +__version__ = "0.7.0" from dotenv import load_dotenv diff --git a/openai_forward/__main__.py b/openai_forward/__main__.py index e38c0f6..628a879 100644 --- a/openai_forward/__main__.py +++ b/openai_forward/__main__.py @@ -63,7 +63,7 @@ def run(self, port=8000, workers=1, webui=False, ui_port=8001): while True: message = socket.recv() env_dict: dict = pickle.loads(message) - logger.debug(f"{env_dict=}") + # logger.debug(f"{env_dict=}") for key, value in env_dict.items(): os.environ[key] = value diff --git a/openai_forward/settings.py b/openai_forward/settings.py index 78d76e1..866ac70 100644 --- a/openai_forward/settings.py +++ b/openai_forward/settings.py @@ -24,7 +24,6 @@ CACHE_ROUTE_SET = set(env2dict("CACHE_ROUTES", [])) -print(f"{CACHE_ROUTE_SET=}") openai_additional_start_info['cache_routes'] = CACHE_ROUTE_SET general_additional_start_info['cache_routes'] = CACHE_ROUTE_SET diff --git a/openai_forward/webui/run.py b/openai_forward/webui/run.py index 4e7ca75..1f0c03a 100644 --- a/openai_forward/webui/run.py +++ b/openai_forward/webui/run.py @@ -136,7 +136,7 @@ def display_forward_configuration(): def display_api_key_configuration(): - st.header("【WIP】") + st.header("WIP: level 部分尚在开发中") st.write( """\ > **说明**