odaly commited on
Commit
ca9ae0b
·
verified ·
1 Parent(s): a07e57d

update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -1,12 +1,18 @@
 
1
  import streamlit as st
2
  import transformers
3
  import torch
4
- import os
5
  import time
6
 
 
 
 
 
 
 
7
  # Initialize the model and tokenizer using Hugging Face pipeline
8
  model_id = "meta-llama/Meta-Llama-3.1-70B"
9
- pipeline = transformers.pipeline("text-generation", model=model_id)
10
 
11
  def generate_response(prompt):
12
  # Generate a response using the pipeline
 
1
+ import os
2
  import streamlit as st
3
  import transformers
4
  import torch
 
5
  import time
6
 
7
+ # Read Hugging Face API Token from environment variable
8
+ hf_token = os.getenv("HUGGING_FACE_API_TOKEN")
9
+ if not hf_token:
10
+ st.error("Hugging Face API token not found. Please set the HUGGING_FACE_API_TOKEN environment variable.")
11
+ st.stop()
12
+
13
  # Initialize the model and tokenizer using Hugging Face pipeline
14
  model_id = "meta-llama/Meta-Llama-3.1-70B"
15
+ pipeline = transformers.pipeline("text-generation", model=model_id, use_auth_token=hf_token)
16
 
17
  def generate_response(prompt):
18
  # Generate a response using the pipeline