Spaces:
Running
Running
Fix 410 error with token + text_generation
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import gradio as gr
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
#
|
| 6 |
token = os.getenv("HF_TOKEN")
|
| 7 |
|
| 8 |
# Uncensored model
|
|
@@ -11,14 +11,14 @@ model_id = "HuggingFaceH4/zephyr-7b-beta"
|
|
| 11 |
def chat(message, history):
|
| 12 |
try:
|
| 13 |
client = InferenceClient(token=token)
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
messages,
|
| 17 |
model=model_id,
|
| 18 |
-
|
| 19 |
-
temperature=0.8
|
|
|
|
| 20 |
)
|
| 21 |
-
return
|
| 22 |
except Exception as e:
|
| 23 |
return f"Sorry, glitch: {str(e)}. Try again!"
|
| 24 |
|
|
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
# Get your secret token for new endpoint
|
| 6 |
token = os.getenv("HF_TOKEN")
|
| 7 |
|
| 8 |
# Uncensored model
|
|
|
|
| 11 |
def chat(message, history):
|
| 12 |
try:
|
| 13 |
client = InferenceClient(token=token)
|
| 14 |
+
response = client.text_generation(
|
| 15 |
+
message,
|
|
|
|
| 16 |
model=model_id,
|
| 17 |
+
max_new_tokens=200,
|
| 18 |
+
temperature=0.8,
|
| 19 |
+
do_sample=True,
|
| 20 |
)
|
| 21 |
+
return response
|
| 22 |
except Exception as e:
|
| 23 |
return f"Sorry, glitch: {str(e)}. Try again!"
|
| 24 |
|