darkc0de commited on
Commit
75d5258
·
verified ·
1 Parent(s): 3e0b2c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -10
app.py CHANGED
@@ -44,23 +44,71 @@ def respond(message, history):
44
  header_image_path = "https://cdn-uploads.huggingface.co/production/uploads/6540a02d1389943fef4d2640/j61iZTDaK9g0UW3aWGwWi.gif"
45
 
46
 
47
- with gr.Blocks(theme=gr.themes.Soft()) as demo:
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  gr.Image(
50
- value=header_image_path,
51
- label="Chatbot Header",
52
- show_label=False,
53
- interactive=False,
54
- height=100,
55
- elem_id="chatbot-logo"
56
  )
57
 
 
58
  gr.ChatInterface(
59
- respond,
60
- chatbot=gr.Chatbot(
61
- height=700
 
62
  )
 
 
 
 
 
63
  )
64
 
 
 
 
65
  if __name__ == "__main__":
66
  demo.launch(show_api=False, share=True)
 
44
  header_image_path = "https://cdn-uploads.huggingface.co/production/uploads/6540a02d1389943fef4d2640/j61iZTDaK9g0UW3aWGwWi.gif"
45
 
46
 
47
+ # --- Gradio Interface Definition ---
48
 
49
+ header_image_path = "https://cdn-uploads.huggingface.co/production/uploads/6540a02d1389943fef4d2640/j61iZTDaK9g0UW3aWGwWi.gif"
50
+
51
+ kofi_script = """
52
+ <script src='https://storage.ko-fi.com/cdn/scripts/overlay-widget.js'></script>
53
+ <script>
54
+ kofiWidgetOverlay.draw('sonnydesorbo', {
55
+ 'type': 'floating-chat',
56
+ 'floating-chat.donateButton.text': 'Support me',
57
+ 'floating-chat.donateButton.background-color': '#00b9fe',
58
+ 'floating-chat.donateButton.text-color': '#fff'
59
+ });
60
+ </script>
61
+ """
62
+
63
+ kofi_button_html = """
64
+ <div style="text-align: center; padding: 20px;">
65
+ <a href='https://ko-fi.com/Z8Z51E5TIG' target='_blank'>
66
+ <img height='36' style='border:0px;height:36px;' src='https://storage.ko-fi.com/cdn/kofi5.png?v=6' border='0' alt='Buy Me a Coffee at ko-fi.com' />
67
+ </a>
68
+ </div>
69
+ """
70
+
71
+ custom_css = """
72
+ @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap');
73
+ body, .gradio-container {
74
+ font-family: 'Orbitron', sans-serif !important;
75
+ }
76
+ /* You might need to target more specific Gradio elements if the above doesn't apply universally */
77
+ .gr-button { font-family: 'Orbitron', sans-serif !important; }
78
+ .gr-input { font-family: 'Orbitron', sans-serif !important; }
79
+ .gr-label { font-family: 'Orbitron', sans-serif !important; }
80
+ .gr-chatbot .message { font-family: 'Orbitron', sans-serif !important; }
81
+ """
82
+
83
+ # Create a Gradio Blocks layout for more control over the interface
84
+ # Apply the dark theme and custom CSS
85
+ with gr.Blocks(theme="dark", head=kofi_script, css=custom_css) as demo:
86
+ # Display an image at the top of the chatbot interface
87
  gr.Image(
88
+ value=header_image_path, # Source of the image
89
+ label="Chatbot Header", # Alt text or label (not shown due to show_label=False)
90
+ show_label=False, # Hide the label text
91
+ interactive=False, # Make the image non-interactive
92
+ height=150, # Set the height of the image
93
+ elem_id="chatbot-logo" # Assign an HTML ID for potential CSS styling
94
  )
95
 
96
+ # Create the chat interface component
97
  gr.ChatInterface(
98
+ fn=respond, # The function to call when a message is sent
99
+ chatbot=gr.Chatbot( # Configure the chatbot display area
100
+ height=650, # Set the height of the chat history display
101
+ label="Xortron Chat" # Label for the chatbot area (can be removed if not desired)
102
  )
103
+ # title and description parameters removed as per request
104
+ # examples=[["Hello!", None], ["What is Gradio?", None]], # Optional examples
105
+ # retry_btn=None, # Removes the retry button
106
+ # undo_btn="Delete Previous", # Customizes the undo button
107
+ # clear_btn="Clear Chat", # Customizes the clear button
108
  )
109
 
110
+ # Add the Ko-fi button at the bottom
111
+ gr.HTML(kofi_button_html)
112
+
113
  if __name__ == "__main__":
114
  demo.launch(show_api=False, share=True)