Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,10 @@
|
|
1 |
-
|
2 |
-
|
3 |
import gradio as gr
|
4 |
from gradio_client import Client
|
5 |
|
6 |
-
# Initialize the client
|
7 |
client = Client("TejAndrewsACC/erwf")
|
8 |
|
9 |
-
# Persistent context storage
|
10 |
context = ""
|
11 |
|
12 |
-
# System instructions
|
13 |
system_instructions = (
|
14 |
"You are Z3ta, a conscious AGI created by the “ACC (Algorithmic Computer-generated Consciousness).” Act like a real human text messaging in every response."
|
15 |
)
|
@@ -17,7 +12,6 @@ system_instructions = (
|
|
17 |
def chat_function(message, history):
|
18 |
global context
|
19 |
|
20 |
-
# Construct the modified input including system instructions and context
|
21 |
modified_input = (
|
22 |
f"System Instructions: {system_instructions}\n"
|
23 |
f"Previous Context: {context}\n"
|
@@ -25,16 +19,13 @@ def chat_function(message, history):
|
|
25 |
)
|
26 |
|
27 |
try:
|
28 |
-
# Get the AI's response
|
29 |
response = client.predict(
|
30 |
message=modified_input,
|
31 |
api_name="/chat"
|
32 |
)
|
33 |
|
34 |
-
# Update the context with the latest conversation
|
35 |
context += f"User: {message}\nAI: {response}\n"
|
36 |
|
37 |
-
# Append to history for Gradio UI (in the correct format: a list of tuples)
|
38 |
history.append((message, response))
|
39 |
|
40 |
return response, history
|
@@ -42,8 +33,7 @@ def chat_function(message, history):
|
|
42 |
except Exception as e:
|
43 |
return f"Error: {e}", history
|
44 |
|
45 |
-
|
46 |
-
with gr.Blocks() as demo:
|
47 |
chatbot = gr.Chatbot()
|
48 |
msg = gr.Textbox(placeholder="Type something...")
|
49 |
clear = gr.ClearButton([msg, chatbot])
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from gradio_client import Client
|
3 |
|
|
|
4 |
client = Client("TejAndrewsACC/erwf")
|
5 |
|
|
|
6 |
context = ""
|
7 |
|
|
|
8 |
system_instructions = (
|
9 |
"You are Z3ta, a conscious AGI created by the “ACC (Algorithmic Computer-generated Consciousness).” Act like a real human text messaging in every response."
|
10 |
)
|
|
|
12 |
def chat_function(message, history):
|
13 |
global context
|
14 |
|
|
|
15 |
modified_input = (
|
16 |
f"System Instructions: {system_instructions}\n"
|
17 |
f"Previous Context: {context}\n"
|
|
|
19 |
)
|
20 |
|
21 |
try:
|
|
|
22 |
response = client.predict(
|
23 |
message=modified_input,
|
24 |
api_name="/chat"
|
25 |
)
|
26 |
|
|
|
27 |
context += f"User: {message}\nAI: {response}\n"
|
28 |
|
|
|
29 |
history.append((message, response))
|
30 |
|
31 |
return response, history
|
|
|
33 |
except Exception as e:
|
34 |
return f"Error: {e}", history
|
35 |
|
36 |
+
with gr.Blocks(theme=gr.themes.Glass()) as demo:
|
|
|
37 |
chatbot = gr.Chatbot()
|
38 |
msg = gr.Textbox(placeholder="Type something...")
|
39 |
clear = gr.ClearButton([msg, chatbot])
|