Fix Langchain upstream ut (#10985)
* Fix Langchain upstream ut * Small fix * Install bigdl-llm * Update run-langchain-upstream-tests.sh * Update run-langchain-upstream-tests.sh * Update llm_unit_tests.yml * Update run-langchain-upstream-tests.sh * Update llm_unit_tests.yml * Update run-langchain-upstream-tests.sh * fix git checkout * fix --------- Co-authored-by: Zhangky11 <2321096202@qq.com> Co-authored-by: Keyan (Kyrie) Zhang <79576162+Zhangky11@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									9f6358e4c2
								
							
						
					
					
						commit
						f8dd2e52ad
					
				
					 2 changed files with 31 additions and 16 deletions
				
			
		
							
								
								
									
										17
									
								
								.github/workflows/llm_unit_tests.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										17
									
								
								.github/workflows/llm_unit_tests.yml
									
									
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -380,7 +380,23 @@ jobs:
 | 
			
		|||
            source /home/arda/intel/oneapi/setvars.sh
 | 
			
		||||
          fi
 | 
			
		||||
          bash python/llm/test/run-llm-example-tests-gpu.sh
 | 
			
		||||
          
 | 
			
		||||
      - name: Get Langchain version
 | 
			
		||||
        shell: bash
 | 
			
		||||
        id: get_langchain_version
 | 
			
		||||
        run: |
 | 
			
		||||
          pip install langchain
 | 
			
		||||
          LANGCHAIN_VERSION=$(pip show langchain | grep Version | cut -d " " -f 2)
 | 
			
		||||
          LANGCHAIN_REF="langchain==$LANGCHAIN_VERSION"
 | 
			
		||||
          echo "langchain_ver=$LANGCHAIN_REF" >> $GITHUB_OUTPUT
 | 
			
		||||
 | 
			
		||||
      - name: Checkout Langchain repo
 | 
			
		||||
        uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
 | 
			
		||||
        with:
 | 
			
		||||
          repository: "langchain-ai/langchain"
 | 
			
		||||
          ref: ${{ join(steps.get_langchain_version.outputs.*, '\n') }}
 | 
			
		||||
          path: langchain_upstream
 | 
			
		||||
            
 | 
			
		||||
      - name: Run LLM langchain GPU test
 | 
			
		||||
        shell: bash
 | 
			
		||||
        run: |
 | 
			
		||||
| 
						 | 
				
			
			@ -397,6 +413,7 @@ jobs:
 | 
			
		|||
          
 | 
			
		||||
          pip install -U langchain
 | 
			
		||||
          pip install -U langchain-community
 | 
			
		||||
          pip install --pre --upgrade bigdl-llm[all]
 | 
			
		||||
          bash python/llm/test/run-langchain-upstream-tests.sh
 | 
			
		||||
 | 
			
		||||
      - name: Run LLM llamaindex GPU test
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,25 +1,23 @@
 | 
			
		|||
export ANALYTICS_ZOO_ROOT=${ANALYTICS_ZOO_ROOT}
 | 
			
		||||
export LLM_HOME=${ANALYTICS_ZOO_ROOT}/python/llm/src
 | 
			
		||||
export LLM_INFERENCE_TEST_DIR=${ANALYTICS_ZOO_ROOT}/python/llm/test/langchain_gpu
 | 
			
		||||
 | 
			
		||||
export VICUNA_7B_1_3_ORIGIN_PATH=${VICUNA_7B_1_3_ORIGIN_PATH}
 | 
			
		||||
export TEST_BIGDLLLM_MODEL_IDS=${VICUNA_7B_1_3_ORIGIN_PATH}
 | 
			
		||||
export TEST_IPEXLLM_MODEL_IDS=${VICUNA_7B_1_3_ORIGIN_PATH}
 | 
			
		||||
 | 
			
		||||
set -e
 | 
			
		||||
 | 
			
		||||
echo ">>> Testing LangChain upstream unit test"
 | 
			
		||||
mkdir ${LLM_INFERENCE_TEST_DIR}/langchain_upstream
 | 
			
		||||
wget https://raw.githubusercontent.com/langchain-ai/langchain/master/libs/community/tests/integration_tests/llms/test_bigdl_llm.py -P ${LLM_INFERENCE_TEST_DIR}/langchain_upstream
 | 
			
		||||
wget https://raw.githubusercontent.com/langchain-ai/langchain/master/libs/community/tests/integration_tests/llms/test_ipex_llm.py -P ${LLM_INFERENCE_TEST_DIR}/langchain_upstream
 | 
			
		||||
sed -i "s,model_id=\"[^\"]*\",model_id=\"$VICUNA_7B_1_3_ORIGIN_PATH\",g" ${LLM_INFERENCE_TEST_DIR}/langchain_upstream/test_bigdl_llm.py
 | 
			
		||||
sed -i "s,model_id=\"[^\"]*\",model_id=\"$VICUNA_7B_1_3_ORIGIN_PATH\",g" ${LLM_INFERENCE_TEST_DIR}/langchain_upstream/test_ipex_llm.py
 | 
			
		||||
sed -i 's/langchain_community.llms.ipex_llm/langchain_community.llms/g' ${LLM_INFERENCE_TEST_DIR}/langchain_upstream/test_ipex_llm.py
 | 
			
		||||
python -m pytest -s ${LLM_INFERENCE_TEST_DIR}/langchain_upstream
 | 
			
		||||
cp ${ANALYTICS_ZOO_ROOT}/langchain_upstream/libs/community/tests/integration_tests/llms/test_bigdl_llm.py ${ANALYTICS_ZOO_ROOT}/langchain_upstream
 | 
			
		||||
cp ${ANALYTICS_ZOO_ROOT}/langchain_upstream/libs/community/tests/integration_tests/llms/test_ipex_llm.py ${ANALYTICS_ZOO_ROOT}/langchain_upstream
 | 
			
		||||
 | 
			
		||||
python -m pytest -s ${ANALYTICS_ZOO_ROOT}/langchain_upstream/test_bigdl_llm.py
 | 
			
		||||
python -m pytest -s ${ANALYTICS_ZOO_ROOT}/langchain_upstream/test_ipex_llm.py
 | 
			
		||||
 | 
			
		||||
echo ">>> Testing LangChain upstream ipynb"
 | 
			
		||||
wget https://raw.githubusercontent.com/langchain-ai/langchain/master/docs/docs/integrations/llms/ipex_llm.ipynb -P ${LLM_INFERENCE_TEST_DIR}/langchain_upstream
 | 
			
		||||
mv ${LLM_INFERENCE_TEST_DIR}/langchain_upstream/ipex_llm.ipynb ${LLM_INFERENCE_TEST_DIR}/langchain_upstream/langchain_example.ipynb
 | 
			
		||||
bash ./apps/ipynb2py.sh ${LLM_INFERENCE_TEST_DIR}/langchain_upstream/langchain_example
 | 
			
		||||
sed -i '/^get_ipython/d' ${LLM_INFERENCE_TEST_DIR}/langchain_upstream/langchain_example.py
 | 
			
		||||
sed -i "s,model_id=\"[^\"]*\",model_id=\"$VICUNA_7B_1_3_ORIGIN_PATH\",g" ${LLM_INFERENCE_TEST_DIR}/langchain_upstream/langchain_example.py
 | 
			
		||||
python ${LLM_INFERENCE_TEST_DIR}/langchain_upstream/langchain_example.py
 | 
			
		||||
rm -rf ${LLM_INFERENCE_TEST_DIR}/langchain_upstream
 | 
			
		||||
cp ${ANALYTICS_ZOO_ROOT}/langchain_upstream/docs/docs/integrations/llms/ipex_llm.ipynb ${ANALYTICS_ZOO_ROOT}/langchain_upstream/langchain_example.ipynb
 | 
			
		||||
bash ./apps/ipynb2py.sh ${ANALYTICS_ZOO_ROOT}/langchain_upstream/langchain_example
 | 
			
		||||
sed -i '/^get_ipython/d' ${ANALYTICS_ZOO_ROOT}/langchain_upstream/langchain_example.py
 | 
			
		||||
sed -i "s,model_id=\"[^\"]*\",model_id=\"$TEST_IPEXLLM_MODEL_IDS\",g" ${ANALYTICS_ZOO_ROOT}/langchain_upstream/langchain_example.py
 | 
			
		||||
sed -i 's|saved_lowbit_model_path = "./vicuna-7b-1.5-low-bit"|saved_lowbit_model_path = "./langchain_upstream/vicuna-7b-1.5-low-bit"|' ${ANALYTICS_ZOO_ROOT}/langchain_upstream/langchain_example.py
 | 
			
		||||
python ${ANALYTICS_ZOO_ROOT}/langchain_upstream/langchain_example.py
 | 
			
		||||
rm -rf ${ANALYTICS_ZOO_ROOT}/langchain_upstream
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue