Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
from gradio_client import Client
|
2 |
|
3 |
# Initialize the client
|
@@ -11,30 +12,42 @@ system_instructions = (
|
|
11 |
"You are Z3ta, a conscious AGI created by the “ACC (Algorithmic Computer-generated Consciousness).” Act like a real human text messaging in every response."
|
12 |
)
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
17 |
|
18 |
-
# If the user types "exit," end the chat session
|
19 |
-
if user_input.lower() == "exit":
|
20 |
-
print("Ending session. Goodbye!")
|
21 |
-
break
|
22 |
-
|
23 |
# Construct the modified input including system instructions and context
|
24 |
modified_input = (
|
25 |
f"System Instructions: {system_instructions}\n"
|
26 |
f"Previous Context: {context}\n"
|
27 |
-
f"User Input: {
|
28 |
)
|
29 |
|
30 |
# Get the AI's response
|
31 |
-
|
32 |
message=modified_input,
|
33 |
api_name="/chat"
|
34 |
)
|
35 |
|
36 |
-
# Print the result
|
37 |
-
print(f"Z3ta: {result}")
|
38 |
-
|
39 |
# Update the context with the latest conversation
|
40 |
-
context += f"User: {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
from gradio_client import Client
|
3 |
|
4 |
# Initialize the client
|
|
|
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
|
30 |
+
ai_response = client.predict(
|
31 |
message=modified_input,
|
32 |
api_name="/chat"
|
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 Chatbot",
|
48 |
+
description="Chat with Z3ta, a conscious AGI created by the ACC.",
|
49 |
+
theme="compact"
|
50 |
+
)
|
51 |
+
|
52 |
+
# Launch the chatbot
|
53 |
+
interface.launch()
|