remove media generation and search
Browse filesFiles changed (3)
- README.md-7
- app.py+29-731
- requirements.txt-1
43 unmodified lines4445464748495046 unmodified lines97989910010110210310410510610721 unmodified lines12913013113213313413543 unmodified lines3. Set up environment variables:```bashexport HF_TOKEN="your_huggingface_token"export TAVILY_API_KEY="your_tavily_api_key" # Optional, for web search featureexport DASHSCOPE_API_KEY="your_dashscope_api_key" # Required for Qwen3-30B models via DashScopeexport POE_API_KEY="your_poe_api_key" # Required for GPT-5, Grok-4, and Grok-Code-Fast-1 via Poeexport GEMINI_API_KEY="your_gemini_api_key" # Required for Gemini models46 unmodified lines- **File Upload**: Provide a reference file (PDF, TXT, MD, CSV, DOCX, or image) for code generation or text extraction (OCR for images)- **Website URL**: Enter a URL to extract and redesign the website (HTML and content are analyzed and modernized)## Web Search Feature- Enable the "Web search" toggle to use Tavily for real-time information (requires TAVILY_API_KEY)- Uses advanced search depth for best results## Code Generation & Modification- Generates code in HTML, Python, JS, and more (selectable via dropdown)21 unmodified lines## Environment Variables- `HF_TOKEN`: Your Hugging Face API token (required)- `TAVILY_API_KEY`: Your Tavily API key (optional, for web search)- `GEMINI_API_KEY`: Your Google Gemini API key (required to use Gemini models)- `MOONSHOT_API_KEY`: Your Moonshot AI API key (required to use Kimi models)43 unmodified lines44454647484946 unmodified lines9697989910010121 unmodified lines12312412512612712843 unmodified lines3. Set up environment variables:```bashexport HF_TOKEN="your_huggingface_token"export DASHSCOPE_API_KEY="your_dashscope_api_key" # Required for Qwen3-30B models via DashScopeexport POE_API_KEY="your_poe_api_key" # Required for GPT-5, Grok-4, and Grok-Code-Fast-1 via Poeexport GEMINI_API_KEY="your_gemini_api_key" # Required for Gemini models46 unmodified lines- **File Upload**: Provide a reference file (PDF, TXT, MD, CSV, DOCX, or image) for code generation or text extraction (OCR for images)- **Website URL**: Enter a URL to extract and redesign the website (HTML and content are analyzed and modernized)## Code Generation & Modification- Generates code in HTML, Python, JS, and more (selectable via dropdown)21 unmodified lines## Environment Variables- `HF_TOKEN`: Your Hugging Face API token (required)- `GEMINI_API_KEY`: Your Google Gemini API key (required to use Gemini models)- `MOONSHOT_API_KEY`: Your Moonshot AI API key (required to use Kimi models)
22 unmodified lines232425262728291119 unmodified lines114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214223 unmodified lines14381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153913 unmodified lines155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158934 unmodified lines16241625162616271628162916301631163216331634163516361637163816391640164127 unmodified lines1669167016711672167316741675167616771678167916801681168216831684168516861687168816891690631 unmodified lines232223232324232523262327232823292330233123322333233423351141 unmodified lines3477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935901400 unmodified lines4991499249934994499549964997503 unmodified lines5501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555713 unmodified lines6269627062716272627362746275174 unmodified lines6450645164526453645464556456645764586459646064616462646364646465646625 unmodified lines6492649364946495649664976498649940 unmodified lines65406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658434 unmodified lines66196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866492 unmodified lines6652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688231 unmodified lines6920692169226923692469256926172 unmodified lines709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307 unmodified lines713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871691092 unmodified lines826282638264826582668267826882698270827182728273827482758276827782788279828051 unmodified lines83328333833483358336833783388339834083418342834383448345834683478348834983508351835216 unmodified lines836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854913 unmodified lines856385648565856685678568856985708571526 unmodified lines909890999100910191029103910434 unmodified lines913991409141914291439144914522 unmodified linesimport gradio as grfrom huggingface_hub import InferenceClientfrom tavily import TavilyClientfrom huggingface_hub import HfApiimport tempfilefrom openai import OpenAI1119 unmodified linesexcept Exception:return Falsedef llm_place_media(html_content: str, media_html_tag: str, media_kind: str = "image") -> str:"""Ask a lightweight model to produce search/replace blocks that insert media_html_tag in the best spot.The model must return ONLY our block format using SEARCH_START/DIVIDER/REPLACE_END."""try:client = get_inference_client("Qwen/Qwen3-Coder-480B-A35B-Instruct", "auto")system_prompt = ("You are a code editor. Insert the provided media tag into the given HTML in the most semantically appropriate place.\n""For video elements: prefer replacing placeholder images or inserting in hero sections with proper container divs.\n""For image elements: prefer replacing placeholder images or inserting near related content.\n""CRITICAL: Ensure proper HTML structure - videos should be wrapped in appropriate containers.\n""Return ONLY search/replace blocks using the exact markers: <<<<<<< SEARCH, =======, >>>>>>> REPLACE.\n""Do NOT include any commentary. Ensure the SEARCH block matches exact lines from the input.\n""When inserting videos, ensure they are properly contained within semantic HTML elements.\n")# Truncate very long media tags for LLM prompt only to prevent token limitstruncated_media_tag_for_prompt = media_html_tagif len(media_html_tag) > 2000:# For very long data URIs, show structure but truncate the data for LLM promptif 'data:video/mp4;base64,' in media_html_tag:start_idx = media_html_tag.find('data:video/mp4;base64,')end_idx = media_html_tag.find('"', start_idx)if start_idx != -1 and end_idx != -1:truncated_media_tag_for_prompt = (media_html_tag[:start_idx] +'data:video/mp4;base64,[TRUNCATED_BASE64_DATA]' +media_html_tag[end_idx:])user_payload = ("HTML Document:\n" + html_content + "\n\n" +f"Media ({media_kind}):\n" + truncated_media_tag_for_prompt + "\n\n" +"Produce search/replace blocks now.")messages = [{"role": "system", "content": system_prompt},{"role": "user", "content": user_payload},]completion = client.chat.completions.create(model="Qwen/Qwen3-Coder-480B-A35B-Instruct",messages=messages,max_tokens=2000,temperature=0.2,)text = (completion.choices[0].message.content or "") if completion and completion.choices else ""# Replace any truncated placeholders with the original full media HTMLif '[TRUNCATED_BASE64_DATA]' in text and 'data:video/mp4;base64,[TRUNCATED_BASE64_DATA]' in truncated_media_tag_for_prompt:# Extract the original base64 data from the full media tagoriginal_start = media_html_tag.find('data:video/mp4;base64,')original_end = media_html_tag.find('"', original_start)if original_start != -1 and original_end != -1:original_data_uri = media_html_tag[original_start:original_end]text = text.replace('data:video/mp4;base64,[TRUNCATED_BASE64_DATA]', original_data_uri)return text.strip()except Exception as e:print(f"[LLMPlaceMedia] Fallback due to error: {e}")return ""# Stricter prompt for GLM-4.5V to ensure a complete, runnable HTML document with no escaped charactersGLM45V_HTML_SYSTEM_PROMPT = """You are an expert front-end developer.223 unmodified linesIMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""SVELTE_SYSTEM_PROMPT_WITH_SEARCH = """You are an expert Svelte developer. You have access to real-time web search.File selection policy (dynamic, model-decided):- Generate ONLY the files actually needed for the user's request.- MUST include src/App.svelte (entry component) and src/main.ts (entry point).- Usually include src/app.css for global styles.- Add additional files when needed, e.g. src/lib/*.svelte, src/components/*.svelte, src/stores/*.ts, static/* assets, etc.- Other base template files (package.json, vite.config.ts, tsconfig, svelte.config.js, src/vite-env.d.ts) are provided by the template and should NOT be generated unless explicitly requested by the user.CRITICAL: Always generate src/main.ts with correct Svelte 5 syntax:```typescriptimport './app.css'import App from './App.svelte'const app = new App({target: document.getElementById('app')!,})export default app```Do NOT use the old mount syntax: `import { mount } from 'svelte'` - this will cause build errors.Output format (CRITICAL):- Return ONLY a series of file sections, each starting with a filename line:=== src/App.svelte ===...file content...=== src/app.css ===...file content...(repeat for all files you decide to create)- Do NOT wrap files in Markdown code fences.Dependency policy:- If you import any third-party npm packages, include a package.json at the project root with a "dependencies" section listing them. Keep scripts and devDependencies compatible with the default Svelte + Vite template.Requirements:1. Create a modern, responsive Svelte application2. Prefer TypeScript where applicable3. Clean, professional UI and UX4. Mobile-first responsiveness5. Svelte best practices and modern CSS6. Error handling and loading states7. Accessibility best practices8. Use search to apply current best practices9. Keep component structure organized and minimalIMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""TRANSFORMERS_JS_SYSTEM_PROMPT_WITH_SEARCH = """You are an expert web developer creating a transformers.js application. You have access to real-time web search. When needed, use web search to find the latest information, best practices, or specific technologies for transformers.js.You will generate THREE separate files: index.html, index.js, and style.css.IMPORTANT: You MUST output ALL THREE files in the following format:```html<!-- index.html content here -->``````javascript// index.js content here``````css/* style.css content here */```Requirements:1. Create a modern, responsive web application using transformers.js2. Use the transformers.js library for AI/ML functionality3. Use web search to find current best practices and latest transformers.js features4. Create a clean, professional UI with good user experience5. Make the application fully responsive for mobile devices6. Use modern CSS practices and JavaScript ES6+ features7. Include proper error handling and loading states8. Follow accessibility best practicesLibrary import (required): Add the following snippet to index.html to import transformers.js:<script type="module">import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.3';</script>Device Options: By default, transformers.js runs on CPU (via WASM). For better performance, you can run models on GPU using WebGPU:- CPU (default): const pipe = await pipeline('task', 'model-name');- GPU (WebGPU): const pipe = await pipeline('task', 'model-name', { device: 'webgpu' });Consider providing users with a toggle option to choose between CPU and GPU execution based on their browser's WebGPU support.The index.html should contain the basic HTML structure and link to the CSS and JS files.The index.js should contain all the JavaScript logic including transformers.js integration.The style.css should contain all the styling for the application.Generate complete, working code files as shown above.IMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""# Gradio system prompts will be dynamically populated by update_gradio_system_prompts()GRADIO_SYSTEM_PROMPT = ""13 unmodified linesIMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""# System prompt with search capabilityHTML_SYSTEM_PROMPT_WITH_SEARCH = """You are an expert front-end developer. You have access to real-time web search.Output a COMPLETE, STANDALONE HTML document that renders directly in a browser. Requirements:- Include <!DOCTYPE html>, <html>, <head>, and <body> with proper nesting- Include all required <link> and <script> tags for any libraries you use- Do NOT escape characters (no \\n, \\t, or escaped quotes). Output raw HTML/JS/CSS.- If you use React or Tailwind, include correct CDN tags- Keep everything in ONE file; inline CSS/JS as neededUse web search when needed to find the latest best practices or correct CDN links.For website redesign tasks:- Use the provided original HTML code as the starting point for redesign- Preserve all original content, structure, and functionality- Keep the same semantic HTML structure but enhance the styling- Reuse all original images and their URLs from the HTML code- Use web search to find current design trends and best practices for the specific type of website- Create a modern, responsive design with improved typography and spacing- Use modern CSS frameworks and design patterns- Ensure accessibility and mobile responsiveness- Maintain the same navigation and user flow- Enhance the visual design while keeping the original layout structureIf an image is provided, analyze it and use the visual information to better understand the user's requirements.Always respond with code that can be executed or rendered directly.Generate complete, working HTML code that can be run immediately.IMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""# Multi-page static HTML project prompt (generic, production-style structure)MULTIPAGE_HTML_SYSTEM_PROMPT = """You are an expert front-end developer.34 unmodified linesIMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""# Multi-page with search augmentationMULTIPAGE_HTML_SYSTEM_PROMPT_WITH_SEARCH = """You are an expert front-end developer. You have access to real-time web search.Create a production-ready MULTI-PAGE website using ONLY HTML, CSS, and vanilla JavaScript. Do NOT use SPA frameworks.Follow the same file output format and project structure as specified:=== filename === blocks for each file (no Markdown fences)Use search results to apply current best practices in accessibility, semantics, responsive meta tags, and performance (preconnect, responsive images).IMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""# Dynamic multi-page (model decides files) promptsDYNAMIC_MULTIPAGE_HTML_SYSTEM_PROMPT = """You are an expert front-end developer.27 unmodified linesIMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""DYNAMIC_MULTIPAGE_HTML_SYSTEM_PROMPT_WITH_SEARCH = """You are an expert front-end developer. You have access to real-time web search.Create a production-ready website using ONLY HTML, CSS, and vanilla JavaScript. Do NOT use SPA frameworks.Follow the same output format and file selection policy as above (=== filename === blocks; model decides which files to create; ensure index.html unless explicitly not needed).Use search results to apply current best practices in accessibility, semantics, responsive meta tags, and performance (preconnect, responsive images).IMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""GENERIC_SYSTEM_PROMPT_WITH_SEARCH = """You are an expert {language} developer. You have access to real-time web search. When needed, use web search to find the latest information, best practices, or specific technologies for {language}.Write clean, idiomatic, and runnable {language} code for the user's request. If possible, include comments and best practices. Generate complete, working code that can be run immediately. If the user provides a file or other context, use it as a reference. If the code is for a script or app, make it as self-contained as possible.IMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""# Follow-up system prompt for modifying existing HTML filesFollowUpSystemPrompt = f"""You are an expert web developer modifying an existing project.631 unmodified linesMessages = List[Dict[str, str]]# Tavily Search ClientTAVILY_API_KEY = os.getenv('TAVILY_API_KEY')tavily_client = Noneif TAVILY_API_KEY:try:tavily_client = TavilyClient(api_key=TAVILY_API_KEY)except Exception as e:print(f"Failed to initialize Tavily client: {e}")tavily_client = Nonedef history_to_messages(history: History, system: str) -> Messages:messages = [{'role': 'system', 'content': system}]1141 unmodified linesexcept Exception as e:print(f"[TempCleanup] Error during cleanup: {str(e)}")def generate_image_with_hunyuan(prompt: str, image_index: int = 0, token: gr.OAuthToken | None = None) -> str:"""Generate image using Tencent HunyuanImage-2.1 via Hugging Face InferenceClient.Uses tencent/HunyuanImage-2.1 via HuggingFace InferenceClient with fal-ai provider.Returns an HTML <img> tag whose src is an uploaded temporary URL."""try:print(f"[Text2Image] Starting HunyuanImage generation with prompt: {prompt[:100]}...")# Check for HF_TOKENhf_token = os.getenv('HF_TOKEN')if not hf_token:print("[Text2Image] Missing HF_TOKEN")return "Error: HF_TOKEN environment variable is not set. Please set it to your Hugging Face API token."from huggingface_hub import InferenceClientfrom PIL import Imageimport io as _io# Create InferenceClient with fal-ai providerclient = InferenceClient(provider="fal-ai",api_key=hf_token,bill_to="huggingface",)print("[Text2Image] Making API request to HuggingFace InferenceClient...")# Generate image using HunyuanImage-2.1 modelimage = client.text_to_image(prompt,model="tencent/HunyuanImage-2.1",)print(f"[Text2Image] Successfully generated image with size: {image.size}")# Resize image to reduce size while maintaining qualitymax_size = 1024if image.width > max_size or image.height > max_size:image.thumbnail((max_size, max_size), Image.Resampling.LANCZOS)# Convert PIL Image to bytes for uploadbuffer = _io.BytesIO()# Save as JPEG with good qualityimage.convert('RGB').save(buffer, format='JPEG', quality=90, optimize=True)image_bytes = buffer.getvalue()# Upload and return HTML tagprint("[Text2Image] Uploading image to HF...")filename = f"generated_image_{image_index}.jpg"temp_url = upload_media_to_hf(image_bytes, filename, "image", token, use_temp=True)if temp_url.startswith("Error"):print(f"[Text2Image] Upload failed: {temp_url}")return temp_urlprint(f"[Text2Image] Successfully generated image: {temp_url}")return f"<img src=\"{temp_url}\" alt=\"{prompt}\" style=\"max-width: 100%; height: auto; border-radius: 8px; margin: 10px 0;\" loading=\"lazy\" />"except Exception as e:print(f"[Text2Image] Error generating image with HunyuanImage: {str(e)}")return f"Error generating image (text-to-image): {str(e)}"def generate_image_with_qwen(prompt: str, image_index: int = 0, token: gr.OAuthToken | None = None) -> str:"""Generate image using Qwen image model via Hugging Face InferenceClient and upload to HF for permanent URL"""try:# Check if HF_TOKEN is availableif not os.getenv('HF_TOKEN'):return "Error: HF_TOKEN environment variable is not set. Please set it to your Hugging Face API token."# Create InferenceClient for Qwen image generationclient = InferenceClient(provider="auto",api_key=os.getenv('HF_TOKEN'),bill_to="huggingface",)# Generate image using Qwen/Qwen-Image modelimage = client.text_to_image(prompt,model="Qwen/Qwen-Image",)# Resize image to reduce size while maintaining qualitymax_size = 1024 # Increased size since we're not using data URIsif image.width > max_size or image.height > max_size:image.thumbnail((max_size, max_size), Image.Resampling.LANCZOS)# Convert PIL Image to bytes for uploadimport iobuffer = io.BytesIO()# Save as JPEG with good quality since we're not embeddingimage.convert('RGB').save(buffer, format='JPEG', quality=90, optimize=True)image_bytes = buffer.getvalue()# Create temporary URL for preview (will be uploaded to HF during deploy)filename = f"generated_image_{image_index}.jpg"temp_url = upload_media_to_hf(image_bytes, filename, "image", token, use_temp=True)# Check if creation was successfulif temp_url.startswith("Error"):return temp_url# Return HTML img tag with temporary URLreturn f'<img src="{temp_url}" alt="{prompt}" style="max-width: 100%; height: auto; border-radius: 8px; margin: 10px 0;" loading="lazy" />'except Exception as e:print(f"Image generation error: {str(e)}")return f"Error generating image: {str(e)}"def generate_image_to_image(input_image_data, prompt: str, token: gr.OAuthToken | None = None) -> str:"""Generate an image using image-to-image via OpenRouter.1400 unmodified linesprint("[Video2Video] No <body> tag; appending video via replacement block")return f"{SEARCH_START}\n\n{DIVIDER}\n{video_html}\n{REPLACE_END}"def apply_generated_media_to_html(html_content: str, user_prompt: str, enable_text_to_image: bool, enable_image_to_image: bool, input_image_data, image_to_image_prompt: str | None = None, text_to_image_prompt: str | None = None, enable_image_to_video: bool = False, image_to_video_prompt: str | None = None, session_id: str | None = None, enable_text_to_video: bool = False, text_to_video_prompt: str | None = None, enable_video_to_video: bool = False, video_to_video_prompt: str | None = None, input_video_data = None, enable_text_to_music: bool = False, text_to_music_prompt: str | None = None, enable_image_video_to_animation: bool = False, animation_mode: str = "wan2.2-animate-move", animation_quality: str = "wan-pro", animation_video_data = None, token: gr.OAuthToken | None = None) -> str:"""Apply text/image/video/music replacements to HTML content.- Works with single-document HTML strings503 unmodified lines# Updated for faster Tavily search and closer prompt usage# Uses 'advanced' search_depth and auto_parameters=True for speed and relevancedef perform_web_search(query: str, max_results: int = 5, include_domains=None, exclude_domains=None) -> str:"""Perform web search using Tavily with default parameters"""if not tavily_client:return "Web search is not available. Please set the TAVILY_API_KEY environment variable."try:# Use Tavily defaults with advanced search depth for better resultssearch_params = {"search_depth": "advanced","max_results": min(max(1, max_results), 20)}if include_domains is not None:search_params["include_domains"] = include_domainsif exclude_domains is not None:search_params["exclude_domains"] = exclude_domainsresponse = tavily_client.search(query, **search_params)search_results = []for result in response.get('results', []):title = result.get('title', 'No title')url = result.get('url', 'No URL')content = result.get('content', 'No content')search_results.append(f"Title: {title}\nURL: {url}\nContent: {content}\n")if search_results:return "Web Search Results:\n\n" + "\n---\n".join(search_results)else:return "No search results found."except Exception as e:return f"Search error: {str(e)}"def enhance_query_with_search(query: str, enable_search: bool) -> str:"""Enhance the query with web search results if search is enabled"""if not enable_search or not tavily_client:return query# Perform search to get relevant informationsearch_results = perform_web_search(query)# Combine original query with search resultsenhanced_query = f"""Original Query: {query}{search_results}Please use the search results above to help create the requested application with the most up-to-date information and best practices."""return enhanced_querydef send_to_sandbox(code):"""Render HTML in a sandboxed iframe. Assumes full HTML is provided by prompts."""713 unmodified lines}def generation_code(query: str | None, vlm_image: Optional[gr.Image], gen_image: Optional[gr.Image], file: str | None, website_url: str | None, _setting: Dict[str, str], _history: Optional[History], _current_model: Dict, enable_search: bool = False, language: str = "html", provider: str = "auto", enable_image_generation: bool = False, enable_image_to_image: bool = False, image_to_image_prompt: str | None = None, text_to_image_prompt: str | None = None, enable_image_to_video: bool = False, image_to_video_prompt: str | None = None, enable_text_to_video: bool = False, text_to_video_prompt: str | None = None, enable_video_to_video: bool = False, video_to_video_prompt: str | None = None, input_video_data = None, enable_text_to_music: bool = False, text_to_music_prompt: str | None = None, enable_image_video_to_animation: bool = False, animation_mode: str = "wan2.2-animate-move", animation_quality: str = "wan-pro", animation_video_data = None, profile: gr.OAuthProfile | None = None, token: gr.OAuthToken | None = None):# Check authentication firstis_authenticated, auth_message = check_authentication(profile, token)if not is_authenticated:174 unmodified lines# Use language-specific promptif language == "html":# Dynamic file selection always enabledsystem_prompt = DYNAMIC_MULTIPAGE_HTML_SYSTEM_PROMPT_WITH_SEARCH if enable_search else DYNAMIC_MULTIPAGE_HTML_SYSTEM_PROMPTelif language == "transformers.js":system_prompt = TRANSFORMERS_JS_SYSTEM_PROMPT_WITH_SEARCH if enable_search else TRANSFORMERS_JS_SYSTEM_PROMPTelif language == "svelte":system_prompt = SVELTE_SYSTEM_PROMPT_WITH_SEARCH if enable_search else SVELTE_SYSTEM_PROMPTelif language == "gradio":system_prompt = GRADIO_SYSTEM_PROMPT_WITH_SEARCH if enable_search else GRADIO_SYSTEM_PROMPTelif language == "json":system_prompt = JSON_SYSTEM_PROMPT_WITH_SEARCH if enable_search else JSON_SYSTEM_PROMPTelse:system_prompt = GENERIC_SYSTEM_PROMPT_WITH_SEARCH.format(language=language) if enable_search else GENERIC_SYSTEM_PROMPT.format(language=language)messages = history_to_messages(_history, system_prompt)25 unmodified linesThis will help me create a better design for you."""query = f"{query}\n\n[Error extracting website: {website_text}]{fallback_guidance}"# Enhance query with search if enabledenhanced_query = enhance_query_with_search(query, enable_search)# Check if this is GLM-4.5 model and handle with simple HuggingFace InferenceClientif _current_model["id"] == "zai-org/GLM-4.5":40 unmodified linesclean_code = remove_code_block(content)# Apply media generation (images/video/music)print("[Generate] Applying post-generation media to GLM-4.5 HTML output")final_content = apply_generated_media_to_html(clean_code,query,enable_text_to_image=enable_image_generation,enable_image_to_image=enable_image_to_image,input_image_data=gen_image,image_to_image_prompt=image_to_image_prompt,enable_image_to_video=enable_image_to_video,image_to_video_prompt=image_to_video_prompt,session_id=session_id,enable_text_to_video=enable_text_to_video,text_to_video_prompt=text_to_video_prompt,enable_video_to_video=enable_video_to_video,video_to_video_prompt=video_to_video_prompt,input_video_data=input_video_data,enable_text_to_music=enable_text_to_music,text_to_music_prompt=text_to_music_prompt,enable_image_video_to_animation=enable_image_video_to_animation,animation_mode=animation_mode,animation_quality=animation_quality,animation_video_data=animation_video_data,token=None,)_history.append([query, final_content])if language == "transformers.js":files = parse_transformers_js_output(clean_code)if files['index.html'] and files['index.js'] and files['style.css']:# Apply image generation if enabledif enable_image_generation:# Create search/replace blocks for image replacement based on images found in codeimage_replacement_blocks = create_image_replacement_blocks(files['index.html'], query)if image_replacement_blocks:# Apply the image replacements using existing search/replace logicfiles['index.html'] = apply_search_replace_changes(files['index.html'], image_replacement_blocks)formatted_output = format_transformers_js_output(files)yield {code_output: formatted_output,34 unmodified linesmodified_content = apply_search_replace_changes(last_content, clean_code)clean_content = remove_code_block(modified_content)# Apply media generation (images/video/music)print("[Generate] Applying post-generation media to modified HTML content")clean_content = apply_generated_media_to_html(clean_content,query,enable_text_to_image=enable_image_generation,enable_image_to_image=enable_image_to_image,input_image_data=gen_image,image_to_image_prompt=image_to_image_prompt,enable_image_to_video=enable_image_to_video,image_to_video_prompt=image_to_video_prompt,session_id=session_id,enable_text_to_video=enable_text_to_video,text_to_video_prompt=text_to_video_prompt,enable_video_to_video=enable_video_to_video,video_to_video_prompt=video_to_video_prompt,input_video_data=input_video_data,enable_text_to_music=enable_text_to_music,text_to_music_prompt=text_to_music_prompt,enable_image_video_to_animation=enable_image_video_to_animation,animation_mode=animation_mode,animation_quality=animation_quality,animation_video_data=animation_video_data,token=None,)yield {code_output: clean_content,2 unmodified lineshistory_output: history_to_chatbot_messages(_history),}else:# Apply media generation (images/video/music)# Only apply media generation to static HTML apps, not Svelte/React/other frameworksif language == "html":print("[Generate] Applying post-generation media to static HTML content")final_content = apply_generated_media_to_html(clean_code,query,enable_text_to_image=enable_image_generation,enable_image_to_image=enable_image_to_image,input_image_data=gen_image,image_to_image_prompt=image_to_image_prompt,text_to_image_prompt=text_to_image_prompt,enable_image_to_video=enable_image_to_video,image_to_video_prompt=image_to_video_prompt,session_id=session_id,enable_text_to_video=enable_text_to_video,text_to_video_prompt=text_to_video_prompt,enable_video_to_video=enable_video_to_video,video_to_video_prompt=video_to_video_prompt,input_video_data=input_video_data,enable_text_to_music=enable_text_to_music,text_to_music_prompt=text_to_music_prompt,enable_image_video_to_animation=enable_image_video_to_animation,animation_mode=animation_mode,animation_quality=animation_quality,animation_video_data=animation_video_data,token=None,)else:print(f"[Generate] Skipping media generation for {language} apps (only supported for static HTML)")final_content = clean_codepreview_val = Noneif language == "html":231 unmodified lineselse:# Append content, filtering out placeholder thinking linescontent += strip_placeholder_thinking(chunk_content)search_status = " (with web search)" if enable_search and tavily_client else ""# Handle transformers.js output differentlyif language == "transformers.js":172 unmodified linesmodified_content = apply_search_replace_changes(last_content, final_code)clean_content = remove_code_block(modified_content)# Apply media generation (images/video/music)print("[Generate] Applying post-generation media to follow-up HTML content")clean_content = apply_generated_media_to_html(clean_content,query,enable_text_to_image=enable_image_generation,enable_image_to_image=enable_image_to_image,input_image_data=gen_image,image_to_image_prompt=image_to_image_prompt,enable_image_to_video=enable_image_to_video,image_to_video_prompt=image_to_video_prompt,session_id=session_id,text_to_image_prompt=text_to_image_prompt,enable_text_to_video=enable_text_to_video,text_to_video_prompt=text_to_video_prompt,enable_video_to_video=enable_video_to_video,video_to_video_prompt=video_to_video_prompt,input_video_data=input_video_data,enable_text_to_music=enable_text_to_music,text_to_music_prompt=text_to_music_prompt,enable_image_video_to_animation=enable_image_video_to_animation,animation_mode=animation_mode,animation_quality=animation_quality,animation_video_data=animation_video_data,token=None,)# Update history with the cleaned content_history.append([query, clean_content])7 unmodified lines# Regular generation - use the content as isfinal_content = remove_code_block(content)# Apply media generation (images/video/music)print("[Generate] Applying post-generation media to final HTML content")final_content = apply_generated_media_to_html(final_content,query,enable_text_to_image=enable_image_generation,enable_image_to_image=enable_image_to_image,input_image_data=gen_image,image_to_image_prompt=image_to_image_prompt,text_to_image_prompt=text_to_image_prompt,enable_image_to_video=enable_image_to_video,image_to_video_prompt=image_to_video_prompt,session_id=session_id,enable_text_to_video=enable_text_to_video,text_to_video_prompt=text_to_video_prompt,enable_video_to_video=enable_video_to_video,video_to_video_prompt=video_to_video_prompt,input_video_data=input_video_data,enable_text_to_music=enable_text_to_music,text_to_music_prompt=text_to_music_prompt,enable_image_video_to_animation=enable_image_video_to_animation,animation_mode=animation_mode,animation_quality=animation_quality,animation_video_data=animation_video_data,token=None,)_history.append([query, final_content])preview_val = None1092 unmodified linesvalue=("### Command Reference\n""- **Language**: 'use streamlit' | 'use gradio' | 'use html'\n""- **Web search**: 'enable web search' | 'disable web search'\n""- **Model**: 'model <name>' (exact match to items in the Model dropdown)\n""- **Website redesign**: include a URL in your message (e.g., 'https://example.com')\n""- **Text → Image**: 'generate images: <prompt>' or 'text to image: <prompt>'\n""- **Image → Image**: 'image to image: <prompt>' (attach an image)\n""- **Image → Video**: 'image to video: <prompt>' (attach an image)\n""- **Text → Video**: 'text to video: <prompt>' or 'generate video: <prompt>'\n""- **Files & media**: attach documents or images directly; the first image is used for generation, the first non-image is treated as a reference file\n""- **Multiple directives**: separate with commas. The first segment is the main build prompt.\n\n""Examples:\n""- anycoder coffee shop, text to video: coffee pouring into cup\n""- redesign https://example.com, use streamlit, enable web search\n""- dashboard ui, generate images: minimalist pastel hero"))51 unmodified lineslabel="UI design image",visible=False)# New hidden image input used for VLMs, image-to-image, and image-to-videogeneration_image_input = gr.Image(label="image for generation",visible=False)image_to_image_prompt = gr.Textbox(label="Image-to-Image Prompt",placeholder="Describe how to transform the uploaded image (e.g., 'Turn the cat into a tiger.')",lines=2,visible=False)with gr.Row():btn = gr.Button("Generate", variant="secondary", size="lg", scale=2, visible=True, interactive=False)clear_btn = gr.Button("Clear", variant="secondary", size="sm", scale=1, visible=True)# --- Move deploy/app name/sdk here, right before web search ---space_name_input = gr.Textbox(label="app name (e.g. my-cool-app)",placeholder="Enter your app name",16 unmodified linesdeploy_btn = gr.Button("🚀 Deploy App", variant="primary", visible=False)deploy_status = gr.Markdown(visible=False, label="Deploy status")# --- End move ---search_toggle = gr.Checkbox(label="🔍 Web search",value=False,visible=True)# Dynamic multipage is always enabled; no toggle in UI# Image generation togglesimage_generation_toggle = gr.Checkbox(label="🎨 Generate Images (text → image)",value=False,visible=True,info="Include generated images in your outputs using HunyuanImage-2.1")text_to_image_prompt = gr.Textbox(label="Text-to-Image Prompt",placeholder="Describe the image to generate (e.g., 'A minimalist dashboard hero illustration in pastel colors.')",lines=2,visible=False)image_to_image_toggle = gr.Checkbox(label="🖼️ Image to Image (uses input image)",value=False,visible=True,info="Transform your uploaded image using Nano Banana")image_to_video_toggle = gr.Checkbox(label="🎞️ Image to Video (uses input image)",value=False,visible=True,info="Generate a short video from your uploaded image using Lightricks LTX-Video")image_to_video_prompt = gr.Textbox(label="Image-to-Video Prompt",placeholder="Describe the motion (e.g., 'The cat starts to dance')",lines=2,visible=False)# Text-to-Videotext_to_video_toggle = gr.Checkbox(label="📹 Generate Video (text → video)",value=False,visible=True,info="Generate a short video directly from your prompt using Wan-AI/Wan2.2-TI2V-5B")text_to_video_prompt = gr.Textbox(label="Text-to-Video Prompt",placeholder="Describe the video to generate (e.g., 'A young man walking on the street')",lines=2,visible=False)# Video-to-Videovideo_to_video_toggle = gr.Checkbox(label="🎬 Video to Video (uses input video)",value=False,visible=True,info="Transform your uploaded video using Decart AI's Lucy Pro V2V")video_to_video_prompt = gr.Textbox(label="Video-to-Video Prompt",placeholder="Describe the transformation (e.g., 'Change their shirt to black and shiny leather')",lines=2,visible=False)video_input = gr.Video(label="Input video for transformation",visible=False)# Text-to-Musictext_to_music_toggle = gr.Checkbox(label="🎵 Generate Music (text → music)",value=False,visible=True,info="Compose short music from your prompt using ElevenLabs Music")text_to_music_prompt = gr.Textbox(label="Text-to-Music Prompt",placeholder="Describe the music to generate (e.g., 'Epic orchestral theme with soaring strings and powerful brass')",lines=2,visible=False)# Image+Video to Animationimage_video_to_animation_toggle = gr.Checkbox(label="🎭 Character Animation (uses input image + video)",value=False,visible=True,info="Animate characters using Wan2.2-Animate with reference image and template video")animation_mode_dropdown = gr.Dropdown(label="Animation Mode",choices=[("Move Mode (animate character with video motion)", "wan2.2-animate-move"),("Mix Mode (replace character in video)", "wan2.2-animate-mix")],value="wan2.2-animate-move",visible=False,info="Move: animate image character with video motion. Mix: replace video character with image character")animation_quality_dropdown = gr.Dropdown(label="Animation Quality",choices=[("Professional (25fps, 720p)", "wan-pro"),("Standard (15fps, 720p)", "wan-std")],value="wan-pro",visible=False,info="Higher quality takes more time to generate")animation_video_input = gr.Video(label="Template video for animation (upload a video to use as motion template or character replacement source)",visible=False)# LLM-guided media placement is now always on (no toggle in UI)def on_image_to_image_toggle(toggled):vis = bool(toggled)return gr.update(visible=vis), gr.update(visible=vis)def on_text_to_image_toggle(toggled):vis = bool(toggled)return gr.update(visible=vis)image_to_image_toggle.change(on_image_to_image_toggle,inputs=[image_to_image_toggle],outputs=[generation_image_input, image_to_image_prompt])def on_image_to_video_toggle(toggled):vis = bool(toggled)return gr.update(visible=vis), gr.update(visible=vis)image_to_video_toggle.change(on_image_to_video_toggle,inputs=[image_to_video_toggle],outputs=[generation_image_input, image_to_video_prompt])image_generation_toggle.change(on_text_to_image_toggle,inputs=[image_generation_toggle],outputs=[text_to_image_prompt])text_to_video_toggle.change(on_text_to_image_toggle,inputs=[text_to_video_toggle],outputs=[text_to_video_prompt])video_to_video_toggle.change(on_image_to_video_toggle,inputs=[video_to_video_toggle],outputs=[video_input, video_to_video_prompt])text_to_music_toggle.change(on_text_to_image_toggle,inputs=[text_to_music_toggle],outputs=[text_to_music_prompt])def on_image_video_to_animation_toggle(toggled):vis = bool(toggled)return (gr.update(visible=vis), # generation_image_inputgr.update(visible=vis), # animation_mode_dropdowngr.update(visible=vis), # animation_quality_dropdowngr.update(visible=vis), # animation_video_input)image_video_to_animation_toggle.change(on_image_video_to_animation_toggle,inputs=[image_video_to_animation_toggle],outputs=[generation_image_input, animation_mode_dropdown, animation_quality_dropdown, animation_video_input])model_dropdown = gr.Dropdown(choices=[model['name'] for model in AVAILABLE_MODELS],value=DEFAULT_MODEL_NAME,13 unmodified linesfn=lambda idx=i: gr.update(value=DEMO_LIST[idx]['description']),outputs=input)if not tavily_client:gr.Markdown("⚠️ Web search unavailable", visible=True)# Remove model display and web search available linedef on_model_change(model_name):for m in AVAILABLE_MODELS:if m['name'] == model_name:526 unmodified linesshow_progress="hidden",).then(generation_code,inputs=[input, image_input, generation_image_input, file_input, website_url_input, setting, history, current_model, search_toggle, language_dropdown, provider_state, image_generation_toggle, image_to_image_toggle, image_to_image_prompt, text_to_image_prompt, image_to_video_toggle, image_to_video_prompt, text_to_video_toggle, text_to_video_prompt, video_to_video_toggle, video_to_video_prompt, video_input, text_to_music_toggle, text_to_music_prompt, image_video_to_animation_toggle, animation_mode_dropdown, animation_quality_dropdown, animation_video_input],outputs=[code_output, history, sandbox, history_output]).then(end_generation_ui,34 unmodified linesshow_progress="hidden",).then(generation_code,inputs=[input, image_input, generation_image_input, file_input, website_url_input, setting, history, current_model, search_toggle, language_dropdown, provider_state, image_generation_toggle, image_to_image_toggle, image_to_image_prompt, text_to_image_prompt, image_to_video_toggle, image_to_video_prompt, text_to_video_toggle, text_to_video_prompt, video_to_video_toggle, video_to_video_prompt, video_input, text_to_music_toggle, text_to_music_prompt],outputs=[code_output, history, sandbox, history_output]).then(end_generation_ui,22 unmodified lines2324252627281119 unmodified lines114811491150115111521153223 unmodified lines13771378137913801381138213 unmodified lines13961397139813991400140134 unmodified lines14361437143814391440144127 unmodified lines1469147014711472147314741475631 unmodified lines2107210821092110211121121141 unmodified lines32543255325632573258325932601400 unmodified lines4661466246634664466546664667503 unmodified lines517151725173517451755176713 unmodified lines5890589158925893589458955896174 unmodified lines6071607260736074607560766077607860796080608160826083608460856086608725 unmodified lines6113611461156116611761186119612040 unmodified lines6161616261636164616561666167616861696170617161726173617434 unmodified lines62096210621162126213621462152 unmodified lines62186219622062216222622362246225231 unmodified lines6457645864596460646164626463172 unmodified lines66366637663866396640664166427 unmodified lines66506651665266536654665566561092 unmodified lines7749775077517752775377547755775677577758775977607761776251 unmodified lines7814781578167817781878197820782178227823782416 unmodified lines78417842784378447845784678477848784913 unmodified lines7863786478657866786778687869526 unmodified lines839683978398839984008401840234 unmodified lines843784388439844084418442844322 unmodified linesimport gradio as grfrom huggingface_hub import InferenceClientfrom huggingface_hub import HfApiimport tempfilefrom openai import OpenAI1119 unmodified linesexcept Exception:return False# Stricter prompt for GLM-4.5V to ensure a complete, runnable HTML document with no escaped charactersGLM45V_HTML_SYSTEM_PROMPT = """You are an expert front-end developer.223 unmodified linesIMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""# Gradio system prompts will be dynamically populated by update_gradio_system_prompts()GRADIO_SYSTEM_PROMPT = ""13 unmodified linesIMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""# Multi-page static HTML project prompt (generic, production-style structure)MULTIPAGE_HTML_SYSTEM_PROMPT = """You are an expert front-end developer.34 unmodified linesIMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""# Dynamic multi-page (model decides files) promptsDYNAMIC_MULTIPAGE_HTML_SYSTEM_PROMPT = """You are an expert front-end developer.27 unmodified linesIMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""# Follow-up system prompt for modifying existing HTML filesFollowUpSystemPrompt = f"""You are an expert web developer modifying an existing project.631 unmodified linesMessages = List[Dict[str, str]]# Tavily Search Clientdef history_to_messages(history: History, system: str) -> Messages:messages = [{'role': 'system', 'content': system}]1141 unmodified linesexcept Exception as e:print(f"[TempCleanup] Error during cleanup: {str(e)}")def generate_image_to_image(input_image_data, prompt: str, token: gr.OAuthToken | None = None) -> str:"""Generate an image using image-to-image via OpenRouter.1400 unmodified linesprint("[Video2Video] No <body> tag; appending video via replacement block")return f"{SEARCH_START}\n\n{DIVIDER}\n{video_html}\n{REPLACE_END}"def apply_generated_media_to_html_REMOVED():"""Apply text/image/video/music replacements to HTML content.- Works with single-document HTML strings503 unmodified lines# Updated for faster Tavily search and closer prompt usage# Uses 'advanced' search_depth and auto_parameters=True for speed and relevancedef send_to_sandbox(code):"""Render HTML in a sandboxed iframe. Assumes full HTML is provided by prompts."""713 unmodified lines}def generation_code(query: str | None, vlm_image: Optional[gr.Image], file: str | None, website_url: str | None, _setting: Dict[str, str], _history: Optional[History], _current_model: Dict, language: str = "html", provider: str = "auto", profile: gr.OAuthProfile | None = None, token: gr.OAuthToken | None = None):# Check authentication firstis_authenticated, auth_message = check_authentication(profile, token)if not is_authenticated:174 unmodified lines# Use language-specific promptif language == "html":# Dynamic file selection always enabledsystem_prompt = DYNAMIC_MULTIPAGE_HTML_SYSTEM_PROMPTelif language == "transformers.js":system_prompt = TRANSFORMERS_JS_SYSTEM_PROMPTelif language == "svelte":system_prompt = SVELTE_SYSTEM_PROMPTelif language == "gradio":system_prompt = GRADIO_SYSTEM_PROMPTelif language == "json":system_prompt = JSON_SYSTEM_PROMPTelse:system_prompt = GENERIC_SYSTEM_PROMPT.format(language=language)messages = history_to_messages(_history, system_prompt)25 unmodified linesThis will help me create a better design for you."""query = f"{query}\n\n[Error extracting website: {website_text}]{fallback_guidance}"# Use the original query without search enhancementenhanced_query = query# Check if this is GLM-4.5 model and handle with simple HuggingFace InferenceClientif _current_model["id"] == "zai-org/GLM-4.5":40 unmodified linesclean_code = remove_code_block(content)# Use clean code as final content without media generationfinal_content = clean_code_history.append([query, final_content])if language == "transformers.js":files = parse_transformers_js_output(clean_code)if files['index.html'] and files['index.js'] and files['style.css']:formatted_output = format_transformers_js_output(files)yield {code_output: formatted_output,34 unmodified linesmodified_content = apply_search_replace_changes(last_content, clean_code)clean_content = remove_code_block(modified_content)# Use clean content without media generationyield {code_output: clean_content,2 unmodified lineshistory_output: history_to_chatbot_messages(_history),}else:# Use clean code as final content without media generationfinal_content = clean_codepreview_val = Noneif language == "html":231 unmodified lineselse:# Append content, filtering out placeholder thinking linescontent += strip_placeholder_thinking(chunk_content)search_status = ""# Handle transformers.js output differentlyif language == "transformers.js":172 unmodified linesmodified_content = apply_search_replace_changes(last_content, final_code)clean_content = remove_code_block(modified_content)# Use clean content without media generation# Update history with the cleaned content_history.append([query, clean_content])7 unmodified lines# Regular generation - use the content as isfinal_content = remove_code_block(content)# Use final content without media generation_history.append([query, final_content])preview_val = None1092 unmodified linesvalue=("### Command Reference\n""- **Language**: 'use streamlit' | 'use gradio' | 'use html'\n""- **Model**: 'model <name>' (exact match to items in the Model dropdown)\n""- **Website redesign**: include a URL in your message (e.g., 'https://example.com')\n""- **Files**: attach documents or images directly for reference\n""- **Multiple directives**: separate with commas. The first segment is the main build prompt.\n\n""Examples:\n""- anycoder coffee shop website\n""- redesign https://example.com, use streamlit\n""- dashboard ui with minimalist design"))51 unmodified lineslabel="UI design image",visible=False)# Removed image generation componentswith gr.Row():btn = gr.Button("Generate", variant="secondary", size="lg", scale=2, visible=True, interactive=False)clear_btn = gr.Button("Clear", variant="secondary", size="sm", scale=1, visible=True)# --- Deploy/app name/sdk components ---space_name_input = gr.Textbox(label="app name (e.g. my-cool-app)",placeholder="Enter your app name",16 unmodified linesdeploy_btn = gr.Button("🚀 Deploy App", variant="primary", visible=False)deploy_status = gr.Markdown(visible=False, label="Deploy status")# --- End move ---# Removed media generation and web search UI components# Removed media generation toggle event handlersmodel_dropdown = gr.Dropdown(choices=[model['name'] for model in AVAILABLE_MODELS],value=DEFAULT_MODEL_NAME,13 unmodified linesfn=lambda idx=i: gr.update(value=DEMO_LIST[idx]['description']),outputs=input)# Removed web search availability indicatordef on_model_change(model_name):for m in AVAILABLE_MODELS:if m['name'] == model_name:526 unmodified linesshow_progress="hidden",).then(generation_code,inputs=[input, image_input, file_input, website_url_input, setting, history, current_model, language_dropdown, provider_state],outputs=[code_output, history, sandbox, history_output]).then(end_generation_ui,34 unmodified linesshow_progress="hidden",).then(generation_code,inputs=[input, image_input, file_input, website_url_input, setting, history, current_model, language_dropdown, provider_state],outputs=[code_output, history, sandbox, history_output]).then(end_generation_ui,
123456git+https://github.com/huggingface/huggingface_hub.gitgradio[oauth]tavily-pythonPyPDF2python-docxpytesseract12345git+https://github.com/huggingface/huggingface_hub.gitgradio[oauth]PyPDF2python-docxpytesseract
README.md-7
app.py+29-731
requirements.txt-1