Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,13 @@ import gradio as gr
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
MODEL = "mlabonne/gemma-3-27b-it-abliterated:featherless-ai"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
|
| 7 |
def respond(
|
|
@@ -19,13 +26,10 @@ def respond(
|
|
| 19 |
client = InferenceClient(token=hf_token.token, model=MODEL)
|
| 20 |
|
| 21 |
messages = [{"role": "system", "content": system_message}]
|
| 22 |
-
|
| 23 |
messages.extend(history)
|
| 24 |
-
|
| 25 |
messages.append({"role": "user", "content": message})
|
| 26 |
-
|
| 27 |
response = ""
|
| 28 |
-
|
| 29 |
for message in client.chat_completion(
|
| 30 |
messages,
|
| 31 |
max_tokens=max_tokens,
|
|
@@ -41,7 +45,6 @@ def respond(
|
|
| 41 |
response += token
|
| 42 |
yield response
|
| 43 |
|
| 44 |
-
|
| 45 |
"""
|
| 46 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
| 47 |
"""
|
|
@@ -49,7 +52,7 @@ chatbot = gr.ChatInterface(
|
|
| 49 |
respond,
|
| 50 |
type="messages",
|
| 51 |
additional_inputs=[
|
| 52 |
-
gr.Textbox(value=
|
| 53 |
gr.Slider(minimum=1, maximum=2048, value=300, step=1, label="Max new tokens"),
|
| 54 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 55 |
gr.Slider(
|
|
@@ -60,6 +63,9 @@ chatbot = gr.ChatInterface(
|
|
| 60 |
label="Top-p (nucleus sampling)",
|
| 61 |
),
|
| 62 |
],
|
|
|
|
|
|
|
|
|
|
| 63 |
)
|
| 64 |
|
| 65 |
with gr.Blocks() as demo:
|
|
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
MODEL = "mlabonne/gemma-3-27b-it-abliterated:featherless-ai"
|
| 5 |
+
SYSTEM_PROMPT = """
|
| 6 |
+
You are an erotic writer assistant, who responds to the user requests in plain text, not markdown
|
| 7 |
+
|
| 8 |
+
Your responses are very short and direct
|
| 9 |
+
|
| 10 |
+
Your responses must be worded as if they were the statistics in an RPG game, with item and character descriptions as if they were part of the game
|
| 11 |
+
"""
|
| 12 |
|
| 13 |
|
| 14 |
def respond(
|
|
|
|
| 26 |
client = InferenceClient(token=hf_token.token, model=MODEL)
|
| 27 |
|
| 28 |
messages = [{"role": "system", "content": system_message}]
|
|
|
|
| 29 |
messages.extend(history)
|
|
|
|
| 30 |
messages.append({"role": "user", "content": message})
|
| 31 |
+
|
| 32 |
response = ""
|
|
|
|
| 33 |
for message in client.chat_completion(
|
| 34 |
messages,
|
| 35 |
max_tokens=max_tokens,
|
|
|
|
| 45 |
response += token
|
| 46 |
yield response
|
| 47 |
|
|
|
|
| 48 |
"""
|
| 49 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
| 50 |
"""
|
|
|
|
| 52 |
respond,
|
| 53 |
type="messages",
|
| 54 |
additional_inputs=[
|
| 55 |
+
gr.Textbox(value=SYSTEM_PROMPT, label="System message"),
|
| 56 |
gr.Slider(minimum=1, maximum=2048, value=300, step=1, label="Max new tokens"),
|
| 57 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 58 |
gr.Slider(
|
|
|
|
| 63 |
label="Top-p (nucleus sampling)",
|
| 64 |
),
|
| 65 |
],
|
| 66 |
+
examples=[
|
| 67 |
+
"Provide the stats of the female workers in the local town's brothel, these stats refer to the number of sexual acts (vaginal, anal, etc) executed by each person and their profficiency at it"
|
| 68 |
+
],
|
| 69 |
)
|
| 70 |
|
| 71 |
with gr.Blocks() as demo:
|