Update app.py
Browse files
app.py
CHANGED
@@ -2,10 +2,8 @@ import gradio as gr
|
|
2 |
import requests
|
3 |
from huggingface_hub import InferenceClient
|
4 |
|
5 |
-
# HuggingFace modeli
|
6 |
client = InferenceClient("MiniMaxAI/MiniMax-M1-80k")
|
7 |
|
8 |
-
# Sistem mesajı GitHub'dan alınacak
|
9 |
GITHUB_RAW_URL = "https://raw.githubusercontent.com/ALPERALL/AlpDroid/main/prompt.txt"
|
10 |
|
11 |
def fetch_system_message():
|
@@ -16,7 +14,6 @@ def fetch_system_message():
|
|
16 |
except requests.exceptions.RequestException as e:
|
17 |
return f"Error fetching system message: {str(e)}"
|
18 |
|
19 |
-
# Mesaja cevap oluşturan fonksiyon
|
20 |
def respond(message, history):
|
21 |
max_tokens = 512
|
22 |
temperature = 0.7
|
@@ -48,7 +45,6 @@ def respond(message, history):
|
|
48 |
response += token
|
49 |
yield response
|
50 |
|
51 |
-
# Tema (mor renkli koyu mod)
|
52 |
theme = gr.themes.Soft(
|
53 |
primary_hue="purple",
|
54 |
secondary_hue="purple",
|
@@ -73,8 +69,25 @@ theme = gr.themes.Soft(
|
|
73 |
code_background_fill_dark="#0d1117",
|
74 |
)
|
75 |
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
gr.Markdown("## 🤖 AlpDroid\nAlper A. tarafından yapıldı, yasadışı kullanımda sorumluluk kullanıcıya aittir.")
|
79 |
|
80 |
chatbot = gr.Chatbot(label="AlpDroid")
|
@@ -84,9 +97,10 @@ with gr.Blocks(theme=theme) as demo:
|
|
84 |
txt = gr.Textbox(
|
85 |
show_label=False,
|
86 |
placeholder="Sohbet etmek için dokun...",
|
87 |
-
scale=4
|
|
|
88 |
)
|
89 |
-
submit = gr.Button("⬆️", scale=1
|
90 |
|
91 |
with gr.Row():
|
92 |
file_upload = gr.File(label="Dosya Yükle", file_types=["image", "video", ".pdf", ".txt"], file_count="single")
|
@@ -101,11 +115,10 @@ with gr.Blocks(theme=theme) as demo:
|
|
101 |
for token in response_gen:
|
102 |
response = token
|
103 |
history.append((message, response))
|
104 |
-
return history, "", None # textbox
|
105 |
|
106 |
submit.click(fn=user_submit, inputs=[txt, file_upload, state], outputs=[chatbot, txt, file_upload])
|
107 |
txt.submit(fn=user_submit, inputs=[txt, file_upload, state], outputs=[chatbot, txt, file_upload])
|
108 |
|
109 |
-
# Uygulama başlatılıyor
|
110 |
if __name__ == "__main__":
|
111 |
demo.launch(share=True)
|
|
|
2 |
import requests
|
3 |
from huggingface_hub import InferenceClient
|
4 |
|
|
|
5 |
client = InferenceClient("MiniMaxAI/MiniMax-M1-80k")
|
6 |
|
|
|
7 |
GITHUB_RAW_URL = "https://raw.githubusercontent.com/ALPERALL/AlpDroid/main/prompt.txt"
|
8 |
|
9 |
def fetch_system_message():
|
|
|
14 |
except requests.exceptions.RequestException as e:
|
15 |
return f"Error fetching system message: {str(e)}"
|
16 |
|
|
|
17 |
def respond(message, history):
|
18 |
max_tokens = 512
|
19 |
temperature = 0.7
|
|
|
45 |
response += token
|
46 |
yield response
|
47 |
|
|
|
48 |
theme = gr.themes.Soft(
|
49 |
primary_hue="purple",
|
50 |
secondary_hue="purple",
|
|
|
69 |
code_background_fill_dark="#0d1117",
|
70 |
)
|
71 |
|
72 |
+
css = """
|
73 |
+
#input-textbox textarea {
|
74 |
+
height: 50px !important;
|
75 |
+
border-radius: 10px 0 0 10px !important;
|
76 |
+
padding: 10px !important;
|
77 |
+
font-size: 16px !important;
|
78 |
+
resize: none !important;
|
79 |
+
}
|
80 |
+
|
81 |
+
#submit-button {
|
82 |
+
width: 50px !important;
|
83 |
+
height: 50px !important;
|
84 |
+
border-radius: 0 10px 10px 0 !important;
|
85 |
+
font-size: 24px !important;
|
86 |
+
padding: 0 !important;
|
87 |
+
}
|
88 |
+
"""
|
89 |
+
|
90 |
+
with gr.Blocks(theme=theme, css=css) as demo:
|
91 |
gr.Markdown("## 🤖 AlpDroid\nAlper A. tarafından yapıldı, yasadışı kullanımda sorumluluk kullanıcıya aittir.")
|
92 |
|
93 |
chatbot = gr.Chatbot(label="AlpDroid")
|
|
|
97 |
txt = gr.Textbox(
|
98 |
show_label=False,
|
99 |
placeholder="Sohbet etmek için dokun...",
|
100 |
+
scale=4,
|
101 |
+
elem_id="input-textbox"
|
102 |
)
|
103 |
+
submit = gr.Button("⬆️", scale=1, elem_id="submit-button")
|
104 |
|
105 |
with gr.Row():
|
106 |
file_upload = gr.File(label="Dosya Yükle", file_types=["image", "video", ".pdf", ".txt"], file_count="single")
|
|
|
115 |
for token in response_gen:
|
116 |
response = token
|
117 |
history.append((message, response))
|
118 |
+
return history, "", None # textbox ve dosya input temizle
|
119 |
|
120 |
submit.click(fn=user_submit, inputs=[txt, file_upload, state], outputs=[chatbot, txt, file_upload])
|
121 |
txt.submit(fn=user_submit, inputs=[txt, file_upload, state], outputs=[chatbot, txt, file_upload])
|
122 |
|
|
|
123 |
if __name__ == "__main__":
|
124 |
demo.launch(share=True)
|