Skip to content

Commit

Permalink
Merge pull request #1 from InternLM/pip
Browse files Browse the repository at this point in the history
add pypi update
  • Loading branch information
fly2tomato authored Jan 12, 2024
2 parents 4155c06 + 235bd6b commit f41912e
Show file tree
Hide file tree
Showing 19 changed files with 188 additions and 89 deletions.
54 changes: 35 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,50 +44,60 @@ AOE can help large model algorithm researchers, evaluators, engineering develope


# Quick Run
We will provide 3 different ways to run open-aoe: run by pip, run by docker and run by source code as well.
We will provide three different ways to run open-aoe: run by pip, run by docker and run by source code as well.


## Run by pip
- Install
## Run by pip
### **Install**
```shell
pip install open-aoe
pip install -U open-aoe
```
- Start
### **Start**
```shell
open-aoe -f /path/to/your/config.yaml
```

## Run by docker
- Install
### **Install**

There are two ways to get the Open-AOE docker image by:
1. pull the open-aoe docker image
```shell
docker pull open-aoe:latest
```
- Start

2. or build a docker image
```shell
git clone https://github.com/internlm/Open-AOE
cd open-aoe
docker build . -f docker/Dockerfile -t open-aoe:latest
```

### **Start**
```shell
docker run -p 10099:10099 -v /path/to/your/config.yaml:/app/config.yaml --name Open-AOE open-aoe:latest
```

## Run by source code
- Install
### **Install**
1. clone this project
```shell
git clone https://github.com/internlm/Open-AOE
```
2. (optional) build the frontend project
2. [_optional_] build the frontend project when the frontend codes are changed
```shell
cd Open-AOE/openaoe/frontend
npm i
cd open-aoe/openaoe/frontend
npm install
npm run build
```


- Start
### **Start**
```shell
cd Open-AOE/openaoe
cd open-aoe/openaoe
pip install -r backend/requirements.txt
python main.py -f /path/to/your/config.yaml
python -m main
```
-


> [!TIP]
Expand All @@ -98,15 +108,21 @@ python main.py -f /path/to/your/config.yaml

# Tech Introduction
> **You are always welcome to fork this project.**
> **You are always welcome to fork this project and contribute your work**
If you want to add more LLMs/features based on Open-AOE, the following info might be helpful.
If you want to add more LLMs' APIs or features based on Open-AOE, the following info might be helpful.

## Tech Stack
The technology stack we use includes:

- Backend framework based on python + fastapi;
- Frontend framework based on typescript + Sealion-Client (encapsulated based on React) + Sealion-UI.
1. Backend framework based on python + fastapi;
2. Frontend framework based on typescript + Sealion-Client (encapsulated based on React) + Sealion-UI.
3. Build tools:
1. conda: quickly create a virtual python env to install necessary packages
2. npm: build the frontend project

> [!TIP]
> The build tools can be installed by [sealion-cli](https://github.com/opensealion/sealion-cli) by `pip install -U sealion-cli`
## Organization of the Repo
- Frontend code in `openaoe/frontend`
Expand Down
50 changes: 36 additions & 14 deletions docs/README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,47 +44,63 @@ AOE 可以帮助大模型算法研究、评测、工程开发人员甚至非专
# 快速安装
我们将提供 3 种不同的方式安装:基于 pip、基于 docker 以及基于源代码,实现开箱即用。


## 基于 pip
- 安装:
### **安装**
```shell
pip install open-aoe
pip install -U open-aoe
```

- 启动:
### **运行**
```shell
open-aoe -f /path/to/your/config.yaml
```

## 基于 docker
- 安装:
### **安装**
有两种方式获取 Open-AOE 的 docker 镜像:
1. 官方拉取
```shell
docker pull open-aoe:latest
```

- 启动:
2. 本地构建
```shell
git clone https://github.com/internlm/Open-AOE
cd open-aoe
docker build . -f docker/Dockerfile -t open-aoe:latest
```

### **运行**
```shell
docker run -p 10099:10099 -v /path/to/your/config.yaml:/app/config.yaml --name open-aoe open-aoe:latest
docker run -p 10099:10099 -v /path/to/your/config.yaml:/app/config.yaml --name Open-AOE open-aoe:latest
```

## 基于源代码
- 安装:
### **安装**
1. 克隆项目
```shell
git clone https://github.com/internlm/open-aoe
git clone https://github.com/internlm/Open-AOE
```
2. [_可选_] (如果前端代码发生变动)重新构建前端项目
```shell
cd open-aoe/openaoe/frontend
npm install
npm run build
```


- 启动:
### **运行**
```shell
cd open-aoe/openaoe
pip install -r backend/requirements.txt
python main.py -f /path/to/your/config.yaml
```
python -m main
``````

> [!TIP]
> `/path/to/your/config.yaml` 是 open-aoe 启动时读取的配置文件,里面包含了大模型的相关配置信息,
> 包括:调用API地址、AKSK、Token等信息,是 open-aoe 启动的必备文件。文件模板可以在 `openaoe/backend/config/config.yaml` 中找到。

# 二次开发
> **欢迎 fork**
> **欢迎 fork,一起共建 ~**

如果想基于此项目做二次开发,下面这些信息将会对你有帮助。

Expand All @@ -93,6 +109,12 @@ python main.py -f /path/to/your/config.yaml
我们使用到的技术栈是:
1. 基于 Python + fastapi 的后端框架;
2. 基于 Typescript + [Sealion-Client](https://github.com/OpenSealion/sealion-client) (基于React封装)+ [Sealion-UI](https://github.com/OpenSealion/sealion-ui) 的前端框架。
3. 构建工具:
1. conda: 快速创建 python 环境来安装后端必要的依赖包
2. npm: 构建前端项目

> [!TIP]
> 构建工具可通过 [sealion-cli](https://github.com/opensealion/sealion-cli) 快速获得: `pip install -U sealion-cli`


## 整个仓库的简要说明
Expand Down
4 changes: 2 additions & 2 deletions openaoe/backend/api/route_claude.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fastapi import APIRouter, Request

from ..model.dto.ClaudeDto import ClaudeChatReqDto
from ..service.service_claude import claude_chat_anthropic, claude_chat_stream_svc
from openaoe.backend.model.dto.ClaudeDto import ClaudeChatReqDto
from openaoe.backend.service.service_claude import claude_chat_anthropic, claude_chat_stream_svc

router = APIRouter()

Expand Down
4 changes: 2 additions & 2 deletions openaoe/backend/api/route_google.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fastapi import APIRouter, Request

from ..model.dto.GoogleDto import GooglePalmChatReqDto, GooglePalmTextReqDto, GoogleBardAskImgReqDto
from ..service.service_google import palm_chat_svc, palm_text_svc, bard_ask_img_svc
from openaoe.backend.model.dto.GoogleDto import GooglePalmChatReqDto, GooglePalmTextReqDto, GoogleBardAskImgReqDto
from openaoe.backend.service.service_google import palm_chat_svc, palm_text_svc, bard_ask_img_svc

router = APIRouter()

Expand Down
4 changes: 2 additions & 2 deletions openaoe/backend/api/route_internlm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fastapi import APIRouter, Request

from ..model.dto.InternlmDto import InternlmChatCompletionReqDto
from ..service.service_internlm import chat_completion_v1, chat_completion_stream_v1
from openaoe.backend.model.dto.InternlmDto import InternlmChatCompletionReqDto
from openaoe.backend.service.service_internlm import chat_completion_v1, chat_completion_stream_v1

router = APIRouter()

Expand Down
4 changes: 2 additions & 2 deletions openaoe/backend/api/route_minimax.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fastapi import APIRouter, Request

from ..model.dto.MinimaxDto import MinimaxChatCompletionReqDto
from ..service.service_minimax import chat_completion, minimax_chat_stream_svc
from openaoe.backend.model.dto.MinimaxDto import MinimaxChatCompletionReqDto
from openaoe.backend.service.service_minimax import chat_completion, minimax_chat_stream_svc

router = APIRouter()

Expand Down
4 changes: 2 additions & 2 deletions openaoe/backend/api/route_openai.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from fastapi import APIRouter, Request

from ..model.dto.OpenaiDto import OpenaiCompletionReqDto, OpenaiChatStreamReqDto, \
from openaoe.backend.model.dto.OpenaiDto import OpenaiCompletionReqDto, OpenaiChatStreamReqDto, \
OpenaiChatCompletionV2ReqDto
from ..service.service_openai import completions, chat_completion_stream, chat_completion_svc, \
from openaoe.backend.service.service_openai import completions, chat_completion_stream, chat_completion_svc, \
proxy_files, proxy_assistants, proxy_threads, proxy_messages, proxy_runs

router = APIRouter()
Expand Down
4 changes: 2 additions & 2 deletions openaoe/backend/api/route_xunfei.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fastapi import APIRouter, Request

from ..model.dto.XunfeiDto import XunfeiSparkChatReqDto
from ..service.service_xunfei import spark_chat_svc
from openaoe.backend.model.dto.XunfeiDto import XunfeiSparkChatReqDto
from openaoe.backend.service.service_xunfei import spark_chat_svc

router = APIRouter()

Expand Down
2 changes: 1 addition & 1 deletion openaoe/backend/config/biz_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
import yaml

from ..util.log import log
from openaoe.backend.util.log import log
import os

logger = log(__name__)
Expand Down
10 changes: 5 additions & 5 deletions openaoe/backend/service/service_claude.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from slack_sdk.errors import SlackApiError
from sse_starlette.sse import EventSourceResponse

from ..config.biz_config import get_api_key
from ..config.constant import TYPE_BOT, TYPE_USER, TYPE_SYSTEM
from ..config.constant import VENDOR_CLAUDE
from ..model.dto.ClaudeDto import ClaudeChatReqDto, ClaudeMessage
from ..model.dto.ReturnBase import ReturnBase
from openaoe.backend.config.biz_config import get_api_key
from openaoe.backend.config.constant import TYPE_BOT, TYPE_USER, TYPE_SYSTEM
from openaoe.backend.config.constant import VENDOR_CLAUDE
from openaoe.backend.model.dto.ClaudeDto import ClaudeChatReqDto, ClaudeMessage
from openaoe.backend.model.dto.ReturnBase import ReturnBase


def send_message(client, channel, text):
Expand Down
10 changes: 5 additions & 5 deletions openaoe/backend/service/service_google.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from fastapi import Request
from fastapi.encoders import jsonable_encoder

from ..config.biz_config import get_api_key, get_base_url
from ..config.constant import *
from ..model.dto.GoogleDto import GooglePalmChatReqDto, GooglePalmTextReqDto, GoogleBardAskImgReqDto, \
from openaoe.backend.config.biz_config import get_api_key, get_base_url
from openaoe.backend.config.constant import *
from openaoe.backend.model.dto.GoogleDto import GooglePalmChatReqDto, GooglePalmTextReqDto, GoogleBardAskImgReqDto, \
GoogleSafetySetting
from ..model.dto.ReturnBase import ReturnBase
from ..util.log import log
from openaoe.backend.model.dto.ReturnBase import ReturnBase
from openaoe.backend.util.log import log

logger = log(__name__)

Expand Down
10 changes: 5 additions & 5 deletions openaoe/backend/service/service_internlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from fastapi.encoders import jsonable_encoder
from sse_starlette.sse import EventSourceResponse

from ..config.biz_config import get_base_url
from ..config.constant import *
from ..model.dto.InternlmDto import InternlmChatCompletionReqDto
from ..model.dto.ReturnBase import ReturnBase
from ..util.log import log
from openaoe.backend.config.biz_config import get_base_url
from openaoe.backend.config.constant import *
from openaoe.backend.model.dto.InternlmDto import InternlmChatCompletionReqDto
from openaoe.backend.model.dto.ReturnBase import ReturnBase
from openaoe.backend.util.log import log

logger = log(__name__)

Expand Down
10 changes: 5 additions & 5 deletions openaoe/backend/service/service_minimax.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from fastapi import Request
from sse_starlette.sse import EventSourceResponse

from ..config.biz_config import get_model_configuration, get_base_url
from ..config.constant import *
from ..model.dto.MinimaxDto import MinimaxChatCompletionReqDto
from ..model.dto.ReturnBase import ReturnBase
from ..util.log import log
from openaoe.backend.config.biz_config import get_model_configuration, get_base_url
from openaoe.backend.config.constant import *
from openaoe.backend.model.dto.MinimaxDto import MinimaxChatCompletionReqDto
from openaoe.backend.model.dto.ReturnBase import ReturnBase
from openaoe.backend.util.log import log

logger = log(__name__)

Expand Down
10 changes: 5 additions & 5 deletions openaoe/backend/service/service_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from openai import OpenAI
from sse_starlette.sse import EventSourceResponse

from ..config.biz_config import get_api_key, get_base_url
from ..config.constant import *
from ..model.dto.OpenaiDto import OpenaiChatCompletionReqDto, OpenaiCompletionReqDto, OpenaiChatCompletionV2ReqDto
from ..model.dto.ReturnBase import ReturnBase, ProxyReturnBase
from ..util.log import log
from openaoe.backend.config.biz_config import get_api_key, get_base_url
from openaoe.backend.config.constant import *
from openaoe.backend.model.dto.OpenaiDto import OpenaiChatCompletionReqDto, OpenaiCompletionReqDto, OpenaiChatCompletionV2ReqDto
from openaoe.backend.model.dto.ReturnBase import ReturnBase, ProxyReturnBase
from openaoe.backend.util.log import log

logger = log(__name__)

Expand Down
12 changes: 6 additions & 6 deletions openaoe/backend/service/service_xunfei.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
from fastapi import Request
from websocket import create_connection

from ..config.biz_config import get_model_configuration, get_base_url
from ..config.constant import VENDOR_XUNFEI
from ..model.dto.ReturnBase import ReturnBase
from ..model.dto.XunfeiDto import XunfeiSparkChatReqDto
from ..util.log import log
from ..util.time_util import get_current_date
from openaoe.backend.config.biz_config import get_model_configuration, get_base_url
from openaoe.backend.config.constant import VENDOR_XUNFEI
from openaoe.backend.model.dto.ReturnBase import ReturnBase
from openaoe.backend.model.dto.XunfeiDto import XunfeiSparkChatReqDto
from openaoe.backend.util.log import log
from openaoe.backend.util.time_util import get_current_date

logger = log(__name__)

Expand Down
4 changes: 2 additions & 2 deletions openaoe/backend/util/time_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from time import mktime
from wsgiref.handlers import format_date_time

from ..util.log import logger
from ..config.constant import DATE_PATTERN
from openaoe.backend.util.log import logger
from openaoe.backend.config.constant import DATE_PATTERN


def get_current_date() -> str:
Expand Down
Loading

0 comments on commit f41912e

Please sign in to comment.