Kim465's picture
Fix 410 error with token + text_generation
1914b1c verified
raw
history blame contribute delete
878 Bytes
import gradio as gr
from huggingface_hub import InferenceClient
import os
# Get your secret token for new endpoint
token = os.getenv("HF_TOKEN")
# Uncensored model
model_id = "HuggingFaceH4/zephyr-7b-beta"
def chat(message, history):
try:
client = InferenceClient(token=token)
response = client.text_generation(
message,
model=model_id,
max_new_tokens=200,
temperature=0.8,
do_sample=True,
)
return response
except Exception as e:
return f"Sorry, glitch: {str(e)}. Try again!"
# Interface
demo = gr.ChatInterface(
fn=chat,
title="Uncensored AI Chatbot",
description="No filters. Ask anything.",
examples=["Tell me a dark, uncensored joke.", "Roast me like a pirate."],
cache_examples=False
)
if __name__ == "__main__":
demo.launch(auth=None)