TDN-M commited on
Commit
95bfed4
·
verified ·
1 Parent(s): 9fe1456

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -6,14 +6,17 @@ import pdfkit
6
  from docx import Document
7
  from docx.shared import Pt
8
  from docx.oxml.ns import qn
 
9
 
10
  # Thiết lập API token từ Hugging Face
11
- api_token = "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"
 
 
12
 
13
  # Tải mô hình và tokenizer từ Hugging Face
14
  model_name = "meta-llama/Meta-Llama-3.1-8B-Instruct"
15
- tokenizer = AutoTokenizer.from_pretrained(model_name, token=api_token)
16
- model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, token=api_token).to("cuda")
17
 
18
  def analyze_chat(link, extraction_request, system_message, max_tokens, temperature, top_p):
19
  response = requests.get(link)
 
6
  from docx import Document
7
  from docx.shared import Pt
8
  from docx.oxml.ns import qn
9
+ import os
10
 
11
  # Thiết lập API token từ Hugging Face
12
+ api_token = os.getenv("api_token")
13
+ if api_token is None:
14
+ raise ValueError("API token is not set. Please set it in your Hugging Face settings.")
15
 
16
  # Tải mô hình và tokenizer từ Hugging Face
17
  model_name = "meta-llama/Meta-Llama-3.1-8B-Instruct"
18
+ tokenizer = AutoTokenizer.from_pretrained(model_name, use_auth_token=api_token)
19
+ model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, use_auth_token=api_token).to("cuda")
20
 
21
  def analyze_chat(link, extraction_request, system_message, max_tokens, temperature, top_p):
22
  response = requests.get(link)