File size: 1,409 Bytes
9b171dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
42
from constants import *
from hf_client import get_inference_client, tavily_client
from tavily_search import enhance_query_with_search
from utils import *
from search_replace import *
from web_scraper import *
from deploy import *

with gr.Blocks(
    theme=gr.themes.Base(
        primary_hue="blue",
        secondary_hue="gray",
        neutral_hue="gray",
        font=gr.themes.GoogleFont("Inter"),
        font_mono=gr.themes.GoogleFont("JetBrains Mono"),
        text_size=gr.themes.sizes.text_md,
        spacing_size=gr.themes.sizes.spacing_md,
        radius_size=gr.themes.sizes.radius_md
    ),
    title="AnyCoder - AI Code Generator"
) as demo:
    history=gr.State([])
    setting=gr.State({"system": HTML_SYSTEM_PROMPT})
    current_model=gr.State(AVAILABLE_MODELS[9])
    open_panel=gr.State(None)
    last_login_state=gr.State(None)

    # Sidebar definition, inputs, buttons...
    # (exactly as in the monolith)

    def generation_code(query, image, file, website_url, _setting, _history, _current_model, enable_search, language, provider):
        ...
        # (exactly the full function from the monolith)

    # Event handlers: load_project_btn.click, btn.click -> generation_code, clear_btn.click, etc.

    # Deploy button hookup

if __name__=="__main__":
    demo.queue(api_open=False, default_concurrency_limit=20)\
        .launch(show_api=False, ssr_mode=True, mcp_server=False)