Skip to content

Commit

Permalink
Update HF token environment variable (#116)
Browse files Browse the repository at this point in the history
* Update TF token environment variable

Signed-off-by: lvliang-intel <liang1.lv@intel.com>

* add token

Signed-off-by: lvliang-intel <liang1.lv@intel.com>

---------

Signed-off-by: lvliang-intel <liang1.lv@intel.com>
  • Loading branch information
lvliang-intel authored May 31, 2024
1 parent 0e988f0 commit 3a2343c
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/megaservice-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
# - name: Run Workflow
# env:
# HUGGINGFACEHUB_API_TOKEN: ${{ secrets.HUGGINGFACEHUB_API_TOKEN }}
# HF_TOKEN: ${{ secrets.HF_TOKEN }}
# run: |
# xxx

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/microservice-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:

- name: Run microservice test
env:
HUGGINGFACEHUB_API_TOKEN: ${{ secrets.HUGGINGFACEHUB_API_TOKEN }}
HF_TOKEN: ${{ secrets.HF_TOKEN }}
service: ${{ matrix.service }}
hardware: ${{ matrix.hardware }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion comps/guardrails/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pip install -r requirements.txt
## 1.2 Start TGI Gaudi Service

```bash
export HUGGINGFACEHUB_API_TOKEN=${your_hf_api_token}
export HF_TOKEN=${your_hf_api_token}
export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_API_KEY=${your_langchain_api_key}
export LANGCHAIN_PROJECT="opea/gaurdrails"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ services:
- "8088:80"
volumes:
- "./data:/data"
environment:
HF_TOKEN: ${HF_TOKEN}
shm_size: 1g
command: --model-id ${LLM_MODEL_ID}
guardrails:
Expand All @@ -24,6 +26,7 @@ services:
https_proxy: ${https_proxy}
SAFETY_GUARD_ENDPOINT: ${SAFETY_GUARD_ENDPOINT}
LANGCHAIN_API_KEY: ${LANGCHAIN_API_KEY}
HUGGINGFACEHUB_API_TOKEN: ${HF_TOKEN}
restart: unless-stopped

networks:
Expand Down
6 changes: 3 additions & 3 deletions comps/llms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pip install -r requirements.txt
### 1.2.1 Start TGI Service

```bash
export HUGGINGFACEHUB_API_TOKEN=${your_hf_api_token}
export HF_TOKEN=${your_hf_api_token}
export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_API_KEY=${your_langchain_api_key}
export LANGCHAIN_PROJECT="opea/gen-ai-comps:llms"
Expand Down Expand Up @@ -115,7 +115,7 @@ If you start an LLM microservice with docker, the `docker_compose_llm.yaml` file
In order to start TGI and LLM services, you need to setup the following environment variables first.

```bash
export HUGGINGFACEHUB_API_TOKEN=${your_hf_api_token}
export HF_TOKEN=${your_hf_api_token}
export TGI_LLM_ENDPOINT="http://${your_ip}:8008"
export LLM_MODEL_ID=${your_hf_llm_model}
export LANGCHAIN_TRACING_V2=true
Expand Down Expand Up @@ -180,7 +180,7 @@ You can choose one as needed.
### 2.3.1 TGI

```bash
docker run -d --name="llm-tgi-server" -p 9000:9000 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e TGI_LLM_ENDPOINT=$TGI_LLM_ENDPOINT -e HUGGINGFACEHUB_API_TOKEN=$HUGGINGFACEHUB_API_TOKEN opea/llm-tgi:latest
docker run -d --name="llm-tgi-server" -p 9000:9000 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e TGI_LLM_ENDPOINT=$TGI_LLM_ENDPOINT -e HF_TOKEN=$HF_TOKEN opea/llm-tgi:latest
```

### 2.3.2 vLLM
Expand Down
4 changes: 3 additions & 1 deletion comps/llms/summarization/tgi/docker_compose_llm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ services:
- "8008:80"
volumes:
- "./data:/data"
environment:
HF_TOKEN: ${HF_TOKEN}
shm_size: 1g
command: --model-id ${LLM_MODEL_ID}
llm:
Expand All @@ -23,7 +25,7 @@ services:
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
TGI_LLM_ENDPOINT: ${TGI_LLM_ENDPOINT}
HUGGINGFACEHUB_API_TOKEN: ${HUGGINGFACEHUB_API_TOKEN}
HUGGINGFACEHUB_API_TOKEN: ${HF_TOKEN}
LANGCHAIN_API_KEY: ${LANGCHAIN_API_KEY}
restart: unless-stopped

Expand Down
6 changes: 3 additions & 3 deletions comps/llms/text-generation/ray_serve/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
bash ./launch_ray_service.sh
```

For gated models such as `LLAMA-2`, you need set the environment variable `HUGGING_FACE_HUB_TOKEN=<token>` to access the Hugging Face Hub.
For gated models such as `LLAMA-2`, you need set the environment variable `HF_TOKEN=<token>` to access the Hugging Face Hub.

Please follow this link [huggingface token](https://huggingface.co/docs/hub/security-tokens) to get the access token and export `HUGGINGFACEHUB_API_TOKEN` environment with the token.
Please follow this link [huggingface token](https://huggingface.co/docs/hub/security-tokens) to get the access token and export `HF_TOKEN` environment with the token.

```bash
export HUGGINGFACEHUB_API_TOKEN=<token>
export HF_TOKEN=<token>
```

And then you can make requests with the OpenAI-compatible APIs like below to check the service status:
Expand Down
2 changes: 1 addition & 1 deletion comps/llms/text-generation/tgi/docker_compose_llm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ services:
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
TGI_LLM_ENDPOINT: ${TGI_LLM_ENDPOINT}
HUGGINGFACEHUB_API_TOKEN: ${HUGGINGFACEHUB_API_TOKEN}
HF_TOKEN: ${HF_TOKEN}
LANGCHAIN_API_KEY: ${LANGCHAIN_API_KEY}
restart: unless-stopped

Expand Down
6 changes: 3 additions & 3 deletions comps/llms/text-generation/vllm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
bash ./serving/vllm/launch_vllm_service.sh
```

For gated models such as `LLAMA-2`, you will have to pass -e HUGGING_FACE_HUB_TOKEN=\<token\> to the docker run command above with a valid Hugging Face Hub read token.
For gated models such as `LLAMA-2`, you will have to pass -e HF_TOKEN=\<token\> to the docker run command above with a valid Hugging Face Hub read token.

Please follow this link [huggingface token](https://huggingface.co/docs/hub/security-tokens) to get the access token and export `HUGGINGFACEHUB_API_TOKEN` environment with the token.
Please follow this link [huggingface token](https://huggingface.co/docs/hub/security-tokens) to get the access token and export `HF_TOKEN` environment with the token.

```bash
export HUGGINGFACEHUB_API_TOKEN=<token>
export HF_TOKEN=<token>
```

And then you can make requests like below to check the service status:
Expand Down
6 changes: 3 additions & 3 deletions comps/reranks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pip install -r requirements.txt
## 1.2 Start TEI Service

```bash
export HUGGINGFACEHUB_API_TOKEN=${your_hf_api_token}
export HF_TOKEN=${your_hf_api_token}
export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_API_KEY=${your_langchain_api_key}
export LANGCHAIN_PROJECT="opea/reranks"
Expand Down Expand Up @@ -48,7 +48,7 @@ If you start an Reranking microservice with docker, the `docker_compose_rerankin
## 2.1 Setup Environment Variables

```bash
export HUGGINGFACEHUB_API_TOKEN=${your_hf_api_token}
export HF_TOKEN=${your_hf_api_token}
export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_API_KEY=${your_langchain_api_key}
export LANGCHAIN_PROJECT="opea/reranks"
Expand All @@ -72,7 +72,7 @@ You can choose one as needed.
## 2.3 Run Docker with CLI (Option A)

```bash
docker run -d --name="reranking-tei-server" -p 8000:8000 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e TEI_RERANKING_ENDPOINT=$TEI_RERANKING_ENDPOINT -e HUGGINGFACEHUB_API_TOKEN=$HUGGINGFACEHUB_API_TOKEN -e LANGCHAIN_API_KEY=$LANGCHAIN_API_KEY opea/reranking-tei:latest
docker run -d --name="reranking-tei-server" -p 8000:8000 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e TEI_RERANKING_ENDPOINT=$TEI_RERANKING_ENDPOINT -e HF_TOKEN=$HF_TOKEN -e LANGCHAIN_API_KEY=$LANGCHAIN_API_KEY opea/reranking-tei:latest
```

## 2.4 Run Docker with Docker Compose (Option B)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ services:
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
TEI_RERANKING_ENDPOINT: ${TEI_RERANKING_ENDPOINT}
HUGGINGFACEHUB_API_TOKEN: ${HUGGINGFACEHUB_API_TOKEN}
HF_TOKEN: ${HF_TOKEN}
LANGCHAIN_API_KEY: ${LANGCHAIN_API_KEY}
restart: unless-stopped

Expand Down
6 changes: 3 additions & 3 deletions tests/test_llms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ function build_docker_images() {
function start_service() {
tgi_endpoint_port=5004
export your_hf_llm_model="Intel/neural-chat-7b-v3-3"
# Remember to set HUGGINGFACEHUB_API_TOKEN before invoking this test!
export HUGGINGFACEHUB_API_TOKEN=${HUGGINGFACEHUB_API_TOKEN}
# Remember to set HF_TOKEN before invoking this test!
export HF_TOKEN=${HF_TOKEN}
docker run -d --name="test-comps-llm-tgi-endpoint" -p $tgi_endpoint_port:80 -v ./data:/data --shm-size 1g ghcr.io/huggingface/text-generation-inference:1.4 --model-id ${your_hf_llm_model}
export TGI_LLM_ENDPOINT="http://${ip_address}:${tgi_endpoint_port}"

tei_service_port=5005
unset http_proxy
docker run -d --name="test-comps-llm-tgi-server" -p ${tei_service_port}:9000 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e TGI_LLM_ENDPOINT=$TGI_LLM_ENDPOINT -e HUGGINGFACEHUB_API_TOKEN=$HUGGINGFACEHUB_API_TOKEN opea/llm-tgi:comps
docker run -d --name="test-comps-llm-tgi-server" -p ${tei_service_port}:9000 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e TGI_LLM_ENDPOINT=$TGI_LLM_ENDPOINT -e HF_TOKEN=$HF_TOKEN opea/llm-tgi:comps

# check whether tgi is fully ready
n=0
Expand Down
6 changes: 3 additions & 3 deletions tests/test_reranks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ function build_docker_images() {

function start_service() {
tei_endpoint=5006
# Remember to set HUGGINGFACEHUB_API_TOKEN before invoking this test!
export HUGGINGFACEHUB_API_TOKEN=${HUGGINGFACEHUB_API_TOKEN}
# Remember to set HF_TOKEN before invoking this test!
export HF_TOKEN=${HF_TOKEN}
model=BAAI/bge-reranker-large
revision=refs/pr/4
volume=$PWD/data
Expand All @@ -23,7 +23,7 @@ function start_service() {
export TEI_RERANKING_ENDPOINT="http://${ip_address}:${tei_endpoint}"
tei_service_port=5007
unset http_proxy
docker run -d --name="test-comps-reranking-tei-server" -p ${tei_service_port}:8000 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e TEI_RERANKING_ENDPOINT=$TEI_RERANKING_ENDPOINT -e HUGGINGFACEHUB_API_TOKEN=$HUGGINGFACEHUB_API_TOKEN opea/reranking-tei:comps
docker run -d --name="test-comps-reranking-tei-server" -p ${tei_service_port}:8000 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e TEI_RERANKING_ENDPOINT=$TEI_RERANKING_ENDPOINT -e HF_TOKEN=$HF_TOKEN opea/reranking-tei:comps
sleep 1m
}

Expand Down

0 comments on commit 3a2343c

Please sign in to comment.