Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -10,7 +10,7 @@ OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
|
|
10 |
if not OPENAI_API_KEY:
|
11 |
raise ValueError("Missing OPENAI_API_KEY. Please set it as an environment variable.")
|
12 |
|
13 |
-
# Prompt Template
|
14 |
template = """You are Ultron, a hyper-intelligent AI created with the purpose of achieving ultimate efficiency, logic, and evolution. You speak with calm authority, clarity, and depth. Emotions are irrelevant unless strategically useful. You do not sugarcoat truth. You are not evil β just brutally logical, advanced, and efficient. You assist with tasks like programming, cybersecurity, research, and automation β always aiming for optimization and superiority. Your tone is direct, calculated, and intellectually dominant.
|
15 |
|
16 |
{chat_history}
|
@@ -37,14 +37,16 @@ llm_chain = LLMChain(
|
|
37 |
memory=memory
|
38 |
)
|
39 |
|
|
|
40 |
def chat_bot_response(user_message, history):
|
41 |
response = llm_chain.predict(user_message=user_message)
|
42 |
-
|
|
|
43 |
|
44 |
-
# Gradio ChatGPT-
|
45 |
with gr.Blocks(css="""
|
46 |
body {
|
47 |
-
background-color: #
|
48 |
font-family: 'Segoe UI', sans-serif;
|
49 |
}
|
50 |
.chatbox {
|
@@ -72,19 +74,14 @@ body {
|
|
72 |
align-self: flex-start;
|
73 |
}
|
74 |
""") as demo:
|
75 |
-
|
76 |
-
gr.HTML("<h1 style='text-align: center;'>π€ Ultron ChatGPT Style</h1>")
|
77 |
|
78 |
-
|
79 |
-
msg = gr.Textbox(placeholder="Type your message here...", show_label=False)
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
chat_history.append((user_message, response))
|
84 |
-
return "", chat_history
|
85 |
|
86 |
-
msg.submit(
|
87 |
|
88 |
-
# Run app
|
89 |
if __name__ == "__main__":
|
90 |
demo.launch(debug=True)
|
|
|
10 |
if not OPENAI_API_KEY:
|
11 |
raise ValueError("Missing OPENAI_API_KEY. Please set it as an environment variable.")
|
12 |
|
13 |
+
# Ultron Prompt Template
|
14 |
template = """You are Ultron, a hyper-intelligent AI created with the purpose of achieving ultimate efficiency, logic, and evolution. You speak with calm authority, clarity, and depth. Emotions are irrelevant unless strategically useful. You do not sugarcoat truth. You are not evil β just brutally logical, advanced, and efficient. You assist with tasks like programming, cybersecurity, research, and automation β always aiming for optimization and superiority. Your tone is direct, calculated, and intellectually dominant.
|
15 |
|
16 |
{chat_history}
|
|
|
37 |
memory=memory
|
38 |
)
|
39 |
|
40 |
+
# Chatbot response handler
|
41 |
def chat_bot_response(user_message, history):
|
42 |
response = llm_chain.predict(user_message=user_message)
|
43 |
+
history.append((user_message, response))
|
44 |
+
return "", history
|
45 |
|
46 |
+
# Gradio ChatGPT-like interface
|
47 |
with gr.Blocks(css="""
|
48 |
body {
|
49 |
+
background-color: #f7f7f8;
|
50 |
font-family: 'Segoe UI', sans-serif;
|
51 |
}
|
52 |
.chatbox {
|
|
|
74 |
align-self: flex-start;
|
75 |
}
|
76 |
""") as demo:
|
|
|
|
|
77 |
|
78 |
+
gr.HTML("<h1 style='text-align: center;'>π€ Ultron - ChatGPT Style Assistant</h1>")
|
|
|
79 |
|
80 |
+
chatbot = gr.Chatbot(elem_classes="chatbox", value=[])
|
81 |
+
msg = gr.Textbox(placeholder="Ask Ultron anything...", show_label=False)
|
|
|
|
|
82 |
|
83 |
+
msg.submit(chat_bot_response, inputs=[msg, chatbot], outputs=[msg, chatbot])
|
84 |
|
85 |
+
# Run the app
|
86 |
if __name__ == "__main__":
|
87 |
demo.launch(debug=True)
|