sundeepsingh01 commited on
Commit
9f6dae2
·
verified ·
1 Parent(s): 71eb73d

Create handler.py

Browse files
Files changed (1) hide show
  1. handler.py +22 -0
handler.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Dict, List, Any
2
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, pipeline
3
+ from langchain_huggingface import HuggingFacePipeline, ChatHuggingFace, HuggingFaceEndpoint
4
+ import torch
5
+
6
+ class EndpointHandler:
7
+ def __init__(self, path1="Cognute02/llama_3_1_8B_4bit"):
8
+ # load model and processor from path
9
+ llm = HuggingFaceEndpoint(
10
+ repo_id="Cognute02/llama_3_1_8B_4bit",
11
+ max_new_tokens=256,
12
+ top_k=10,
13
+ top_p=0.25,
14
+ temperature=0.25,
15
+ repetition_penalty=1.03,
16
+ huggingfacehub_api_token="hf"+"_"+"tlVzheuQBwjAxOtNKPqnHSQprFYnDLllut"
17
+ )
18
+
19
+ self.chatllm = ChatHuggingFace(llm=llm)
20
+
21
+ def __call__(self):
22
+ return self.chatllm