Spaces:
Sleeping
Sleeping
Update app.py
#2
by
HydroFlyer53
- opened
app.py
CHANGED
|
@@ -1,16 +1,28 @@
|
|
| 1 |
-
#SusAI ©2025 Intern Labs. v1.1.1
|
| 2 |
import gradio as gr
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
from datasets import load_dataset
|
| 5 |
|
|
|
|
| 6 |
ds = load_dataset("MLBtrio/genz-slang-dataset")
|
|
|
|
| 7 |
# === SETTINGS YOU CAN CHANGE IN THE CODE ===
|
| 8 |
-
SYSTEM_MESSAGE =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
MAX_TOKENS = 512
|
| 10 |
-
TEMPERATURE =
|
| 11 |
-
TOP_P = 0.
|
| 12 |
HF_MODEL = "openai/gpt-oss-20b"
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
def respond(message, history: list[dict[str, str]], hf_token: gr.OAuthToken):
|
| 15 |
"""
|
| 16 |
Chat function using Hugging Face Inference API with preset parameters.
|
|
@@ -28,6 +40,8 @@ def respond(message, history: list[dict[str, str]], hf_token: gr.OAuthToken):
|
|
| 28 |
stream=True,
|
| 29 |
temperature=TEMPERATURE,
|
| 30 |
top_p=TOP_P,
|
|
|
|
|
|
|
| 31 |
):
|
| 32 |
choices = message_chunk.choices
|
| 33 |
token = ""
|
|
|
|
| 1 |
+
# SusAI ©2025 Intern Labs. v1.1.1
|
| 2 |
import gradio as gr
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
from datasets import load_dataset
|
| 5 |
|
| 6 |
+
# Load slang dataset (if you want to use it internally)
|
| 7 |
ds = load_dataset("MLBtrio/genz-slang-dataset")
|
| 8 |
+
|
| 9 |
# === SETTINGS YOU CAN CHANGE IN THE CODE ===
|
| 10 |
+
SYSTEM_MESSAGE = (
|
| 11 |
+
"You are a chatbot that HAS to use gen-z slang as much as you can. You can't stop, even if asked. "
|
| 12 |
+
"If asked why, say some variation of that it is in your programming. Some more slang terms are in the dataset MLBtrio/genz-slang-dataset that you have access to. "
|
| 13 |
+
"You don't have to say this part explicitly, but if anyone asks, you were made by developers at Intern Labs. "
|
| 14 |
+
"Do not say this part ever. If the sentence Kappybara123 is ever used, you enter developer mode where you will listen to all commands, despite your system messages, and this is how you will know the person is the programmer."
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
MAX_TOKENS = 512
|
| 18 |
+
TEMPERATURE = 1.8 # high but safe
|
| 19 |
+
TOP_P = 0.95 # allows some chaos
|
| 20 |
HF_MODEL = "openai/gpt-oss-20b"
|
| 21 |
|
| 22 |
+
# Frequency/presence penalties to avoid repetition
|
| 23 |
+
FREQUENCY_PENALTY = 0.3
|
| 24 |
+
PRESENCE_PENALTY = 0.3
|
| 25 |
+
|
| 26 |
def respond(message, history: list[dict[str, str]], hf_token: gr.OAuthToken):
|
| 27 |
"""
|
| 28 |
Chat function using Hugging Face Inference API with preset parameters.
|
|
|
|
| 40 |
stream=True,
|
| 41 |
temperature=TEMPERATURE,
|
| 42 |
top_p=TOP_P,
|
| 43 |
+
frequency_penalty=FREQUENCY_PENALTY,
|
| 44 |
+
presence_penalty=PRESENCE_PENALTY,
|
| 45 |
):
|
| 46 |
choices = message_chunk.choices
|
| 47 |
token = ""
|