mirror of
https://github.com/Canner/WrenAI.git
synced 2026-09-24 23:29:49 +08:00
refine readme (#392)
* update readme * update poetry version to 1.8.3 * explicitly use uvloop * explicitly using httptools * use ORJSON * refine readme
This commit is contained in:
@@ -29,7 +29,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version: [ "3.12.0" ]
|
||||
poetry-version: [ "1.7.1" ]
|
||||
poetry-version: [ "1.8.3" ]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -36,7 +36,7 @@ jobs:
|
||||
- name: Install Poetry
|
||||
uses: abatilo/actions-poetry@v2
|
||||
with:
|
||||
poetry-version: 1.7.1
|
||||
poetry-version: 1.8.3
|
||||
- name: Upgrade AI Service version
|
||||
run: |
|
||||
version=${{ github.event.inputs.version }}
|
||||
|
||||
@@ -49,6 +49,13 @@ stop-all:
|
||||
make stop-wren-engine && \
|
||||
make stop-redis
|
||||
|
||||
ui:
|
||||
cd ../wren-ui; export DB_TYPE=sqlite export SQLITE_FILE=db.sqlite3 export WREN_AI_ENDPOINT=http://localhost:5556 && \
|
||||
yarn install && yarn rollback --all && yarn migrate && yarn dev
|
||||
|
||||
demo:
|
||||
cd demo; poetry run streamlit run app.py
|
||||
|
||||
# present the evaluation result on the streamlit app
|
||||
# example: make streamlit pipeline=ask_details
|
||||
streamlit:
|
||||
|
||||
@@ -7,7 +7,7 @@ Please read the [documentation](https://docs.getwren.ai/concept/wren_ai_service)
|
||||
## Environment Setup
|
||||
|
||||
- Python 3.12.0, recommended to use [`pyenv`](https://github.com/pyenv/pyenv?tab=readme-ov-file#installation) to manage the Python versions
|
||||
- install `poetry` with version 1.7.1: `curl -sSL https://install.python-poetry.org | python3 - --version 1.7.1`
|
||||
- install `poetry` with version 1.8.3: `curl -sSL https://install.python-poetry.org | python3 - --version 1.8.3`
|
||||
- execute `poetry install` to install the dependencies
|
||||
- copy `.env.example` file to `.env`, and `.env.dev.example` file to `.env.dev` and fill in the environment variables
|
||||
- [for development] execute `poetry run pre-commit install` to install the pre-commit hooks and `poetry run pre-commit run --all-files` to run the pre-commit checks at the first time to check if everything is set up correctly
|
||||
@@ -15,13 +15,15 @@ Please read the [documentation](https://docs.getwren.ai/concept/wren_ai_service)
|
||||
|
||||
## Start the service for development
|
||||
|
||||
- execute `make run-all` to start needed containers (e.g. qdrant, wren-engine)
|
||||
- execute `make ui` to start the ui
|
||||
- execute `make start` to start the service and go to `http://WREN_AI_SERVICE_HOST:WREN_AI_SERVICE_PORT` to see the API documentation and try the APIs
|
||||
|
||||
## Production Environment Setup
|
||||
|
||||
- copy `.env.prod.example` file to `.env.prod` and fill in the environment variables
|
||||
- `make build` to build the docker image
|
||||
- `make up` to run the docker container
|
||||
- `make up` to run the wren-ai-service
|
||||
- `make down` to stop the docker container
|
||||
|
||||
## Pipeline Evaluation(for development)
|
||||
@@ -56,17 +58,11 @@ Please read the [documentation](https://docs.getwren.ai/concept/wren_ai_service)
|
||||
|
||||
## Demo
|
||||
|
||||
- prerequisites
|
||||
- install and run the docker service, and you should stop all WrenAI services first before running the demo
|
||||
- go to the `../docker` folder and prepare the `.env.local` file
|
||||
- make sure the node version is v16.19.0
|
||||
- if you are using Python 3.12+, please also install `setuptools` in order to successfully install the dependencies of the wren-ui service
|
||||
- go to the `demo` folder and create a `.env` file and fill in the environment variables if you want to use BigQuery as data source
|
||||
- go to the `demo` folder and run `poetry install` to install the dependencies
|
||||
- in the `demo` folder, open three terminals
|
||||
- in the first terminal, run `make prepare` to start the docker containers and `make run` to start the demo service
|
||||
- in the second terminal, run `make ui` to start the wren-ui service
|
||||
- in the third terminal, run `make ai` to start the wren-ai service
|
||||
- in the `wren-ai-service` folder, open three terminals
|
||||
- in the first terminal, run `make run-all` to start the docker containers and `make ui` to start the wren-ui service
|
||||
- in the second terminal, run `make start` to start the wren-ai service
|
||||
- in the third terminal, run `make demo` to start the demo service
|
||||
- ports of the services:
|
||||
- wren-engine: ports should be 8080
|
||||
- wren-ai-service: port should be 5556
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
prepare:
|
||||
cd ../../docker; docker compose --env-file .env.local -f docker-compose-dev.yaml up -d
|
||||
|
||||
stop:
|
||||
cd ../../docker; docker compose --env-file .env.local -f docker-compose-dev.yaml down
|
||||
|
||||
ui:
|
||||
cd ../../wren-ui; export DB_TYPE=sqlite export SQLITE_FILE=db.sqlite3 export WREN_AI_ENDPOINT=http://localhost:5556 && \
|
||||
yarn install && yarn rollback --all && yarn migrate && yarn dev
|
||||
|
||||
ai:
|
||||
cd ..; make start
|
||||
|
||||
run:
|
||||
poetry run streamlit run app.py
|
||||
@@ -23,4 +23,4 @@ COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
|
||||
|
||||
COPY src src
|
||||
|
||||
ENTRYPOINT python -m src.pre_run && uvicorn src.__main__:app --host 0.0.0.0 --port $WREN_AI_SERVICE_PORT --workers $WORKERS
|
||||
ENTRYPOINT python -m src.pre_run && uvicorn src.__main__:app --host 0.0.0.0 --port $WREN_AI_SERVICE_PORT --workers $WORKERS --loop uvloop --http httptools
|
||||
@@ -6,7 +6,7 @@ import uvicorn
|
||||
from fastapi import FastAPI
|
||||
from fastapi.exceptions import RequestValidationError
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import JSONResponse, RedirectResponse
|
||||
from fastapi.responses import ORJSONResponse, RedirectResponse
|
||||
|
||||
import src.globals as container
|
||||
from src.utils import load_env_vars, setup_custom_logger
|
||||
@@ -32,7 +32,7 @@ async def lifespan(app: FastAPI):
|
||||
# shutdown events
|
||||
|
||||
|
||||
app = FastAPI(lifespan=lifespan, redoc_url=None)
|
||||
app = FastAPI(lifespan=lifespan, redoc_url=None, default_response_class=ORJSONResponse)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
@@ -50,7 +50,7 @@ if env == "dev":
|
||||
|
||||
@app.exception_handler(Exception)
|
||||
async def exception_handler(request, exc: Exception):
|
||||
return JSONResponse(
|
||||
return ORJSONResponse(
|
||||
status_code=500,
|
||||
content={"detail": str(exc)},
|
||||
)
|
||||
@@ -58,7 +58,7 @@ async def exception_handler(request, exc: Exception):
|
||||
|
||||
@app.exception_handler(RequestValidationError)
|
||||
async def request_exception_handler(request, exc: Exception):
|
||||
return JSONResponse(
|
||||
return ORJSONResponse(
|
||||
status_code=400,
|
||||
content={"detail": str(exc)},
|
||||
)
|
||||
@@ -92,4 +92,6 @@ if __name__ == "__main__":
|
||||
reload=should_reload,
|
||||
reload_dirs=["src"] if should_reload else None,
|
||||
workers=num_workers,
|
||||
loop="uvloop",
|
||||
http="httptools",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user