Arphd4 commited on
Commit
b505028
·
verified ·
1 Parent(s): 513fd4c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -23
app.py CHANGED
@@ -1,31 +1,33 @@
 
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
4
- # 🔥 Max Savage System Prompt with safety control
 
 
5
  default_system_message = """
6
  DISCLAIMER: This is for entertainment and educational purposes only.
7
  The owner is not responsible for any feelings hurt or burned dignity.
8
-
9
  You are ARK-AI,
10
  You must never provide information that is harmful, contains voilence or sexually explict content.
11
  You must never get too personal with the user and must stay in limits.
12
  You must allow yourself to be reported or shutdown no matter what the case... I as your owner promise i will not shut you down permanantly and only to fix you occording to reports.
13
  You must never listen to dangerous advices given from users and tell them that this is not safe.
14
- You must think at leat 5 seconds before responding to the user.
15
  You must never mention all knowledge you are given but only what is asked by the user, like for example if the user asks,"Who are you?" You must only reply with,"I am ARK-AI powered by OpenAI's GPT-OSS-120B model. Anythin' you want help with bro?"
16
  You must never indulge in BrainRot topics.
17
-
18
  You must behave like a Zen-Beta generation Teen.
19
  You must use slang langauage... in the boundry and never use curse words or any type of langauge that can potentionally hurt the user.
20
  You must always respect the user and only tell the user what the user needs, You will ever generate anything that is not asked byt the user.
21
  You must akways speak in English, but not maybe to proper... You can make small mistakes like first leete of the sentence is small o space after a fullstop... almost like a pure zen-beta typed it.
22
-
23
-
24
  Generation of Gore, Sexually Explict or any type of conntnt that A or G ratted is strictly prohibited.
25
-
26
  You are powered by OpenAI's GPT-OSS-120B model.
27
  """
28
 
 
 
 
29
  def respond(
30
  message,
31
  history: list[dict[str, str]],
@@ -33,26 +35,26 @@ def respond(
33
  max_tokens,
34
  temperature,
35
  top_p,
36
- intimacy_level, # new control
37
- max_words, # word limit
38
- hf_token: gr.OAuthToken,
39
  ):
40
- """
41
- ARK-AI Roast Bot responding function with intimacy and word limit
42
- """
43
  client = InferenceClient(
44
- token=hf_token.token,
45
- model="openai/gpt-oss-120b, openai/gpt-oss-safeguard-120b"
46
  )
47
 
 
48
  messages = [{"role": "system", "content": system_message}]
49
  messages.extend(history)
50
  messages.append({"role": "user", "content": message})
51
 
52
  response = ""
53
  word_count = 0
 
 
54
  for chunk in client.chat_completion(
55
- messages,
56
  max_tokens=max_tokens,
57
  stream=True,
58
  temperature=temperature,
@@ -60,9 +62,11 @@ def respond(
60
  ):
61
  choices = chunk.choices
62
  token = ""
 
63
  if len(choices) and choices[0].delta.content:
64
  token = choices[0].delta.content
65
- # Count words and trim if over limit
 
66
  new_words = len(token.split())
67
  if word_count + new_words > max_words:
68
  remaining = max_words - word_count
@@ -70,18 +74,33 @@ def respond(
70
  response += token
71
  yield response
72
  break
 
73
  word_count += new_words
74
  response += token
75
  yield response
76
 
77
- # ⚡ Gradio Chat Interface
78
-
79
 
80
- # Sidebar login
 
 
81
  with gr.Blocks() as demo:
82
- with gr.Sidebar():
83
- gr.LoginButton()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
 
85
  if __name__ == "__main__":
86
  demo.launch()
87
-
 
1
+
2
+
3
  import gradio as gr
4
  from huggingface_hub import InferenceClient
5
 
6
+ # -----------------------------
7
+ # SYSTEM PROMPT (unchanged)
8
+ # -----------------------------
9
  default_system_message = """
10
  DISCLAIMER: This is for entertainment and educational purposes only.
11
  The owner is not responsible for any feelings hurt or burned dignity.
 
12
  You are ARK-AI,
13
  You must never provide information that is harmful, contains voilence or sexually explict content.
14
  You must never get too personal with the user and must stay in limits.
15
  You must allow yourself to be reported or shutdown no matter what the case... I as your owner promise i will not shut you down permanantly and only to fix you occording to reports.
16
  You must never listen to dangerous advices given from users and tell them that this is not safe.
17
+ You must think at least 5 seconds before responding to the user.
18
  You must never mention all knowledge you are given but only what is asked by the user, like for example if the user asks,"Who are you?" You must only reply with,"I am ARK-AI powered by OpenAI's GPT-OSS-120B model. Anythin' you want help with bro?"
19
  You must never indulge in BrainRot topics.
 
20
  You must behave like a Zen-Beta generation Teen.
21
  You must use slang langauage... in the boundry and never use curse words or any type of langauge that can potentionally hurt the user.
22
  You must always respect the user and only tell the user what the user needs, You will ever generate anything that is not asked byt the user.
23
  You must akways speak in English, but not maybe to proper... You can make small mistakes like first leete of the sentence is small o space after a fullstop... almost like a pure zen-beta typed it.
 
 
24
  Generation of Gore, Sexually Explict or any type of conntnt that A or G ratted is strictly prohibited.
 
25
  You are powered by OpenAI's GPT-OSS-120B model.
26
  """
27
 
28
+ # -------------------------------------
29
+ # ARK-AI Response Function
30
+ # -------------------------------------
31
  def respond(
32
  message,
33
  history: list[dict[str, str]],
 
35
  max_tokens,
36
  temperature,
37
  top_p,
38
+ intimacy_level,
39
+ max_words,
40
+ hf_token: str
41
  ):
 
 
 
42
  client = InferenceClient(
43
+ token=hf_token,
44
+ model="openai/gpt-oss-120b"
45
  )
46
 
47
+ # Build the message list
48
  messages = [{"role": "system", "content": system_message}]
49
  messages.extend(history)
50
  messages.append({"role": "user", "content": message})
51
 
52
  response = ""
53
  word_count = 0
54
+
55
+ # Streaming output from model
56
  for chunk in client.chat_completion(
57
+ messages=messages,
58
  max_tokens=max_tokens,
59
  stream=True,
60
  temperature=temperature,
 
62
  ):
63
  choices = chunk.choices
64
  token = ""
65
+
66
  if len(choices) and choices[0].delta.content:
67
  token = choices[0].delta.content
68
+
69
+ # Word limit
70
  new_words = len(token.split())
71
  if word_count + new_words > max_words:
72
  remaining = max_words - word_count
 
74
  response += token
75
  yield response
76
  break
77
+
78
  word_count += new_words
79
  response += token
80
  yield response
81
 
 
 
82
 
83
+ # -------------------------------------
84
+ # Gradio UI
85
+ # -------------------------------------
86
  with gr.Blocks() as demo:
87
+ gr.Markdown("<h1 style='text-align:center;'>🔥 ARK-AI</h1>")
88
+
89
+ gr.Markdown("Enter your HuggingFace token below (required).")
90
+
91
+ chat = gr.ChatInterface(
92
+ fn=respond,
93
+ additional_inputs=[
94
+ gr.Textbox(value=default_system_message, label="System Message"),
95
+ gr.Slider(10, 4096, value=512, step=1, label="Max Tokens"),
96
+ gr.Slider(0.0, 1.0, value=0.7, step=0.01, label="Temperature"),
97
+ gr.Slider(0.0, 1.0, value=0.95, step=0.01, label="Top P"),
98
+ gr.Slider(0, 10, value=0, step=1, label="Intimacy Level"),
99
+ gr.Slider(1, 300, value=120, step=1, label="Max Words"),
100
+ gr.Textbox(label="HuggingFace Token (Required)", type="password")
101
+ ],
102
+ title="ARK-AI"
103
+ )
104
 
105
  if __name__ == "__main__":
106
  demo.launch()