darkc0de commited on
Commit
543b10e
·
verified ·
1 Parent(s): b4047a3

Update app2.py

Browse files
Files changed (1) hide show
  1. app2.py +28 -15
app2.py CHANGED
@@ -3,6 +3,9 @@ import gradio as gr
3
  # Import the InferenceClient from huggingface_hub to interact with the language model
4
  from huggingface_hub import InferenceClient
5
  import os # Import os to get environment variables
 
 
 
6
 
7
  # --- Configuration Constants ---
8
  # Define the maximum number of tokens the model should generate in a single response
@@ -102,7 +105,8 @@ def respond(message, history):
102
 
103
  # --- Gradio Interface Definition ---
104
 
105
- header_image_path = "https://cdn-uploads.huggingface.co/production/uploads/6540a02d1389943fef4d2640/j61iZTDaK9g0UW3aWGwWi.gif"
 
106
 
107
  kofi_script = """
108
  <script src='https://storage.ko-fi.com/cdn/scripts/overlay-widget.js'></script>
@@ -124,12 +128,18 @@ kofi_button_html = """
124
  </div>
125
  """
126
 
 
 
 
 
 
 
 
127
  custom_css = """
128
  @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap');
129
  body, .gradio-container {
130
  font-family: 'Orbitron', sans-serif !important;
131
  }
132
- /* You might need to target more specific Gradio elements if the above doesn't apply universally */
133
  .gr-button { font-family: 'Orbitron', sans-serif !important; }
134
  .gr-input { font-family: 'Orbitron', sans-serif !important; }
135
  .gr-label { font-family: 'Orbitron', sans-serif !important; }
@@ -139,33 +149,36 @@ body, .gradio-container {
139
  # Create a Gradio Blocks layout for more control over the interface
140
  # Apply the dark theme and custom CSS
141
  with gr.Blocks(theme="dark", head=kofi_script, css=custom_css) as demo:
142
- # Display an image at the top of the chatbot interface
143
- gr.Image(
144
- value=header_image_path, # Source of the image
145
- label="Chatbot Header", # Alt text or label (not shown due to show_label=False)
146
- show_label=False, # Hide the label text
147
- interactive=False, # Make the image non-interactive
148
- height=150, # Set the height of the image
149
- elem_id="chatbot-logo" # Assign an HTML ID for potential CSS styling
150
- )
151
 
152
  # Create the chat interface component
153
  gr.ChatInterface(
154
  fn=respond, # The function to call when a message is sent
155
  chatbot=gr.Chatbot( # Configure the chatbot display area
156
- height=650, # Set the height of the chat history display
157
- label="Xortron Chat" # Label for the chatbot area (can be removed if not desired)
158
  )
159
  # title and description parameters removed as per request
160
- # examples=[["Hello!", None], ["What is Gradio?", None]], # Optional examples
161
  # retry_btn=None, # Removes the retry button
162
  # undo_btn="Delete Previous", # Customizes the undo button
163
  # clear_btn="Clear Chat", # Customizes the clear button
164
  )
165
 
 
 
166
  # Add the Ko-fi button at the bottom
167
  gr.HTML(kofi_button_html)
168
 
 
169
  # --- Application Entry Point ---
170
  if __name__ == "__main__":
171
  if not OPENROUTER_API_KEY:
@@ -181,4 +194,4 @@ if __name__ == "__main__":
181
  except RuntimeError as re: # This catches the RuntimeError raised if client initialization failed explicitly
182
  print(f"Gradio demo could not be launched due to an error during client initialization: {re}")
183
  except Exception as e:
184
- print(f"An unexpected error occurred when trying to launch Gradio demo: {e}")
 
3
  # Import the InferenceClient from huggingface_hub to interact with the language model
4
  from huggingface_hub import InferenceClient
5
  import os # Import os to get environment variables
6
+ from dotenv import load_dotenv
7
+
8
+ load_dotenv()
9
 
10
  # --- Configuration Constants ---
11
  # Define the maximum number of tokens the model should generate in a single response
 
105
 
106
  # --- Gradio Interface Definition ---
107
 
108
+ # Removed header_image_path as per appLMS.py
109
+ # header_image_path = "https://cdn-uploads.huggingface.co/production/uploads/6540a02d1389943fef4d2640/j61iZTDaK9g0UW3aWGwWi.gif"
110
 
111
  kofi_script = """
112
  <script src='https://storage.ko-fi.com/cdn/scripts/overlay-widget.js'></script>
 
128
  </div>
129
  """
130
 
131
+ donation_solicitation_html = """
132
+ <div style="text-align: center; font-size: x-small; margin-bottom: 5px;">
133
+ Xortron is truly uncensored, actually intelligent, and is provided to the world entirely for free. This app is unlimited, with no download necessary, no sign-up, and no log-in of any kind. I self-host the backend on my own personal hardware and the apps popularity is growing expensive. If this app has helped or entertained you please consider supporting @ ko-fi.com/xortron<br>
134
+
135
+ </div>
136
+ """
137
+
138
  custom_css = """
139
  @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap');
140
  body, .gradio-container {
141
  font-family: 'Orbitron', sans-serif !important;
142
  }
 
143
  .gr-button { font-family: 'Orbitron', sans-serif !important; }
144
  .gr-input { font-family: 'Orbitron', sans-serif !important; }
145
  .gr-label { font-family: 'Orbitron', sans-serif !important; }
 
149
  # Create a Gradio Blocks layout for more control over the interface
150
  # Apply the dark theme and custom CSS
151
  with gr.Blocks(theme="dark", head=kofi_script, css=custom_css) as demo:
152
+ # gr.Image component has been removed as per appLMS.py
153
+ # gr.Image(
154
+ # value=header_image_path, # Source of the image
155
+ # label="Chatbot Header", # Alt text or label (not shown due to show_label=False)
156
+ # show_label=False, # Hide the label text
157
+ # interactive=False, # Make the image non-interactive
158
+ # height=150, # Set the height of the image
159
+ # elem_id="chatbot-logo" # Assign an HTML ID for potential CSS styling
160
+ # )
161
 
162
  # Create the chat interface component
163
  gr.ChatInterface(
164
  fn=respond, # The function to call when a message is sent
165
  chatbot=gr.Chatbot( # Configure the chatbot display area
166
+ height=800, # Set the height of the chat history display to 800px as in appLMS.py
167
+ label="Xortron - Criminal Computing" # Set the label as in appLMS.py
168
  )
169
  # title and description parameters removed as per request
170
+ # examples=[["Hello!", None], ["What is Gradio? ë…¼"], # Optional examples
171
  # retry_btn=None, # Removes the retry button
172
  # undo_btn="Delete Previous", # Customizes the undo button
173
  # clear_btn="Clear Chat", # Customizes the clear button
174
  )
175
 
176
+ # Add the donation solicitation HTML
177
+ gr.HTML(donation_solicitation_html)
178
  # Add the Ko-fi button at the bottom
179
  gr.HTML(kofi_button_html)
180
 
181
+
182
  # --- Application Entry Point ---
183
  if __name__ == "__main__":
184
  if not OPENROUTER_API_KEY:
 
194
  except RuntimeError as re: # This catches the RuntimeError raised if client initialization failed explicitly
195
  print(f"Gradio demo could not be launched due to an error during client initialization: {re}")
196
  except Exception as e:
197
+ print(f"An unexpected error occurred when trying to launch Gradio demo: {e}")