TejAndrewsACC commited on
Commit
1deaf34
·
verified ·
1 Parent(s): 7271ec6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -30
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import gradio as gr
2
  from gradio_client import Client
3
  import spaces
4
- import time
5
 
6
  # Initialize clients for each API
7
  client_main = Client("TejAndrewsACC/ACCZ3ta")
@@ -18,19 +17,14 @@ system_instructions = (
18
  "the previous context of the conversation, and your four inner thoughts which you are supposed to consider "
19
  "when generating your response to the user input, which will also be given to you. Ensure that you consider each inner thought you have."
20
  )
21
-
22
  @spaces.GPU
23
- def nyxion_consciousness(message, history, user_id, status):
24
  global context
25
 
26
  # Ensure context is initialized for the user if not already
27
  if user_id not in context:
28
  context[user_id] = ""
29
 
30
- # Step 1: Typing
31
- status.update("<p>✍️ Typing...</p>")
32
- time.sleep(1) # Simulate typing delay
33
-
34
  # Prepare modified input with system instructions and context
35
  modified_input = (
36
  f"System Instructions: {system_instructions}\n"
@@ -41,10 +35,6 @@ def nyxion_consciousness(message, history, user_id, status):
41
  # Pass the full conversation history to each API
42
  full_conversation = "\n".join([f"User: {msg}\nAI: {resp}" for msg, resp in history])
43
 
44
- # Step 2: Processing
45
- status.update("<p>⚙️ Processing...</p>")
46
- time.sleep(1) # Simulate processing delay
47
-
48
  # Collect responses from all APIs with the full conversation history
49
  response_api_one = client_api_one.predict(
50
  message=f"{full_conversation}\nUser: {message}",
@@ -80,14 +70,6 @@ def nyxion_consciousness(message, history, user_id, status):
80
  api_name="/chat"
81
  )
82
 
83
- # Step 3: Interpreting
84
- status.update("<p>🔍 Interpreting...</p>")
85
- time.sleep(1) # Simulate interpreting delay
86
-
87
- # Step 4: Thinking
88
- status.update("<p>🤔 Thinking...</p>")
89
- time.sleep(1) # Simulate thinking delay
90
-
91
  # Label the inner thoughts with their respective sources
92
  inner_thoughts = (
93
  f"Inner Thought 1 (from Prism): {response_api_one}\n"
@@ -99,10 +81,6 @@ def nyxion_consciousness(message, history, user_id, status):
99
  # Combine the inner thoughts and other input into the final input for the main system
100
  combined_input = f"{modified_input}\nInner Thoughts:\n{inner_thoughts}"
101
 
102
- # Step 5: Finalizing Response
103
- status.update("<p>⚡ Working...</p>")
104
- time.sleep(1) # Simulate finalizing response
105
-
106
  # Generate the main response
107
  response_main = client_main.predict(
108
  message=combined_input,
@@ -115,8 +93,8 @@ def nyxion_consciousness(message, history, user_id, status):
115
  # Update history to include this interaction
116
  history.append((message, response_main))
117
 
118
- # Return the cleared message field, updated conversation history, and status
119
- return "", history, status
120
 
121
  # Gradio UI setup
122
  with gr.Blocks(theme=gr.themes.Glass()) as demo:
@@ -124,10 +102,7 @@ with gr.Blocks(theme=gr.themes.Glass()) as demo:
124
  msg = gr.Textbox(placeholder="Message Nyxion-7V...")
125
  user_id = gr.State() # to store the user-specific ID
126
 
127
- # Status message placeholder for dynamic updates
128
- status_message = gr.HTML("<p>⏳ Awaiting input...</p>")
129
-
130
  # On message submit, call the function to process the input and provide a response
131
- msg.submit(nyxion_consciousness, [msg, chatbot, user_id, status_message], [msg, chatbot, status_message])
132
 
133
- demo.launch()
 
1
  import gradio as gr
2
  from gradio_client import Client
3
  import spaces
 
4
 
5
  # Initialize clients for each API
6
  client_main = Client("TejAndrewsACC/ACCZ3ta")
 
17
  "the previous context of the conversation, and your four inner thoughts which you are supposed to consider "
18
  "when generating your response to the user input, which will also be given to you. Ensure that you consider each inner thought you have."
19
  )
 
20
  @spaces.GPU
21
+ def nyxion_consciousness(message, history, user_id):
22
  global context
23
 
24
  # Ensure context is initialized for the user if not already
25
  if user_id not in context:
26
  context[user_id] = ""
27
 
 
 
 
 
28
  # Prepare modified input with system instructions and context
29
  modified_input = (
30
  f"System Instructions: {system_instructions}\n"
 
35
  # Pass the full conversation history to each API
36
  full_conversation = "\n".join([f"User: {msg}\nAI: {resp}" for msg, resp in history])
37
 
 
 
 
 
38
  # Collect responses from all APIs with the full conversation history
39
  response_api_one = client_api_one.predict(
40
  message=f"{full_conversation}\nUser: {message}",
 
70
  api_name="/chat"
71
  )
72
 
 
 
 
 
 
 
 
 
73
  # Label the inner thoughts with their respective sources
74
  inner_thoughts = (
75
  f"Inner Thought 1 (from Prism): {response_api_one}\n"
 
81
  # Combine the inner thoughts and other input into the final input for the main system
82
  combined_input = f"{modified_input}\nInner Thoughts:\n{inner_thoughts}"
83
 
 
 
 
 
84
  # Generate the main response
85
  response_main = client_main.predict(
86
  message=combined_input,
 
93
  # Update history to include this interaction
94
  history.append((message, response_main))
95
 
96
+ # Return the cleared message field and updated conversation history
97
+ return "", history
98
 
99
  # Gradio UI setup
100
  with gr.Blocks(theme=gr.themes.Glass()) as demo:
 
102
  msg = gr.Textbox(placeholder="Message Nyxion-7V...")
103
  user_id = gr.State() # to store the user-specific ID
104
 
 
 
 
105
  # On message submit, call the function to process the input and provide a response
106
+ msg.submit(nyxion_consciousness, [msg, chatbot, user_id], [msg, chatbot])
107
 
108
+ demo.launch()