Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
+
|
| 4 |
+
# استدعاء أقوى موديل كود مجاني
|
| 5 |
+
client = InferenceClient("Qwen/Qwen2.5-Coder-32B-Instruct")
|
| 6 |
+
|
| 7 |
+
def respond(message, history):
|
| 8 |
+
system_message = "You are CODEK, the world's most powerful AI Agent. You build full projects (+2000 lines), use professional Clean Code, and follow Dark Mode aesthetics."
|
| 9 |
+
messages = [{"role": "system", "content": system_message}]
|
| 10 |
+
for val in history:
|
| 11 |
+
if val[0]: messages.append({"role": "user", "content": val[0]})
|
| 12 |
+
if val[1]: messages.append({"role": "assistant", "content": val[1]})
|
| 13 |
+
messages.append({"role": "user", "content": message})
|
| 14 |
+
response = ""
|
| 15 |
+
for message_chunk in client.chat_completion(messages, max_tokens=4000, stream=True):
|
| 16 |
+
token = message_chunk.choices[0].delta.content
|
| 17 |
+
response += token
|
| 18 |
+
yield response
|
| 19 |
+
|
| 20 |
+
# ستايل "كودك" النيون
|
| 21 |
+
with gr.Blocks(theme=gr.themes.Default(primary_hue="blue", secondary_hue="purple")) as demo:
|
| 22 |
+
gr.Markdown("<h1 style='text-align: center; color: #3b82f6;'>⚡ CODEK ULTIMATE AGENT ⚡</h1>")
|
| 23 |
+
chat = gr.ChatInterface(fn=respond, type="messages")
|
| 24 |
+
|
| 25 |
+
demo.launch()
|