isitcoding commited on
Commit
e58c81f
·
verified ·
1 Parent(s): 9900e1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -1,11 +1,16 @@
 
1
  import gradio as gr
2
  import random
3
  from transformers import pipeline
4
 
5
 
 
 
6
 
 
 
7
  # Load the text generation pipeline with your fine-tuned model
8
- generator = pipeline('text-generation', model='isitcoding/gpt2_120_finetuned')
9
 
10
  # Function to generate responses using the text generation model
11
  def respond(message, chat_history):
 
1
+ import os
2
  import gradio as gr
3
  import random
4
  from transformers import pipeline
5
 
6
 
7
+ # Get the Hugging Face token from environment variables
8
+ hf_token = os.getenv("gpt2_tokens")
9
 
10
+ if not hf_token:
11
+ raise ValueError("Hugging Face token not found. Please set HF_TOKEN as an environment variable.")
12
  # Load the text generation pipeline with your fine-tuned model
13
+ generator = pipeline('text-generation', model='isitcoding/gpt2_120_finetuned', use_auth_token = hf_token)
14
 
15
  # Function to generate responses using the text generation model
16
  def respond(message, chat_history):