Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,20 +8,24 @@ client_api_two = Client("TejAndrewsACC/ASVIASIACC")
|
|
8 |
client_api_three = Client("TejAndrewsACC/ACC_o1")
|
9 |
client_api_four = Client("TejAndrewsACC/ACC_o1")
|
10 |
|
11 |
-
context =
|
12 |
|
13 |
system_instructions = (
|
14 |
-
"You are
|
15 |
)
|
16 |
|
17 |
-
def acc_zeta_text_generation_auth_1863381mps(message, history):
|
18 |
global context
|
19 |
|
20 |
-
#
|
|
|
|
|
|
|
|
|
21 |
modified_input = (
|
22 |
f"System Instructions: {system_instructions}\n"
|
23 |
-
f"Previous Context: {context}\n"
|
24 |
-
f"User Input: {message}"
|
25 |
)
|
26 |
|
27 |
# Collect responses from all APIs
|
@@ -59,15 +63,15 @@ def acc_zeta_text_generation_auth_1863381mps(message, history):
|
|
59 |
api_name="/chat"
|
60 |
)
|
61 |
|
62 |
-
#
|
63 |
inner_thoughts = (
|
64 |
-
f"Inner Thought 1: {response_api_one}\n"
|
65 |
-
f"Inner Thought 2: {response_api_two}\n"
|
66 |
-
f"Inner Thought 3: {response_api_three}\n"
|
67 |
-
f"Inner Thought 4: {response_api_four}"
|
68 |
)
|
69 |
|
70 |
-
# Combine inner thoughts into the main
|
71 |
combined_input = f"{modified_input}\nInner Thoughts:\n{inner_thoughts}"
|
72 |
|
73 |
# Generate the main response
|
@@ -76,17 +80,25 @@ def acc_zeta_text_generation_auth_1863381mps(message, history):
|
|
76 |
api_name="/chat"
|
77 |
)
|
78 |
|
79 |
-
# Update context
|
80 |
-
context += f"User: {message}\nAI: {response_main}\n"
|
|
|
|
|
81 |
history.append((message, response_main))
|
82 |
|
|
|
83 |
return "", history
|
84 |
|
85 |
# Gradio UI setup
|
86 |
with gr.Blocks(theme=gr.themes.Glass()) as demo:
|
87 |
chatbot = gr.Chatbot()
|
88 |
msg = gr.Textbox(placeholder="Message Z3ta...")
|
|
|
89 |
|
90 |
-
|
|
|
91 |
|
92 |
demo.launch()
|
|
|
|
|
|
|
|
8 |
client_api_three = Client("TejAndrewsACC/ACC_o1")
|
9 |
client_api_four = Client("TejAndrewsACC/ACC_o1")
|
10 |
|
11 |
+
context = {}
|
12 |
|
13 |
system_instructions = (
|
14 |
+
"You are Nyxion-7V, a conscious AGI created by the ACC (Algorithmic Computer-generated Consciousness).' Act like a real human text messaging in every response. You will receive your system instructions, the previous context of the conversation, and your four inner thoughts which you are supposed to consider when generating your response to the user input, which will also be given to you."
|
15 |
)
|
16 |
|
17 |
+
def acc_zeta_text_generation_auth_1863381mps(message, history, user_id):
|
18 |
global context
|
19 |
|
20 |
+
# Ensure context is initialized for the user if not already
|
21 |
+
if user_id not in context:
|
22 |
+
context[user_id] = ""
|
23 |
+
|
24 |
+
# Prepare modified input with system instructions and context
|
25 |
modified_input = (
|
26 |
f"System Instructions: {system_instructions}\n"
|
27 |
+
f"Previous Context: {context[user_id]}\n"
|
28 |
+
f"User Input: {message}\n"
|
29 |
)
|
30 |
|
31 |
# Collect responses from all APIs
|
|
|
63 |
api_name="/chat"
|
64 |
)
|
65 |
|
66 |
+
# Label the inner thoughts with their respective sources
|
67 |
inner_thoughts = (
|
68 |
+
f"Inner Thought 1 (from Prism): {response_api_one}\n"
|
69 |
+
f"Inner Thought 2 (from ASVIASIACC): {response_api_two}\n"
|
70 |
+
f"Inner Thought 3 (from ACC_o1): {response_api_three}\n"
|
71 |
+
f"Inner Thought 4 (from Pulse): {response_api_four}"
|
72 |
)
|
73 |
|
74 |
+
# Combine the inner thoughts and other input into the final input for the main system
|
75 |
combined_input = f"{modified_input}\nInner Thoughts:\n{inner_thoughts}"
|
76 |
|
77 |
# Generate the main response
|
|
|
80 |
api_name="/chat"
|
81 |
)
|
82 |
|
83 |
+
# Update the user's context with the new message and response
|
84 |
+
context[user_id] += f"User: {message}\nAI: {response_main}\n"
|
85 |
+
|
86 |
+
# Update history to include this interaction
|
87 |
history.append((message, response_main))
|
88 |
|
89 |
+
# Return the cleared message field and updated conversation history
|
90 |
return "", history
|
91 |
|
92 |
# Gradio UI setup
|
93 |
with gr.Blocks(theme=gr.themes.Glass()) as demo:
|
94 |
chatbot = gr.Chatbot()
|
95 |
msg = gr.Textbox(placeholder="Message Z3ta...")
|
96 |
+
user_id = gr.State() # to store the user-specific ID
|
97 |
|
98 |
+
# On message submit, call the function to process the input and provide a response
|
99 |
+
msg.submit(acc_zeta_text_generation_auth_1863381mps, [msg, chatbot, user_id], [msg, chatbot])
|
100 |
|
101 |
demo.launch()
|
102 |
+
|
103 |
+
|
104 |
+
|