Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
| 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 |
-
|
|
|
|
|
|
| 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)
|