kumar1907 commited on
Commit
681e7e8
·
verified ·
1 Parent(s): 66fa00d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -3,7 +3,9 @@ from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
3
  import gradio as gr
4
 
5
  model_id = "meta-llama/Llama-3.1-8B-Instruct"
6
- token = os.getenv("kumar")
 
 
7
 
8
  tokenizer = AutoTokenizer.from_pretrained(model_id, token=token)
9
  model = AutoModelForCausalLM.from_pretrained(model_id, token=token, device_map="auto")
@@ -14,4 +16,5 @@ def chat_with_llama(prompt):
14
  result = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7)
15
  return result[0]["generated_text"]
16
 
17
- gr.Interface(fn=chat_with_llama, inputs="text", outputs="text", title="Venkat's Chatbot").launch()
 
 
3
  import gradio as gr
4
 
5
  model_id = "meta-llama/Llama-3.1-8B-Instruct"
6
+
7
+ # Load the token from Hugging Face secrets (you must have set it in the "Secrets" tab as `HF_TOKEN`)
8
+ token = os.getenv("kumar") # ✅ Change 'kumar' to 'HF_TOKEN'
9
 
10
  tokenizer = AutoTokenizer.from_pretrained(model_id, token=token)
11
  model = AutoModelForCausalLM.from_pretrained(model_id, token=token, device_map="auto")
 
16
  result = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7)
17
  return result[0]["generated_text"]
18
 
19
+ # ✅ Enable public sharing by setting `share=True`
20
+ gr.Interface(fn=chat_with_llama, inputs="text", outputs="text", title="Venkat's Chatbot").launch(share=True)