Seymour-Visions commited on
Commit
67d6ca7
·
verified ·
1 Parent(s): 7639d58

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -2,6 +2,8 @@ import gradio as gr
2
  from transformers import AutoModelForCausalLM, AutoTokenizer
3
  import torch
4
  import logging
 
 
5
 
6
  logging.basicConfig(level=logging.DEBUG)
7
  logger = logging.getLogger(__name__)
@@ -10,9 +12,17 @@ logger = logging.getLogger(__name__)
10
  with open("system_message.txt", "r") as file:
11
  system_message = file.read().strip()
12
 
 
 
 
 
 
 
 
 
13
  model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
14
- tokenizer = AutoTokenizer.from_pretrained(model_id)
15
- model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", torch_dtype=torch.float16)
16
 
17
  def respond(message, history):
18
  messages = [{"role": "system", "content": system_message}]
 
2
  from transformers import AutoModelForCausalLM, AutoTokenizer
3
  import torch
4
  import logging
5
+ from huggingface_hub import login
6
+ import os
7
 
8
  logging.basicConfig(level=logging.DEBUG)
9
  logger = logging.getLogger(__name__)
 
12
  with open("system_message.txt", "r") as file:
13
  system_message = file.read().strip()
14
 
15
+ # Get the Hugging Face token from the environment variable
16
+ hf_token = os.environ.get("testmix")
17
+ if not hf_token:
18
+ raise ValueError("testmix secret is not set in the environment variables")
19
+
20
+ # Authenticate with Hugging Face
21
+ login(token=hf_token)
22
+
23
  model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
24
+ tokenizer = AutoTokenizer.from_pretrained(model_id, use_auth_token=hf_token)
25
+ model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", torch_dtype=torch.float16, use_auth_token=hf_token)
26
 
27
  def respond(message, history):
28
  messages = [{"role": "system", "content": system_message}]