from langchain_community.llms import HuggingFaceHub
hf=HuggingFaceHub(
repo_id="google/flan-t5-large",
task="text2text-generation", # Explicitly specify the task
model_kwargs={"temperature":0.7,"max_length":100},
huggingfacehub_api_token="hf_... Ue"
)
text="What is the capital of Turkey"
output=hf.invoke(text)
print(output)
ValueError: Task text2text-generation has no recommended model. Please specify a model explicitly. Visit Tasks - Hugging Face for more info.
Why I am getting this error. I just checked Api token multiple times and still give this error.
from langchain_huggingface.llms.huggingface_endpoint import HuggingFaceEndpoint
llm = HuggingFaceEndpoint(
task='text-generation',
model="deepseek-ai/DeepSeek-R1",
max_new_tokens=100,
temperature=0.7,
huggingfacehub_api_token="your_api"
)
print(llm.invoke("What is the capital of Turkey"))
bro can u give a slution for this too?? it is showing the same error
ValueError: Task text2text-generation has no recommended model. Please specify a model explicitly. Visit Tasks - Hugging Face for more info.