from fastapi import FastAPI from fastapi.responses import RedirectResponse from langserve import add_routes from langchain_community.llms.huggingface_pipeline import HuggingFacePipeline from transformers import pipeline from langchain_openai import ChatOpenAI from langchain_core.output_parsers import StrOutputParser from langchain_core.prompts import ChatPromptTemplate from starlette.requests import Request from starlette.responses import JSONResponse, Response from dotenv import load_dotenv from transformers import AutoTokenizer, pipeline import torch import requests
# 필요한 시스템 패키지 설치 RUN apt-get clean && apt-get update && apt-get install -y --no-install-recommends \ build-essential \ && rm -rf /var/lib/apt/lists/*
# requirements 파일들 및 미리 다운로드한 패키지 복사 COPY requirements1.txt . COPY requirements2.txt . COPY packages /app/packages
# 첫 번째 requirements 파일 설치 RUN pip install --no-cache-dir -r requirements1.txt --default-timeout=300 -i https://pypi.tuna.tsinghua.edu.cn/simple
# 두 번째 requirements 파일 설치 (미리 다운로드한 패키지 포함) RUN pip install --no-cache-dir -r requirements2.txt --find-links=/app/packages --default-timeout=300 --extra-index-url https://pypi.nvidia.com
# 애플리케이션 소스 코드 복사 COPY . .
# FastAPI 서버 실행 CMD ["uvicorn", "app.server:app", "--host", "0.0.0.0", "--port", "5002"]
% docker run --name lm-test-server -p 5002:5002 lm-test-server:20240724
/usr/local/lib/python3.11/site-packages/langchain_core/_api/deprecation.py:139: LangChainDeprecationWarning: The class `HuggingFacePipeline` was deprecated in LangChain 0.0.37 and will be removed in 0.3. An updated version of the class exists in the langchain-huggingface package and should be used instead. To use it run `pip install -U langchain-huggingface` and import as `from langchain_huggingface import HuggingFacePipeline`. warn_deprecated( INFO: Started server process [1] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:5002 (Press CTRL+C to quit)
LANGSERVE: Playground for chain "/openai/" is live at: LANGSERVE: │ LANGSERVE: └──> /openai/playground/ LANGSERVE: LANGSERVE: Playground for chain "/t5-small/" is live at: LANGSERVE: │ LANGSERVE: └──> /t5-small/playground/ LANGSERVE: LANGSERVE: See all available routes at /docs/
LANGSERVE: ⚠️ Using pydantic 2.8.2. OpenAPI docs for invoke, batch, stream, stream_log endpoints will not be generated. API endpoints and playground should work as expected. If you need to see the docs, you can downgrade to pydantic 1. For example, `pip install pydantic==1.10.13`. See https://github.com/tiangolo/fastapi/issues/10360 for details.
Installing the current project: orchestrator (0.1.0)
/root/.cache/pypoetry/virtualenvs/orchestrator-9TtSrW0h-py3.10/lib/python3.10/site-packages/langchain/chat_models/__init__.py:31: LangChainDeprecationWarning: Importing chat models from langchain is deprecated. Importing from langchain will no longer be supported as of langchain==0.2.0. Please import from langchain-community instead:
ERROR: [Errno 99] error while attempting to bind on address ('::1', 8002, 0, 0): cannot assign requested address
INFO: Waiting for application shutdown.
INFO: Application shutdown complete.
The token has not been saved to the git credentials helper. Pass `add_to_git_credential=True` in this function directly or `--add-to-git-credential` if using via `huggingface-cli` if you want to set the git credential as well.
Token is valid (permission: fineGrained).
Your token has been saved to /root/.cache/huggingface/token
Login successful
main.py 수정
src/main.py 파일에서 서버를 실행하는 부분을 확인하고, host 매개변수를 0.0.0.0으로 설정