eabybabu commited on
Commit
77f2591
·
1 Parent(s): 9144ebb

Secure API token using .env

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -1,13 +1,25 @@
1
  import gradio as gr
2
  from transformers import AutoModelForCausalLM, AutoTokenizer
3
  import torch
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  # ✅ Load the trained chatbot model from Hugging Face
6
  MODEL_NAME = "eabybabu/chatbot_model" # Replace with your actual model name
7
 
8
- # ✅ Fix the authentication issue
9
- tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME, token=True)
10
- model = AutoModelForCausalLM.from_pretrained(MODEL_NAME, token=True)
 
11
 
12
  # ✅ Function to generate chatbot responses
13
  def chatbot_response(user_input):
 
1
  import gradio as gr
2
  from transformers import AutoModelForCausalLM, AutoTokenizer
3
  import torch
4
+ import os
5
+
6
+
7
+ from dotenv import load_dotenv
8
+ import os
9
+
10
+ # ✅ Load API Token Securely from .env
11
+ load_dotenv()
12
+ HF_TOKEN = os.getenv("HF_TOKEN")
13
+
14
+
15
 
16
  # ✅ Load the trained chatbot model from Hugging Face
17
  MODEL_NAME = "eabybabu/chatbot_model" # Replace with your actual model name
18
 
19
+
20
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME, token=HF_TOKEN)
21
+ model = AutoModelForCausalLM.from_pretrained(MODEL_NAME, token=HF_TOKEN)
22
+
23
 
24
  # ✅ Function to generate chatbot responses
25
  def chatbot_response(user_input):