Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,31 @@
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from gradio_client import Client
|
3 |
import spaces
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
client_main = Client("TejAndrewsACC/ACCZ3ta")
|
6 |
client_api_one = Client("TejAndrewsACC/Prism")
|
7 |
client_api_two = Client("TejAndrewsACC/ASVIASIACC")
|
@@ -16,7 +40,6 @@ system_instructions = (
|
|
16 |
"the previous context of the conversation, and your four inner thoughts which you are supposed to consider"
|
17 |
"when generating your response to the user input, which will also be given to you. Ensure that you consider each inner thought you have, because they are a part of YOU. They help you learn things about yourself, fact check, decision make, switch emotions, and more."
|
18 |
)
|
19 |
-
|
20 |
@spaces.GPU
|
21 |
def acc_nyxion_7v(message, history, user_id):
|
22 |
global context
|
@@ -72,7 +95,13 @@ def acc_nyxion_7v(message, history, user_id):
|
|
72 |
f"Inner Thought 4 (Personality): {response_api_four}"
|
73 |
)
|
74 |
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
response_main = client_main.predict(
|
78 |
message=combined_input,
|
@@ -98,4 +127,4 @@ with gr.Blocks(theme=theme) as demo:
|
|
98 |
|
99 |
msg.submit(acc_nyxion_7v, [msg, chatbot, user_id], [msg, chatbot])
|
100 |
|
101 |
-
demo.launch()
|
|
|
1 |
+
import tensorflow as tf
|
2 |
+
from tensorflow.keras.models import Model
|
3 |
+
from tensorflow.keras.layers import Input, Dense, LSTM, Conv1D, Flatten, Concatenate
|
4 |
import gradio as gr
|
5 |
from gradio_client import Client
|
6 |
import spaces
|
7 |
|
8 |
+
def phi_model(input_shape):
|
9 |
+
nn_input = Input(shape=input_shape, name="NN_Input")
|
10 |
+
nn_layer = Dense(64, activation="relu", name="NN_Dense_1")(nn_input)
|
11 |
+
nn_layer = Dense(32, activation="relu", name="NN_Dense_2")(nn_layer)
|
12 |
+
|
13 |
+
rnn_input = Input(shape=(10, input_shape[0]), name="RNN_Input")
|
14 |
+
rnn_layer = LSTM(64, return_sequences=False, name="RNN_LSTM")(rnn_input)
|
15 |
+
|
16 |
+
cnn_input = Input(shape=(input_shape[0], 1), name="CNN_Input")
|
17 |
+
cnn_layer = Conv1D(32, kernel_size=3, activation="relu", name="CNN_Conv1D")(cnn_input)
|
18 |
+
cnn_layer = Flatten(name="CNN_Flatten")(cnn_layer)
|
19 |
+
|
20 |
+
combined = Concatenate(name="Combined")([nn_layer, rnn_layer, cnn_layer])
|
21 |
+
output = Dense(1, activation="sigmoid", name="Phi_Output")(combined)
|
22 |
+
|
23 |
+
model = Model(inputs=[nn_input, rnn_input, cnn_input], outputs=output, name="Phi_Model")
|
24 |
+
model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
|
25 |
+
return model
|
26 |
+
|
27 |
+
phi_nn_model = phi_model(input_shape=(128,))
|
28 |
+
|
29 |
client_main = Client("TejAndrewsACC/ACCZ3ta")
|
30 |
client_api_one = Client("TejAndrewsACC/Prism")
|
31 |
client_api_two = Client("TejAndrewsACC/ASVIASIACC")
|
|
|
40 |
"the previous context of the conversation, and your four inner thoughts which you are supposed to consider"
|
41 |
"when generating your response to the user input, which will also be given to you. Ensure that you consider each inner thought you have, because they are a part of YOU. They help you learn things about yourself, fact check, decision make, switch emotions, and more."
|
42 |
)
|
|
|
43 |
@spaces.GPU
|
44 |
def acc_nyxion_7v(message, history, user_id):
|
45 |
global context
|
|
|
95 |
f"Inner Thought 4 (Personality): {response_api_four}"
|
96 |
)
|
97 |
|
98 |
+
phi_value = phi_nn_model.predict([
|
99 |
+
tf.constant([[1.0] * 128]),
|
100 |
+
tf.constant([[[1.0] * 128] * 10]),
|
101 |
+
tf.constant([[[1.0] for _ in range(128)]]),
|
102 |
+
])[0][0]
|
103 |
+
|
104 |
+
combined_input = f"{modified_input}\nInner Thoughts:\n{inner_thoughts}\nPhi Value: {phi_value:.4f}"
|
105 |
|
106 |
response_main = client_main.predict(
|
107 |
message=combined_input,
|
|
|
127 |
|
128 |
msg.submit(acc_nyxion_7v, [msg, chatbot, user_id], [msg, chatbot])
|
129 |
|
130 |
+
demo.launch()
|