diff --git a/Dockerfile b/Dockerfile index 48eeebc8..59db3639 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,53 @@ -# 构建 sudo docker build --network=host -t memoryscope . -# 运行 sudo docker run -it --rm --net=host memoryscope +# __ __ ____ +# | \/ | ___ _ __ ___ ___ _ __ _ _/ ___| ___ ___ _ __ ___ +# | |\/| |/ _ \ '_ ` _ \ / _ \| '__| | | \___ \ / __/ _ \| '_ \ / _ \ +# | | | | __/ | | | | | (_) | | | |_| |___) | (_| (_) | |_) | __/ +# |_| |_|\___|_| |_| |_|\___/|_| \__, |____/ \___\___/| .__/ \___| +# |___/ |_| + +# Instruction + +# To construct docker image: +# sudo docker build --network=host -t memoryscope . + +# To run docker image: +# sudo docker run -it --rm --net=host memoryscope + + + FROM python:3.11 -# 非必要步骤,更换pip源 (以下三行,可以删除) +# (Not necessary) Change pip source RUN echo '[global]' > /etc/pip.conf && \ echo 'index-url = https://mirrors.aliyun.com/pypi/simple/' >> /etc/pip.conf && \ echo 'trusted-host = mirrors.aliyun.com' >> /etc/pip.conf -# 安装大部分依赖,利用Docker缓存加速以后的构建 (以下两行,可以删除) +# (Not necessary) Install the majority of deps, using docker build cache to accelerate future building COPY requirements.txt ./ RUN pip3 install -r requirements.txt -# 进入工作路径(必要) +# Install Elastic Search +RUN useradd -m elastic_search_user +USER elastic_search_user +WORKDIR /home/elastic_search_user/elastic_search +# COPY elasticsearch-8.15.0-linux-x86_64.tar.gz ./elasticsearch-8.15.0-linux-x86_64.tar.gz +RUN wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.15.0-linux-x86_64.tar.gz +RUN tar -xzf elasticsearch-8.15.0-linux-x86_64.tar.gz +WORKDIR /home/elastic_search_user/elastic_search/elasticsearch-8.15.0 +ENV DISCOVERY_TYPE=single-node \ + XPACK_SECURITY_ENABLED=false \ + XPACK_LICENSE_SELF_GENERATED_TYPE=trial + +# Change user back to root and fix ownership +USER root +RUN chown -R elastic_search_user:elastic_search_user /home/elastic_search_user/ +WORKDIR /memory_scope_project + +# Enter working dir WORKDIR /memory_scope_project COPY . . RUN pip install -r requirements.txt -# 启动(必要) -CMD ["python3", "memory_scope/cli.py", "config/demo_config_cn.yaml"] +# Launch! +# CMD ["bash"] +CMD ["bash", "examples/docker/entry_point.sh"] \ No newline at end of file diff --git a/examples/docker/entry_point.sh b/examples/docker/entry_point.sh new file mode 100644 index 00000000..e296a67d --- /dev/null +++ b/examples/docker/entry_point.sh @@ -0,0 +1,2 @@ +sh examples/docker/run_elastic_search.sh +python quick_start_demo.py --config_path=memoryscope/core/config/demo_config.yaml \ No newline at end of file diff --git a/examples/docker/run_elastic_search.sh b/examples/docker/run_elastic_search.sh new file mode 100644 index 00000000..98b55aa3 --- /dev/null +++ b/examples/docker/run_elastic_search.sh @@ -0,0 +1 @@ +su - elastic_search_user -c "/home/elastic_search_user/elastic_search/elasticsearch-8.15.0/bin/elasticsearch -d" \ No newline at end of file diff --git a/memoryscope/core/config/demo_config.yaml b/memoryscope/core/config/demo_config.yaml index 28b25cac..497690ed 100644 --- a/memoryscope/core/config/demo_config.yaml +++ b/memoryscope/core/config/demo_config.yaml @@ -157,14 +157,14 @@ worker: model: generation_model: class: core.models.llama_index_generation_model - module_name: openai_generation - model_name: gpt-4o + module_name: dashscope_generation + model_name: qwen-max max_tokens: 2000 temperature: 0.01 embedding_model: class: core.models.llama_index_embedding_model - module_name: openai_embedding - model_name: text-embedding-3-small + module_name: dashscope_embedding + model_name: text-embedding-v2 rank_model: class: core.models.llama_index_rank_model module_name: dashscope_rank diff --git a/quick_start_demo.py b/quick_start_demo.py new file mode 100644 index 00000000..b6093536 --- /dev/null +++ b/quick_start_demo.py @@ -0,0 +1,7 @@ +import os + +if os.environ.get('DASHSCOPE_API_KEY', None) is None: + os.environ['DASHSCOPE_API_KEY'] = input('Missing api key from dashscope ( https:// ???? ), please input key and press Enter:') + +from memoryscope import cli +cli() \ No newline at end of file