darkc0de commited on
Commit
069b824
Β·
verified Β·
1 Parent(s): 3f5d005

Delete appLMS.py

Browse files
Files changed (1) hide show
  1. appLMS.py +0 -103
appLMS.py DELETED
@@ -1,103 +0,0 @@
1
- import gradio as gr
2
- from huggingface_hub import InferenceClient
3
- import os
4
- from dotenv import load_dotenv
5
-
6
- load_dotenv()
7
-
8
- api_url = os.getenv("API_URL")
9
-
10
- if api_url is None:
11
- raise ValueError("API_URL environment variable not set. Please create a .env file with API_URL.")
12
-
13
- client = InferenceClient(api_url)
14
-
15
- # FIXED_MAX_TOKENS, FIXED_TEMPERATURE, FIXED_TOP_P have been removed.
16
-
17
- # SYSTEM_PROMPT has been entirely removed as requested.
18
-
19
- def respond(message, history):
20
- messages = [] # Removed the initial system prompt addition here
21
-
22
- for user_message, ai_message in history:
23
- if user_message:
24
- messages.append({"role": "user", "content": user_message})
25
- if ai_message:
26
- messages.append({"role": "assistant", "content": ai_message})
27
-
28
- messages.append({"role": "user", "content": message})
29
-
30
- response_text = ""
31
-
32
- try:
33
- for chunk in client.chat.completions.create(
34
- messages=messages,
35
- stream=True,
36
- # max_tokens, temperature, and top_p are removed from here
37
- ):
38
- if chunk.choices[0].delta.content is not None:
39
- token = chunk.choices[0].delta.content
40
- response_text += token
41
- yield response_text
42
- except Exception as e:
43
- yield f"An error occurred: {e}"
44
-
45
- # header_image_path has been removed.
46
- kofi_script = """
47
- <script src='https://storage.ko-fi.com/cdn/scripts/overlay-widget.js'></script>
48
- <script>
49
- kofiWidgetOverlay.draw('sonnydesorbo', {
50
- 'type': 'floating-chat',
51
- 'floating-chat.donateButton.text': 'Support me',
52
- 'floating-chat.donateButton.background-color': '#00b9fe',
53
- 'floating-chat.donateButton.text-color': '#fff'
54
- });
55
- </script>
56
- """
57
- kofi_button_html = """
58
- <div style="text-align: center; padding: 20px;">
59
- <a href='https://ko-fi.com/Z8Z51E5TIG' target='_blank'>
60
- <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' />
61
- </a>
62
- </div>
63
- """
64
- donation_solicitation_html = """
65
- <div style="text-align: center; font-size: x-small; margin-bottom: 5px;">
66
- 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>
67
-
68
- </div>
69
- """
70
- custom_css = """
71
- @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap');
72
- body, .gradio-container {
73
- font-family: 'Orbitron', sans-serif !important;
74
- }
75
- .gr-button { font-family: 'Orbitron', sans-serif !important; }
76
- .gr-input { font-family: 'Orbitron', sans-serif !important; }
77
- .gr-label { font-family: 'Orbitron', sans-serif !important; }
78
- .gr-chatbot .message { font-family: 'Orbitron', sans-serif !important; }
79
- """
80
-
81
- with gr.Blocks(theme="dark", head=kofi_script, css=custom_css) as demo:
82
- # gr.Image component has been removed.
83
-
84
- gr.ChatInterface(
85
- fn=respond,
86
- chatbot=gr.Chatbot(
87
- height=800,
88
- label="Xortron - Criminal Computing"
89
- )
90
- )
91
-
92
- gr.HTML(donation_solicitation_html)
93
- gr.HTML(kofi_button_html)
94
-
95
- if __name__ == "__main__":
96
- try:
97
- demo.launch(show_api=False, share=True)
98
- except NameError as ne:
99
- print(f"Gradio demo could not be launched. 'client' might not have been initialized: {ne}")
100
- except RuntimeError as re:
101
- print(f"Gradio demo could not be launched due to an error during client initialization: {re}")
102
- except Exception as e:
103
- print(f"An unexpected error occurred when trying to launch Gradio demo: {e}")