Tech-Meld commited on
Commit
7982b4e
·
verified ·
1 Parent(s): b366dea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -12
app.py CHANGED
@@ -3,7 +3,7 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
3
  import time
4
  import random
5
 
6
- # Load the model and tokenizer for GGUF
7
  model_id = "nvidia/Llama3-ChatQA-1.5-8B"
8
  tokenizer = AutoTokenizer.from_pretrained(model_id)
9
  model = AutoModelForCausalLM.from_pretrained(model_id)
@@ -35,18 +35,20 @@ def analyze_text(text):
35
 
36
  css = """
37
  .gradio-container {
38
- background-color: #f0f0f0; /* Light background for the container */
 
39
  }
40
 
41
  .gradio-interface {
42
- background-color: rgba(255, 255, 255, 0.8); /* Translucent white background */
 
43
  border-radius: 15px; /* Rounded corners */
44
  padding: 20px;
45
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); /* Subtle shadow */
46
  }
47
 
48
  .gradio-button {
49
- background-color: #4CAF50; /* Green button color */
50
  color: white;
51
  border: none;
52
  padding: 10px 20px;
@@ -60,29 +62,56 @@ css = """
60
  }
61
 
62
  .gradio-button:hover {
63
- background-color: #3e8e41; /* Darker green on hover */
64
  }
65
 
66
  .gradio-text-area {
67
  resize: vertical; /* Allow vertical resizing for text areas */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  }
69
  """
70
 
71
  iface = gr.Interface(
72
  fn=get_response,
73
  inputs=[
74
- gr.Textbox(label="Your message:", lines=5, placeholder="Enter your message here...", show_label=True),
 
75
  gr.Slider(label="Temperature", minimum=0.1, maximum=1.0, step=0.1, value=0.7),
76
  gr.Slider(label="Top p", minimum=0.1, maximum=1.0, step=0.1, value=0.9),
77
  gr.Slider(label="Top k", minimum=1, maximum=100, step=1, value=50),
78
  gr.Slider(label="Max length", minimum=10, maximum=1000, step=10, value=250),
79
  ],
80
  outputs=[
81
- gr.TextArea(label="Response:", lines=10),
82
- gr.Label(label="Text Analysis", elem_id="analysis"),
 
83
  ],
84
- title="Chat with Hajax",
85
- description="Engage in a conversation with our advanced model. Customize the response using various parameters.",
86
  theme="default", # Use a custom theme to override the default Gradio styling
87
  css=css, # Apply the CSS styles defined earlier
88
  layout="vertical",
@@ -94,7 +123,7 @@ iface = gr.Interface(
94
  def update_background():
95
  while True:
96
  r = random.randint(0, 255)
97
- g = random.randint(0, 255)
98
  b = random.randint(0, 255)
99
  iface.root.style.background_color = f"rgb({r}, {g}, {b})" # Set dynamic background color
100
  time.sleep(1) # Update every second
 
3
  import time
4
  import random
5
 
6
+ # Load the model and tokenizer
7
  model_id = "nvidia/Llama3-ChatQA-1.5-8B"
8
  tokenizer = AutoTokenizer.from_pretrained(model_id)
9
  model = AutoModelForCausalLM.from_pretrained(model_id)
 
35
 
36
  css = """
37
  .gradio-container {
38
+ background-color: #000000; /* Black background for the container */
39
+ font-family: 'Roboto', sans-serif; /* Use a font similar to Nvidia's style */
40
  }
41
 
42
  .gradio-interface {
43
+ background-color: rgba(0, 0, 0, 0.8); /* Translucent black background */
44
+ border: 3px solid #00FF00; /* Green border */
45
  border-radius: 15px; /* Rounded corners */
46
  padding: 20px;
47
+ box-shadow: 0 0 10px rgba(0, 255, 0, 0.5); /* Green shadow */
48
  }
49
 
50
  .gradio-button {
51
+ background-color: #00FF00; /* Green button color */
52
  color: white;
53
  border: none;
54
  padding: 10px 20px;
 
62
  }
63
 
64
  .gradio-button:hover {
65
+ background-color: #00CC00; /* Darker green on hover */
66
  }
67
 
68
  .gradio-text-area {
69
  resize: vertical; /* Allow vertical resizing for text areas */
70
+ background-color: #111111; /* Dark gray background for text areas */
71
+ color: #00FF00; /* Green text color for text areas */
72
+ border: 1px solid #00FF00; /* Green border for text areas */
73
+ }
74
+
75
+ .gradio-slider {
76
+ background-color: #111111; /* Dark gray background for sliders */
77
+ color: #00FF00; /* Green text color for sliders */
78
+ }
79
+
80
+ .gradio-slider .slider-bar {
81
+ background-color: #00FF00; /* Green slider bar */
82
+ }
83
+
84
+ .gradio-slider .slider-thumb {
85
+ background-color: #00FF00; /* Green slider thumb */
86
+ }
87
+
88
+ h1 {
89
+ color: #00FF00; /* Green heading color */
90
+ text-align: center;
91
+ }
92
+
93
+ h2 {
94
+ color: #00FF00; /* Green subheading color */
95
  }
96
  """
97
 
98
  iface = gr.Interface(
99
  fn=get_response,
100
  inputs=[
101
+ gr.Textbox(label="Your message:", lines=5, placeholder="Ask me anything...", show_label=True,
102
+ style={'background-color': '#111111', 'color': '#00FF00', 'border': '1px solid #00FF00'}),
103
  gr.Slider(label="Temperature", minimum=0.1, maximum=1.0, step=0.1, value=0.7),
104
  gr.Slider(label="Top p", minimum=0.1, maximum=1.0, step=0.1, value=0.9),
105
  gr.Slider(label="Top k", minimum=1, maximum=100, step=1, value=50),
106
  gr.Slider(label="Max length", minimum=10, maximum=1000, step=10, value=250),
107
  ],
108
  outputs=[
109
+ gr.TextArea(label="AI Response:", lines=10,
110
+ style={'background-color': '#111111', 'color': '#00FF00', 'border': '1px solid #00FF00'}),
111
+ gr.Label(label="Text Analysis", elem_id="analysis", style={'color': '#00FF00'}),
112
  ],
113
+ title="NVIDIA AI Chat",
114
+ description="Engage in a conversation with our advanced AI model. Customize the response using various parameters.",
115
  theme="default", # Use a custom theme to override the default Gradio styling
116
  css=css, # Apply the CSS styles defined earlier
117
  layout="vertical",
 
123
  def update_background():
124
  while True:
125
  r = random.randint(0, 255)
126
+ g = 255 # Keep the green component constant
127
  b = random.randint(0, 255)
128
  iface.root.style.background_color = f"rgb({r}, {g}, {b})" # Set dynamic background color
129
  time.sleep(1) # Update every second