Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,37 +7,6 @@ Original file is located at
|
|
7 |
https://colab.research.google.com/drive/1F6f_vJbssO7C2FM6FILWljFYacDmbVBY
|
8 |
"""
|
9 |
|
10 |
-
from IPython.display import display, HTML
|
11 |
-
|
12 |
-
# Inject CSS to enable wrapping
|
13 |
-
display(HTML('''
|
14 |
-
<style>
|
15 |
-
.output_area pre {
|
16 |
-
white-space: pre-wrap;
|
17 |
-
}
|
18 |
-
</style>
|
19 |
-
'''))
|
20 |
-
|
21 |
-
!pip install transformers gradio
|
22 |
-
|
23 |
-
import os
|
24 |
-
from google.colab import userdata
|
25 |
-
|
26 |
-
# Get the Hugging Face API key from Colab Secrets
|
27 |
-
api_key = userdata.get('HF_TOKEN')
|
28 |
-
|
29 |
-
# Ensure the API key is set before using it
|
30 |
-
if api_key is None:
|
31 |
-
raise ValueError("Hugging Face API key not found. Please ensure it is set in Colab Secrets.")
|
32 |
-
|
33 |
-
# Set the Hugging Face token as an environment variable
|
34 |
-
os.environ["HF_TOKEN"] = api_key
|
35 |
-
|
36 |
-
# Hugging Face libraries will automatically use this token for authentication
|
37 |
-
print("Hugging Face API key successfully loaded! You're good to go!")
|
38 |
-
|
39 |
-
# Now you can continue with your Hugging Face-related code
|
40 |
-
|
41 |
# Import necessary libraries
|
42 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
43 |
|
@@ -91,20 +60,3 @@ interface = gr.Interface(
|
|
91 |
|
92 |
# Launch the Gradio interface in Colab
|
93 |
interface.launch(share=True) # share=True creates a public link
|
94 |
-
|
95 |
-
"""### Uploading to Hugging Face Spaces
|
96 |
-
|
97 |
-
Now that we have our chatbot working, here’s how to upload it to Hugging Face Spaces:
|
98 |
-
|
99 |
-
1. Go to [Hugging Face Spaces](https://huggingface.co/spaces).
|
100 |
-
2. Create a new Space, choose "Gradio" as the app type, and name it (e.g., "My Simple Chatbot").
|
101 |
-
3. Upload this notebook, along with any necessary files or model assets.
|
102 |
-
4. Set up your Space and click "Deploy." Your Gradio chatbot will now be live!
|
103 |
-
|
104 |
-
**Tips for Deployment:**
|
105 |
-
- Ensure you include any persona settings or customizations.
|
106 |
-
- Test the app after deployment to confirm it works as expected.
|
107 |
-
|
108 |
-
Once deployed, students can share the link with family and friends!
|
109 |
-
|
110 |
-
"""
|
|
|
7 |
https://colab.research.google.com/drive/1F6f_vJbssO7C2FM6FILWljFYacDmbVBY
|
8 |
"""
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
# Import necessary libraries
|
11 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
12 |
|
|
|
60 |
|
61 |
# Launch the Gradio interface in Colab
|
62 |
interface.launch(share=True) # share=True creates a public link
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|