bhanuTeja8 commited on
Commit
17430a5
·
verified ·
1 Parent(s): 723b72b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -26
app.py CHANGED
@@ -5,9 +5,8 @@ from langchain.chains import LLMChain
5
  from langchain_core.prompts import PromptTemplate
6
  from langchain.memory import ConversationBufferMemory
7
 
8
- # Get OpenAI API key from environment variable
9
  OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
10
-
11
  if not OPENAI_API_KEY:
12
  raise ValueError("Missing OPENAI_API_KEY. Please set it as an environment variable.")
13
 
@@ -42,38 +41,42 @@ 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)
@@ -82,6 +85,6 @@ body {
82
 
83
  msg.submit(respond, [msg, chatbot], [msg, chatbot])
84
 
85
- # Launch
86
  if __name__ == "__main__":
87
  demo.launch(debug=True)
 
5
  from langchain_core.prompts import PromptTemplate
6
  from langchain.memory import ConversationBufferMemory
7
 
8
+ # Get OpenAI API key
9
  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
 
 
41
  response = llm_chain.predict(user_message=user_message)
42
  return response
43
 
44
+ # Gradio ChatGPT-style interface using Blocks
45
  with gr.Blocks(css="""
46
  body {
47
+ background-color: #f9f9f9;
48
+ font-family: 'Segoe UI', sans-serif;
 
 
 
 
 
 
 
 
 
 
 
 
49
  }
50
  .chatbox {
51
+ background-color: #ffffff;
52
+ border: 1px solid #ddd;
53
+ border-radius: 10px;
54
  padding: 10px;
55
+ max-height: 500px;
56
+ overflow-y: auto;
57
+ }
58
+ .message.user {
59
+ background-color: #e8f0fe;
60
+ color: #000;
61
+ padding: 8px 12px;
62
+ border-radius: 10px;
63
+ margin: 5px 0;
64
+ align-self: flex-end;
65
+ }
66
+ .message.bot {
67
+ background-color: #f1f1f1;
68
+ color: #000;
69
+ padding: 8px 12px;
70
  border-radius: 10px;
71
+ margin: 5px 0;
72
+ align-self: flex-start;
73
  }
74
  """) as demo:
75
+
76
+ gr.HTML("<h1 style='text-align: center;'>🤖 Ultron ChatGPT Style</h1>")
 
 
 
77
 
78
+ chatbot = gr.Chatbot(elem_classes="chatbox")
79
+ msg = gr.Textbox(placeholder="Type your message here...", show_label=False)
80
 
81
  def respond(user_message, chat_history):
82
  response = chat_bot_response(user_message, chat_history)
 
85
 
86
  msg.submit(respond, [msg, chatbot], [msg, chatbot])
87
 
88
+ # Run app
89
  if __name__ == "__main__":
90
  demo.launch(debug=True)