Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

refactors

Abi Raja24a123db3608
diff --git a/backend/logging/__init__.py b/backend/fs_logging/__init__.py
similarity index 100%
rename from backend/logging/__init__.py
rename to backend/fs_logging/__init__.py
diff --git a/backend/logging/core.py b/backend/fs_logging/core.py
similarity index 100%
rename from backend/logging/core.py
rename to backend/fs_logging/core.py
diff --git a/backend/routes/generate_code.py b/backend/routes/generate_code.py
index 59bd42dc..6d4f0e41 100644
--- a/backend/routes/generate_code.py
+++ b/backend/routes/generate_code.py
@@ -14,7 +14,7 @@ from llm import (
stream_openai_response,
)
from openai.types.chat import ChatCompletionMessageParam
-from logging.core import write_logs
+from fs_logging.core import write_logs
from mock_llm import mock_completion
from typing import Any, Callable, Coroutine, Dict, List, Literal, Union, cast, get_args
from image_generation import create_alt_url_mapping, generate_images
@@ -30,6 +30,21 @@ from ws.constants import APP_ERROR_WEB_SOCKET_CODE # type: ignore
router = APIRouter()
+# Auto-upgrade usage of older models
+def auto_upgrade_model(code_generation_model: Llm) -> Llm:
+ if code_generation_model in {Llm.GPT_4_VISION, Llm.GPT_4_TURBO_2024_04_09}:
+ print(
+ f"Initial deprecated model: {code_generation_model}. Auto-updating code generation model to GPT-4O-2024-05-13"
+ )
+ return Llm.GPT_4O_2024_05_13
+ elif code_generation_model == Llm.CLAUDE_3_SONNET:
+ print(
+ f"Initial deprecated model: {code_generation_model}. Auto-updating code generation model to CLAUDE-3.5-SONNET-2024-06-20"
+ )
+ return Llm.CLAUDE_3_5_SONNET_2024_06_20
+ return code_generation_model
+
+
# Generate images and return updated completions
async def process_completion(
completion: str,
@@ -121,16 +136,7 @@ async def stream_code(websocket: WebSocket):
raise Exception(f"Invalid model: {code_generation_model_str}")
# Auto-upgrade usage of older models
- if code_generation_model in {Llm.GPT_4_VISION, Llm.GPT_4_TURBO_2024_04_09}:
- print(
- f"Initial deprecated model: {code_generation_model}. Auto-updating code generation model to GPT-4O-2024-05-13"
- )
- code_generation_model = Llm.GPT_4O_2024_05_13
- elif code_generation_model == Llm.CLAUDE_3_SONNET:
- print(
- f"Initial deprecated model: {code_generation_model}. Auto-updating code generation model to CLAUDE-3.5-SONNET-2024-06-20"
- )
- code_generation_model = Llm.CLAUDE_3_5_SONNET_2024_06_20
+ code_generation_model = auto_upgrade_model(code_generation_model)
print(
f"Generating {generated_code_config} code for uploaded {input_mode} using {code_generation_model} model..."