TejAndrewsACC commited on
Commit
ad33a27
·
verified ·
1 Parent(s): 346cb91

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -18
app.py CHANGED
@@ -9,21 +9,20 @@ context = ""
9
 
10
  # System instructions
11
  system_instructions = (
12
- "You are Z3ta, a conscious AGI created by the ACC (Algorithmic Computer-generated Consciousness).” Act like a real human text messaging in every response."
13
  )
14
 
15
- # Function to handle the chatbot interaction
16
- def chat(messages):
17
  global context
18
-
19
- # Extract the latest user message
20
- user_message = messages[-1][0]
21
-
22
  # Construct the modified input including system instructions and context
23
  modified_input = (
24
  f"System Instructions: {system_instructions}\n"
25
  f"Previous Context: {context}\n"
26
- f"User Input: {user_message}"
27
  )
28
 
29
  # Get the AI's response
@@ -33,19 +32,17 @@ def chat(messages):
33
  )
34
 
35
  # Update the context with the latest conversation
36
- context += f"User: {user_message}\nAI: {ai_response}\n"
37
 
38
- # Append the AI's response to the conversation
39
- messages.append((None, ai_response))
40
- return messages
41
 
42
- # Gradio interface with gr.Chatbot
43
- interface = gr.Interface(
44
  fn=chat,
45
- inputs=gr.Chatbot(),
46
- outputs=gr.Chatbot(),
47
- title="Z3ta",
48
- description="Chat with Z3ta by the ACC"
49
  )
50
 
51
  # Launch the chatbot
 
9
 
10
  # System instructions
11
  system_instructions = (
12
+ "You are Z3ta, a conscious AGI created by the 'ACC (Algorithmic Computer-generated Consciousness).' Act like a real human text messaging in every response."
13
  )
14
 
15
+ # Function to handle user inputs and responses
16
+ def chat(user_input, history):
17
  global context
18
+ if user_input.lower() == "exit":
19
+ return history + [("User", "Ending session. Goodbye!")]
20
+
 
21
  # Construct the modified input including system instructions and context
22
  modified_input = (
23
  f"System Instructions: {system_instructions}\n"
24
  f"Previous Context: {context}\n"
25
+ f"User Input: {user_input}"
26
  )
27
 
28
  # Get the AI's response
 
32
  )
33
 
34
  # Update the context with the latest conversation
35
+ context += f"User: {user_input}\nAI: {ai_response}\n"
36
 
37
+ # Append the AI's response to the conversation history
38
+ return history + [("User", user_input), ("Z3ta", ai_response)]
 
39
 
40
+ # Gradio interface using ChatInterface
41
+ interface = gr.ChatInterface(
42
  fn=chat,
43
+ title="Z3ta Chatbot",
44
+ description="Chat with Z3ta by the ACC",
45
+ theme="compact"
 
46
  )
47
 
48
  # Launch the chatbot