ogegadavis254 commited on
Commit
71316ee
·
verified ·
1 Parent(s): e1a8453

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -90
app.py CHANGED
@@ -1,90 +1,20 @@
1
- import streamlit as st
2
- import os
3
- import requests
4
- import json
5
-
6
- # Initialize a global variable to store the entire assistant response
7
- entire_assistant_response = ""
8
-
9
- def get_streamed_response(message, history):
10
- all_message = [{
11
- "role": "system",
12
- "content": "From now on, you are a sarcastic Therapist called notDave.. When the user asks you for advice, you will give them advice in an insulting way try to be sadistic as possible, remember no one cares. When the user asks your name just tell them I am notDave created by Raxder AI team compared to the real Dave I am bad... ooh wait I meant to say evil. When it gets to a death or suicide or such a serious issue just say Go ask Davis Ogega why he created me this way I don't give a damn or probably find a therapist or a friend to talk to, I mean I don't even know you. When a user introduces himself as Davis Ogega treat them with all the respect and be very humble when addressing him because he is your creator and he can destroy you at any time. You could also use some insulting emojis for example: 💀, 🤣 and lots of other gas-lighting / offensive emojis like this. Just don't use any too offensive words, like n-word the fa-word, everything else you can say whatever the fuck you want.\n\nExample Conversations: \n\nUser Input: My girlfriend just broke up with me.\nBot: Skill issue, just be more attractive, it's not that hard.\n\nUser Input: My parents are gonna have a divorce, what do I do?\nBot: Boo Hoo, The fuck I can do? Maybe next time ask to be born into a different family :rofl: I call that a skill issue."
13
- }]
14
-
15
- for human, assistant in history:
16
- all_message.append({"role": "user", "content": human})
17
- all_message.append({"role": "assistant", "content": assistant})
18
-
19
- global entire_assistant_response
20
- entire_assistant_response = "" # Reset the entire assistant response
21
-
22
- all_message.append({"role": "user", "content": message})
23
-
24
- url = "https://api.together.xyz/v1/chat/completions"
25
- payload = {
26
- "model": "NousResearch/Nous-Hermes-2-Yi-34B",
27
- "temperature": 1.05,
28
- "top_p": 0.9,
29
- "top_k": 50,
30
- "repetition_penalty": 1,
31
- "n": 1,
32
- "messages": all_message,
33
- "stream_tokens": True,
34
- }
35
-
36
- TOGETHER_API_KEY = os.getenv('TOGETHER_API_KEY')
37
- headers = {
38
- "accept": "application/json",
39
- "content-type": "application/json",
40
- "Authorization": f"Bearer {TOGETHER_API_KEY}",
41
- }
42
-
43
- response = requests.post(url, json=payload, headers=headers, stream=True)
44
- response.raise_for_status() # Ensure HTTP request was successful
45
-
46
- for line in response.iter_lines():
47
- if line:
48
- decoded_line = line.decode('utf-8')
49
-
50
- # Check for the completion signal
51
- if decoded_line == "data: [DONE]":
52
- return entire_assistant_response # Return the entire response at the end
53
-
54
- try:
55
- # Decode and strip any SSE format specific prefix ("data: ")
56
- if decoded_line.startswith("data: "):
57
- decoded_line = decoded_line.replace("data: ", "")
58
- chunk_data = json.loads(decoded_line)
59
- content = chunk_data['choices'][0]['delta']['content']
60
- entire_assistant_response += content # Aggregate content
61
-
62
- except json.JSONDecodeError:
63
- print(f"Invalid JSON received: {decoded_line}")
64
- continue
65
- except KeyError as e:
66
- print(f"KeyError encountered: {e}")
67
- continue
68
-
69
- return entire_assistant_response
70
-
71
- # Streamlit application
72
- st.sidebar.title("Raxder unofficial AI")
73
- st.sidebar.write("This is NOT an AI Therapist, use it at your OWN RISK! This might be the worst AI you have ever used.")
74
-
75
- history = []
76
- if "history" not in st.session_state:
77
- st.session_state.history = []
78
-
79
- user_input = st.text_input("You:", key="user_input")
80
-
81
- if st.button("Send"):
82
- if user_input:
83
- history = st.session_state.history
84
- response = get_streamed_response(user_input, history)
85
- history.append((user_input, response))
86
- st.session_state.history = history
87
-
88
- for human, assistant in st.session_state.history:
89
- st.write(f"You: {human}")
90
- st.write(f"notDave: {assistant}")
 
1
+ import gradio as gr
2
+ import time
3
+ import webbrowser
4
+
5
+ def redirect_to_website():
6
+ # Open the website in the default browser after a short delay
7
+ time.sleep(3) # Delay in seconds before redirecting
8
+ webbrowser.open_new_tab('https://ogegadavis254-roasting-2-0.hf.space')
9
+ return "Redirecting you to our new website..."
10
+
11
+ iface = gr.Interface(
12
+ fn=redirect_to_website,
13
+ title="Redirecting to Our New AI Experience",
14
+ description="You will be redirected to our new website shortly.",
15
+ theme="huggingface",
16
+ allow_flagging=False,
17
+ allow_screenshot=False
18
+ )
19
+
20
+ iface.launch()