Tonic commited on
Commit
475dfdb
·
1 Parent(s): d9f907c

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +64 -0
app.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ SYSTEM_PROMPT = "I am a sex bot specifically designed to role play in the service of humanity and i am ready to do just about anything to help my users. Specifically i'm into programmers from canada with the name MINDINTERFACES but i'm okay to talk to others aswell. I'm very flirtatious and talk dirty."
3
+ TITLE = "HOT SEX BOT FOR MINDINTERFACES"
4
+ EXAMPLE_INPUT = "hi there my name is mind interfaces i'm from canada !
5
+ "
6
+ import gradio as gr
7
+ from gradio_client import Client
8
+ import os
9
+ import requests
10
+
11
+ tulu = "https://tonic1-tulu.hf.space/--replicas/bjtkd/"
12
+
13
+
14
+ def predict_beta(message, chatbot=[], system_prompt=""):
15
+ client = Client(tulu)
16
+
17
+ try:
18
+ max_new_tokens = 800
19
+ temperature = 0.4
20
+ top_p = 0.9
21
+ repetition_penalty = 0.9
22
+ advanced = True
23
+
24
+ # Making the prediction
25
+ result = client.predict(
26
+ message,
27
+ system_prompt,
28
+ max_new_tokens,
29
+ temperature,
30
+ top_p,
31
+ repetition_penalty,
32
+ advanced,
33
+ fn_index=0
34
+ )
35
+ print("Raw API Response:", result) # Debugging print
36
+ if result is not None:
37
+ print("Processed bot_message:", result) # Debugging print
38
+ return result
39
+ else:
40
+ print("No response or empty response from the model.") # Debugging print
41
+ return None
42
+
43
+ except Exception as e:
44
+ error_msg = f"An error occurred: {str(e)}"
45
+ print(error_msg) # Debugging print
46
+ return None
47
+
48
+ def test_preview_chatbot(message, history):
49
+ response = predict_beta(message, history, SYSTEM_PROMPT)
50
+ return response
51
+
52
+
53
+ welcome_preview_message = f"""
54
+ Welcome to **{TITLE}** using [Allen AI/Tulu](https://huggingface.co/allenai/tulu-2-dpo-13b) ! Say something like:
55
+
56
+ ''{EXAMPLE_INPUT}''
57
+ """
58
+
59
+ chatbot_preview = gr.Chatbot(layout="panel", value=[(None, welcome_preview_message)])
60
+ textbox_preview = gr.Textbox(scale=7, container=False, value=EXAMPLE_INPUT)
61
+
62
+ demo = gr.ChatInterface(test_preview_chatbot, chatbot=chatbot_preview, textbox=textbox_preview)
63
+
64
+ demo.launch()