File size: 759 Bytes
912584a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
from langchain_huggingface import ChatHuggingFace, HuggingFaceEndpoint
import os
from dotenv import load_dotenv
load_dotenv()
llm=''
chat_model=''
HF_TOKEN=os.getenv("HF_TOKEN")
def init_llama_chatmodel(repo_id):
global llm
global chat_model
llm = HuggingFaceEndpoint(
repo_id=repo_id,
task="text-generation"
)
chat_model = ChatHuggingFace(llm=llm)
return chat_model
# def get_llama_endpoint(repo_id):
# llm = HuggingFaceEndpoint(
# repo_id=repo_id,
# task="text-generation",
# max_new_tokens=512,
# do_sample=False,
# repetition_penalty=1.03,
# )
# return llm
# def get_llama_chatmodel(llm):
# chat_model = ChatHuggingFace(llm=llm)
# return chat_model
|