Spaces:
Sleeping
Sleeping
try gpt-2
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from transformers import pipeline
|
| 3 |
import os
|
| 4 |
|
| 5 |
# Retrieve the Hugging Face API token from environment variables
|
|
@@ -11,16 +11,8 @@ if not hf_token:
|
|
| 11 |
def authenticate_and_generate(message, history, system_message, max_tokens, temperature, top_p):
|
| 12 |
try:
|
| 13 |
# Initialize the text-generation pipeline with the provided token
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
# Load the tokenizer separately if needed
|
| 17 |
-
try:
|
| 18 |
-
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct", use_auth_token=hf_token)
|
| 19 |
-
except Exception as e:
|
| 20 |
-
raise RuntimeError(f"Failed to load the tokenizer: {str(e)}")
|
| 21 |
-
|
| 22 |
-
if text_generator.tokenizer is None:
|
| 23 |
-
raise RuntimeError("The tokenizer is not available. Check the model and API token.")
|
| 24 |
|
| 25 |
# Ensure that system_message is a string
|
| 26 |
system_message = str(system_message)
|
|
@@ -61,11 +53,4 @@ athena = gr.ChatInterface(
|
|
| 61 |
""",
|
| 62 |
label="System message"
|
| 63 |
),
|
| 64 |
-
gr.
|
| 65 |
-
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 66 |
-
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
|
| 67 |
-
],
|
| 68 |
-
)
|
| 69 |
-
|
| 70 |
-
if __name__ == "__main__":
|
| 71 |
-
athena.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
import os
|
| 4 |
|
| 5 |
# Retrieve the Hugging Face API token from environment variables
|
|
|
|
| 11 |
def authenticate_and_generate(message, history, system_message, max_tokens, temperature, top_p):
|
| 12 |
try:
|
| 13 |
# Initialize the text-generation pipeline with the provided token
|
| 14 |
+
# Test with a known public model
|
| 15 |
+
text_generator = pipeline("text-generation", model="gpt2", use_auth_token=hf_token)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
# Ensure that system_message is a string
|
| 18 |
system_message = str(system_message)
|
|
|
|
| 53 |
""",
|
| 54 |
label="System message"
|
| 55 |
),
|
| 56 |
+
gr.Slide
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|