Update app.py
Browse files
app.py
CHANGED
|
@@ -1,25 +1,31 @@
|
|
| 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
|
| 11 |
-
|
| 12 |
-
|
|
|
|
| 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 |
-
|
| 18 |
-
|
|
|
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
with gr.Blocks(
|
| 22 |
gr.Markdown("<h1 style='text-align: center; color: #3b82f6;'>โก CODEK ULTIMATE AGENT โก</h1>")
|
| 23 |
-
|
| 24 |
|
| 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 |
+
|
| 10 |
+
# ุชุญููู ุงูุชุงุฑูุฎ ููุดูู ุงููู ุจูููู
ู ุงูู
ูุฏูู
|
| 11 |
messages = [{"role": "system", "content": system_message}]
|
| 12 |
+
for msg in history:
|
| 13 |
+
messages.append({"role": "user", "content": msg['human']})
|
| 14 |
+
messages.append({"role": "assistant", "content": msg['ai']})
|
| 15 |
+
|
| 16 |
messages.append({"role": "user", "content": message})
|
| 17 |
+
|
| 18 |
response = ""
|
| 19 |
for message_chunk in client.chat_completion(messages, max_tokens=4000, stream=True):
|
| 20 |
token = message_chunk.choices[0].delta.content
|
| 21 |
+
if token:
|
| 22 |
+
response += token
|
| 23 |
+
yield response
|
| 24 |
|
| 25 |
+
# ุจูุงุก ุงููุงุฌูุฉ - ุชู
ููู ุงูู theme ููููู ู
ุชูุงูู ู
ุน Gradio 6.0
|
| 26 |
+
with gr.Blocks() as demo:
|
| 27 |
gr.Markdown("<h1 style='text-align: center; color: #3b82f6;'>โก CODEK ULTIMATE AGENT โก</h1>")
|
| 28 |
+
gr.ChatInterface(fn=respond)
|
| 29 |
|
| 30 |
+
# ููุง ุญุทููุง ุงูุซูู
ุฌูุง ุงูู launch ุนุดุงู ุงูู Error ูุฎุชูู
|
| 31 |
+
demo.launch(theme=gr.themes.Default(primary_hue="blue", secondary_hue="purple"))
|