update
Browse filesFiles changed (2)
566 unmodified lines56756856957057157257312 unmodified lines5865875885895905915927 unmodified lines60060160260360460560660760860360961061116 unmodified lines628629630626631632633634566 unmodified lines raise HTTPException(status_code=401, detail="No HuggingFace token available. Please sign in first.") print(f"[Deploy] Attempting deployment with token (first 10 chars): {user_token[:10]}...") print(f"[Deploy] Request parameters - language: {request.language}, space_name: {request.space_name}, existing_repo_id: {request.existing_repo_id}") # Check for existing deployed space in this session existing_repo_id = request.existing_repo_id12 unmodified lines break # Use the standalone deployment function print(f"[Deploy] Calling deploy_to_huggingface_space with existing_repo_id: {existing_repo_id}") success, message, space_url = deploy_to_huggingface_space( code=request.code, language=request.language,7 unmodified lines ) if success: # Extract repo_id from space_url repo_id = space_url.split("/spaces/")[-1] if space_url else None print(f"[Deploy] Success! Repo ID: {repo_id}") # Track deployed space in session for follow-up updates if session_token and session_token in user_sessions: repo_id = space_url.split("/spaces/")[-1] if space_url else None if repo_id: session = user_sessions[session_token] deployed_spaces = session.get("deployed_spaces", [])16 unmodified lines "success": True, "space_url": space_url, "message": message, "repo_id": repo_id if 'repo_id' in locals() else None "repo_id": repo_id } else: # Provide user-friendly error message based on the error192 unmodified lines1931941951961971981992002012022032042052062075 unmodified lines21321421521621721821922022122222322422522622733 unmodified lines261262263264265266267268269270271272273274275276277258278279280281262282283284285286287288289290291192 unmodified lines }
try { console.log('[Deploy] Deploying with params:', { language: selectedLanguage, space_name: spaceName, existing_repo_id: existingRepoId, currentRepoId: currentRepoId, username: username, code_length: generatedCode.length }); const response = await apiClient.deploy({ code: generatedCode, space_name: spaceName,5 unmodified lines if (response.success) { // Update current repo ID if we got one back if (response.repo_id) { console.log('[Deploy] Setting currentRepoId to:', response.repo_id); setCurrentRepoId(response.repo_id); } else if (response.space_url) { // Extract repo_id from space_url as fallback const match = response.space_url.match(/huggingface\.co\/spaces\/([^\/\s\)]+\/[^\/\s\)]+)/); if (match) { console.log('[Deploy] Extracted repo_id from URL:', match[1]); setCurrentRepoId(match[1]); } } // Add deployment message to chat33 unmodified lines };
const handleImport = (code: string, language: Language, importUrl?: string) => { console.log('[Import] Importing project:', { language, importUrl, username }); setGeneratedCode(code); setSelectedLanguage(language); // Extract repo_id from import URL if provided if (importUrl) { const spaceMatch = importUrl.match(/huggingface\.co\/spaces\/([^\/\s\)]+\/[^\/\s\)]+)/); console.log('[Import] Regex match result:', spaceMatch); if (spaceMatch) { const importedRepoId = spaceMatch[1]; console.log('[Import] Extracted repo_id:', importedRepoId, 'Username:', username); // Only set as current repo if user owns it if (username && importedRepoId.startsWith(`${username}/`)) { setCurrentRepoId(importedRepoId); console.log('[Import] Set current repo to:', importedRepoId); console.log('[Import] ✅ Set current repo to:', importedRepoId); } else { // User doesn't own the imported space, clear current repo setCurrentRepoId(null); console.log('[Import] User does not own imported space:', importedRepoId); console.log('[Import] ⚠️ User does not own imported space:', importedRepoId, '(username:', username, ')'); } } else { console.log('[Import] ⚠️ Could not extract repo_id from URL:', importUrl); } } else { console.log('[Import] No import URL provided'); } // Add messages that include the imported code so LLM can see itbackend_api.py+7-2
frontend/src/app/page.tsx+26-2