Spaces:
Running
Running
File size: 906 Bytes
ccfa18b 255c46a ccfa18b 255c46a 2200a8f 255c46a 2e5d0ce 255c46a 2200a8f 255c46a 2200a8f 255c46a ccfa18b 2200a8f 255c46a 2200a8f ccfa18b 255c46a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import gradio as gr
from huggingface_hub import InferenceClient
import os
# Your secret token
token = os.getenv("HF_TOKEN")
# Uncensored model
model_id = "HuggingFaceH4/zephyr-7b-beta"
def chat(message, history):
try:
client = InferenceClient(token=token)
messages = [{"role": "user", "content": message}]
output = client.chat_completion(
messages,
model=model_id,
max_tokens=200,
temperature=0.8
)
return output.choices[0].message.content
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) |