What is the issue i below code, am getting the below error even after the authentication, what is incorrect in this #134527
Replies: 1 comment
-
The Just modify the code---- import os os.environ["HUGGINGFACEHUB_API_TOKEN"] = "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" llm = HuggingFaceLLM( Ensure the token is correctly set as an environment variable. print(os.environ.get("HUGGINGFACEHUB_API_TOKEN")) This approach uses the environment variable for authentication, which is the correct method for libraries that rely on external API tokens. |
Beta Was this translation helpful? Give feedback.
-
Body
Error :
TypeError: HuggingFaceLLM.init() got an unexpected keyword argument 'HUGGINGFACEHUB_API_TOKEN'
if am removing the token details from below code then am getting authentication error
!pip install llama-index-llms-huggingface
import torch
from llama_index.llms.huggingface import HuggingFaceLLM
import os
Retrieve your token from the environment variable
huggingface_token = os.environ.get("HUGGINGFACEHUB_API_TOKEN")
llm = HuggingFaceLLM(
context_window=4096,
max_new_tokens=256,
generate_kwargs={"temperature": 0.7, "do_sample": False},
system_prompt=system_prompt,
query_wrapper_prompt=query_wrapper_prompt,
tokenizer_name="mistralai/Mistral-7B-Instruct-v0.1",
model_name="mistralai/Mistral-7B-Instruct-v0.1",
device_map="auto",
stopping_ids=[50278, 50279, 50277, 1, 0],
tokenizer_kwargs={"max_length": 4096},
# uncomment this if using CUDA to reduce memory usage
model_kwargs={"torch_dtype": torch.float16},
# Pass the token to the constructor
HUGGINGFACEHUB_API_TOKEN = "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"
)
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions