Spaces:
				
			
			
	
			
			
		Paused
		
	
	
	
			
			
	
	
	
	
		
		
		Paused
		
	Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | @@ -202,10 +202,7 @@ def handle_chat(input_text, history): | |
| 202 | 
             
                    if app_description:
         | 
| 203 | 
             
                        add_message("System", f"'"Generating code for {app_description}..."'")
         | 
| 204 | 
             
                        code = generate_app_code(selected_app, app_description, "CodeQwen", history)  # Use CodeQwen by default
         | 
| 205 | 
            -
                        add_message("System", f"'"
         | 
| 206 | 
            -
             | 
| 207 | 
            -
             | 
| 208 | 
            -
            python\n{code}\n
         | 
| 209 |  | 
| 210 | 
             
            add_message("System", "Code generated! What else can I do for you?")
         | 
| 211 | 
             
                        update_project_data("code", code)
         | 
| @@ -222,10 +219,7 @@ add_message("System", "Code generated! What else can I do for you?") | |
| 222 | 
             
            def generate_code_tool(input_text, history):
         | 
| 223 | 
             
                """Prebuilt tool for code generation."""
         | 
| 224 | 
             
                code = generate_app_code("MyTool", "A tool to do something", "CodeQwen", history)  # Use CodeQwen by default
         | 
| 225 | 
            -
                return f"
         | 
| 226 | 
            -
             | 
| 227 | 
            -
             | 
| 228 | 
            -
            python\n{code}\n
         | 
| 229 |  | 
| 230 | 
             
            def analyze_code_tool(input_text, history):
         | 
| 231 | 
             
                """Prebuilt tool for code analysis."""
         | 
| @@ -247,7 +241,7 @@ chat_input = st.text_input("Tell me your idea...", key="chat_input") | |
| 247 | 
             
            if chat_input:
         | 
| 248 | 
             
                chat_history, dynamic_functions = handle_chat(chat_input, chat_history)
         | 
| 249 | 
             
                for sender, message in chat_history:
         | 
| 250 | 
            -
                    st.markdown(f"**{sender}:** {message}")
         | 
| 251 |  | 
| 252 | 
             
            # --- Code Execution and Deployment ---
         | 
| 253 | 
             
            if CURRENT_APP["code"]:
         | 
| @@ -266,9 +260,9 @@ if CURRENT_APP["code"]: | |
| 266 | 
             
                        inputs = tokenizer(code_area, return_tensors="pt")
         | 
| 267 | 
             
                        output = model.generate(**inputs, max_length=500, num_return_sequences=1)
         | 
| 268 | 
             
                        output = tokenizer.decode(output[0], skip_special_tokens=True)
         | 
| 269 | 
            -
                        st.success(f"'"Code executed successfully!{output}" | 
| 270 | 
             
                    except Exception as e:
         | 
| 271 | 
            -
                        st.error(f"'"Error executing code: {e}" | 
| 272 |  | 
| 273 | 
             
                # --- Code Editing ---
         | 
| 274 | 
             
                st.markdown("## Edit Your Code:")
         | 
| @@ -279,10 +273,7 @@ if CURRENT_APP["code"]: | |
| 279 |  | 
| 280 | 
             
            inputs = tokenizer(prompt, return_tensors="pt")
         | 
| 281 | 
             
                        output = model.generate(**inputs, max_length=500, num_return_sequences=1)
         | 
| 282 | 
            -
                        edited_code = tokenizer.decode(output[0], skip_special_tokens=True).split("
         | 
| 283 | 
            -
             | 
| 284 | 
            -
             | 
| 285 | 
            -
            python\n")[1].split("\n
         | 
| 286 |  | 
| 287 | 
             
            st.success(f"'"Code edited successfully!\n{edited_code}"'"")            
         | 
| 288 | 
             
                        update_project_data("code", edited_code)
         | 
|  | |
| 202 | 
             
                    if app_description:
         | 
| 203 | 
             
                        add_message("System", f"'"Generating code for {app_description}..."'")
         | 
| 204 | 
             
                        code = generate_app_code(selected_app, app_description, "CodeQwen", history)  # Use CodeQwen by default
         | 
| 205 | 
            +
                        add_message("System", f"'"python {code}
         | 
|  | |
|  | |
|  | |
| 206 |  | 
| 207 | 
             
            add_message("System", "Code generated! What else can I do for you?")
         | 
| 208 | 
             
                        update_project_data("code", code)
         | 
|  | |
| 219 | 
             
            def generate_code_tool(input_text, history):
         | 
| 220 | 
             
                """Prebuilt tool for code generation."""
         | 
| 221 | 
             
                code = generate_app_code("MyTool", "A tool to do something", "CodeQwen", history)  # Use CodeQwen by default
         | 
| 222 | 
            +
                return f"'"python\n{code}\n"'"
         | 
|  | |
|  | |
|  | |
| 223 |  | 
| 224 | 
             
            def analyze_code_tool(input_text, history):
         | 
| 225 | 
             
                """Prebuilt tool for code analysis."""
         | 
|  | |
| 241 | 
             
            if chat_input:
         | 
| 242 | 
             
                chat_history, dynamic_functions = handle_chat(chat_input, chat_history)
         | 
| 243 | 
             
                for sender, message in chat_history:
         | 
| 244 | 
            +
                    st.markdown(f"'"**{sender}:** {message}"'")
         | 
| 245 |  | 
| 246 | 
             
            # --- Code Execution and Deployment ---
         | 
| 247 | 
             
            if CURRENT_APP["code"]:
         | 
|  | |
| 260 | 
             
                        inputs = tokenizer(code_area, return_tensors="pt")
         | 
| 261 | 
             
                        output = model.generate(**inputs, max_length=500, num_return_sequences=1)
         | 
| 262 | 
             
                        output = tokenizer.decode(output[0], skip_special_tokens=True)
         | 
| 263 | 
            +
                        st.success(f"'"Code executed successfully!{output}")
         | 
| 264 | 
             
                    except Exception as e:
         | 
| 265 | 
            +
                        st.error(f"'"Error executing code: {e}")
         | 
| 266 |  | 
| 267 | 
             
                # --- Code Editing ---
         | 
| 268 | 
             
                st.markdown("## Edit Your Code:")
         | 
|  | |
| 273 |  | 
| 274 | 
             
            inputs = tokenizer(prompt, return_tensors="pt")
         | 
| 275 | 
             
                        output = model.generate(**inputs, max_length=500, num_return_sequences=1)
         | 
| 276 | 
            +
                        edited_code = tokenizer.decode(output[0], skip_special_tokens=True).split("[python [1].split("
         | 
|  | |
|  | |
|  | |
| 277 |  | 
| 278 | 
             
            st.success(f"'"Code edited successfully!\n{edited_code}"'"")            
         | 
| 279 | 
             
                        update_project_data("code", edited_code)
         | 
 
			
