File size: 1,348 Bytes
a5660ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f36fe6f
0763b5e
a5660ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f36fe6f
a5660ec
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import gradio as gr
from models import stream_generate_response

# Header Link
ANYCODER_LINK = "<a href='https://huggingface.co/spaces/akhaliq/anycoder' target='_blank'>Built with anycoder</a>"

with gr.Blocks(title="KAT-Dev Chat", theme=gr.themes.Soft()) as demo:
    gr.HTML(
        f"""
        <div style="text-align: center; max-width: 800px; margin: 0 auto;">
            <h1>💬 KAT-Dev LLM Chat</h1>
            <p>Powered by Kwaipilot/KAT-Dev, a large language model. This application uses Hugging Face ZeroGPU for highly efficient inference.</p>
            {ANYCODER_LINK}
        </div>
        """
    )

    # ChatInterface handles the full conversational UI, streaming, and history management
    chat_interface = gr.ChatInterface(
        fn=stream_generate_response,
        title="",  # Title moved to HTML block
        chatbot=gr.Chatbot(
            height=500,
            show_copy_button=True,
            layout="bubble"
        ),
        textbox=gr.Textbox(
            placeholder="Ask the KAT model anything...", 
            container=False, 
            scale=7
        ),
        # Disable the default submit button text since we have an icon
        submit_btn=True,
        stop_btn=True,
        
        # Concurrency limit handled by @spaces.GPU
        concurrency_limit=10,
    )

demo.queue()
demo.launch()