From e0cf7472f437ec490307c8bff2fa1161e7bf51c5 Mon Sep 17 00:00:00 2001 From: Mohamed Chedli Date: Thu, 21 Nov 2024 19:40:29 +0100 Subject: [PATCH 1/3] feat: add HuggingFace login functionality --- nlu/main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nlu/main.py b/nlu/main.py index 6e0ac9d8..2de8f8d3 100644 --- a/nlu/main.py +++ b/nlu/main.py @@ -7,6 +7,7 @@ import boilerplate as tfbp from fastapi import Depends, FastAPI, HTTPException, status from pydantic import BaseModel import logging +from huggingface_hub import login # Set up logging configuration logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') @@ -17,6 +18,11 @@ AVAILABLE_LANGUAGES = os.getenv("AVAILABLE_LANGUAGES", "en,fr").split(',') TFLC_REPO_ID = os.getenv("TFLC_REPO_ID") INTENT_CLASSIFIER_REPO_ID = os.getenv("INTENT_CLASSIFIER_REPO_ID") SLOT_FILLER_REPO_ID = os.getenv("SLOT_FILLER_REPO_ID") +HF_AUTH_TOKEN = os.getenv("HF_AUTH_TOKEN") + +# Log in to HuggingFace using the provided access token +if HF_AUTH_TOKEN: + login(token=HF_AUTH_TOKEN) def load_language_classifier(): # Init language classifier model From 5d0450c1eb8af74a2fa8b4b7f49704bfd48adb8c Mon Sep 17 00:00:00 2001 From: Mohamed Chedli Date: Thu, 21 Nov 2024 19:50:53 +0100 Subject: [PATCH 2/3] feat: add huggingface access token to example environment file --- docker/.env.example | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker/.env.example b/docker/.env.example index 15d8284f..bcc8335b 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -64,3 +64,6 @@ APP_REDIS_PORT=9001 REDIS_ENABLED=false REDIS_HOST=redis REDIS_PORT=6379 + +# Huggingface Access token +HF_AUTH_TOKEN="" \ No newline at end of file From 1242c0c35e55a86833cc6098f6f1c40810648f54 Mon Sep 17 00:00:00 2001 From: Mohamed Chedli Date: Thu, 21 Nov 2024 20:06:23 +0100 Subject: [PATCH 3/3] fix: update HuggingFace access token example in environment file --- docker/.env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/.env.example b/docker/.env.example index bcc8335b..b268a760 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -66,4 +66,4 @@ REDIS_HOST=redis REDIS_PORT=6379 # Huggingface Access token -HF_AUTH_TOKEN="" \ No newline at end of file +HF_AUTH_TOKEN=