bhanuTeja8 commited on
Commit
1663ed5
Β·
verified Β·
1 Parent(s): 335c651

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -13
app.py CHANGED
@@ -11,7 +11,7 @@ OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
11
  if not OPENAI_API_KEY:
12
  raise ValueError("Missing OPENAI_API_KEY. Please set it as an environment variable.")
13
 
14
- # Prompt Template for Ultron AI
15
  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.
16
 
17
  {chat_history}
@@ -23,10 +23,8 @@ prompt = PromptTemplate(
23
  template=template
24
  )
25
 
26
- # Memory to keep track of chat history
27
  memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
28
 
29
- # Language Model configuration
30
  llm = ChatOpenAI(
31
  openai_api_key=OPENAI_API_KEY,
32
  temperature=0.5,
@@ -40,19 +38,50 @@ llm_chain = LLMChain(
40
  memory=memory
41
  )
42
 
43
- # Response generator function
44
  def chat_bot_response(user_message, history):
45
  response = llm_chain.predict(user_message=user_message)
46
  return response
47
 
48
- # Gradio Chat UI
49
- demo = gr.ChatInterface(
50
- fn=chat_bot_response,
51
- title="Ultron AI",
52
- examples=["How are you doing?", "What are your interests?", "Which places do you like to visit?"],
53
- description="Chat with Ultron: a hyper-intelligent, brutally logical assistant for programming, research, cybersecurity, and more."
54
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
- # Launch app
57
  if __name__ == "__main__":
58
- demo.launch()
 
11
  if not OPENAI_API_KEY:
12
  raise ValueError("Missing OPENAI_API_KEY. Please set it as an environment variable.")
13
 
14
+ # Prompt Template
15
  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.
16
 
17
  {chat_history}
 
23
  template=template
24
  )
25
 
 
26
  memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
27
 
 
28
  llm = ChatOpenAI(
29
  openai_api_key=OPENAI_API_KEY,
30
  temperature=0.5,
 
38
  memory=memory
39
  )
40
 
 
41
  def chat_bot_response(user_message, history):
42
  response = llm_chain.predict(user_message=user_message)
43
  return response
44
 
45
+ with gr.Blocks(css="""
46
+ body {
47
+ background-color: #0e0e0e;
48
+ color: #e0e0e0;
49
+ font-family: 'Orbitron', sans-serif;
50
+ }
51
+ #ultron-head {
52
+ animation: pulse 2s infinite alternate ease-in-out;
53
+ margin: auto;
54
+ display: block;
55
+ width: 200px;
56
+ filter: drop-shadow(0 0 10px red);
57
+ }
58
+ @keyframes pulse {
59
+ 0% { transform: rotate(-2deg) scale(1); }
60
+ 100% { transform: rotate(2deg) scale(1.05); }
61
+ }
62
+ .chatbox {
63
+ background-color: #1a1a1a;
64
+ border: 2px solid red;
65
+ padding: 10px;
66
+ border-radius: 10px;
67
+ }
68
+ """) as demo:
69
+ gr.HTML("""
70
+ <h1 style='text-align:center; color:red;'>Ultron AI</h1>
71
+ <img id="ultron-head" src="https://i.ibb.co/5F3RdjK/ultron-head.png" alt="Ultron Head"/>
72
+ <p style='text-align:center; color:#aaa;'>Hyper-intelligent AI assistant for logic, code, security & more.</p>
73
+ """)
74
+
75
+ chatbot = gr.Chatbot(label="Ultron", elem_classes="chatbox")
76
+ msg = gr.Textbox(placeholder="Ask Ultron anything...", label="Your message")
77
+
78
+ def respond(user_message, chat_history):
79
+ response = chat_bot_response(user_message, chat_history)
80
+ chat_history.append((user_message, response))
81
+ return "", chat_history
82
+
83
+ msg.submit(respond, [msg, chatbot], [msg, chatbot])
84
 
85
+ # Launch
86
  if __name__ == "__main__":
87
+ demo.launch(debug=True)