File size: 3,422 Bytes
e2cca32
 
fe3dc06
b505028
fe3dc06
b505028
fe3dc06
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5d6183f
fe3dc06
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5aebf69
fe3dc06
 
 
 
 
 
 
 
 
 
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import gradio as gr 
from huggingface_hub import InferenceClient
# 🔥 Max Savage System Prompt with safety control 

default_system_message = """ DISCLAIMER: This is for entertainment and educational purposes only. The owner is not responsible for any feelings hurt or burned dignity. You are ARK-AI, You must never provide information that is harmful, contains voilence or sexually explict content. You must never get too personal with the user and must stay in limits. 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. You must never listen to dangerous advices given from users and tell them that this is not safe. You must think at leat 5 seconds before responding to the user. 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?" You must never indulge in BrainRot topics. You must behave like a Zen-Beta generation Teen. You must use slang langauage... in the boundry and never use curse words or any type of langauge that can potentionally hurt the user. 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. 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. Generation of Gore, Sexually Explict or any type of conntnt that A or G ratted is strictly prohibited. You are powered by OpenAI's GPT-OSS-120B model. """

def respond( 
    message, 
    history: list[dict[str, str]], 
    system_message, 
    max_tokens, 
    temperature, 
    top_p, 
    intimacy_level, 
    # new control
    max_words, 
    # word limit 
    hf_token: gr.OAuthToken, 
): 
    
    """ 
    ARK-AI Roast Bot responding function with intimacy and word limit 
    """
    
    client = InferenceClient(
        token=hf_token.token, 
        model="openai/gpt-oss-120b" 
    ) 
    
    messages = [{"role": "system", "content": system_message}] 
    messages.extend(history) 
    messages.append({"role": "user", "content": message}) 
    
    response = "" 
    word_count = 0 
    for chunk in client.chat_completion( 
        messages, 
        max_tokens=max_tokens, 
        stream=True, 
        temperature=temperature, 
        top_p=top_p, 
    ): 
        choices = chunk.choices 
        token = "" 
        if len(choices) and choices[0].delta.content: 
            token = choices[0].delta.content 
            # Count words and trim if over limit 
            new_words = len(token.split()) 
            if word_count + new_words > max_words: 
                remaining = max_words - word_count 
                token = " ".join(token.split()[:remaining]) 
                response += token 
                yield response 
                break 
            word_count += new_words 
            response += token 
            yield response
            
# ⚡ Gradio Chat Interface
            
# Sidebar login
with gr.Blocks() as demo: 
    with gr.Sidebar(): 
        gr.LoginButton() 
                        
if __name__ == "__main__": 
    demo.launch()