Skip to content

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

Python

support genai package and new flash preview

Abi Raja05ab29335c16
diff --git a/backend/evals/core.py b/backend/evals/core.py
index a9dbe748..f9987d5f 100644
--- a/backend/evals/core.py
+++ b/backend/evals/core.py
@@ -41,7 +41,7 @@ async def generate_code_core(
model == Llm.GEMINI_2_0_FLASH_EXP
or model == Llm.GEMINI_2_0_PRO_EXP
or model == Llm.GEMINI_2_0_FLASH
- or model == Llm.GEMINI_2_5_FLASH_PREVIEW_04_17
+ or model == Llm.GEMINI_2_5_FLASH_PREVIEW_05_20
or model == Llm.GEMINI_2_5_PRO_PREVIEW_05_06
):
if not GEMINI_API_KEY:
diff --git a/backend/llm.py b/backend/llm.py
index 88c38453..22f9acef 100644
--- a/backend/llm.py
+++ b/backend/llm.py
@@ -34,7 +34,7 @@ class Llm(Enum):
GEMINI_2_0_FLASH_EXP = "gemini-2.0-flash-exp"
GEMINI_2_0_FLASH = "gemini-2.0-flash"
GEMINI_2_0_PRO_EXP = "gemini-2.0-pro-exp-02-05"
- GEMINI_2_5_FLASH_PREVIEW_04_17 = "gemini-2.5-flash-preview-04-17"
+ GEMINI_2_5_FLASH_PREVIEW_05_20 = "gemini-2.5-flash-preview-05-20"
GEMINI_2_5_PRO_PREVIEW_05_06 = "gemini-2.5-pro-preview-05-06"
O1_2024_12_17 = "o1-2024-12-17"
O4_MINI_2025_04_16 = "o4-mini-2025-04-16"
@@ -310,25 +310,28 @@ async def stream_gemini_response(
image_urls = [{"uri": image_url}] # type: ignore
break # Exit after first image URL
- client = genai.Client(api_key=api_key) # type: ignore
+ client = genai.Client(api_key=api_key)
full_response = ""
- async for response in client.aio.models.generate_content_stream( # type: ignore
+
+ async for chunk in await client.aio.models.generate_content_stream(
model=model.value,
contents={
"parts": [
{"text": messages[0]["content"]}, # type: ignore
- types.Part.from_bytes( # type: ignore
- data=base64.b64decode(image_urls[0]["data"]), # type: ignore
- mime_type=image_urls[0]["mime_type"], # type: ignore
+ types.Part.from_bytes(
+ data=base64.b64decode(image_urls[0]["data"]),
+ mime_type=image_urls[0]["mime_type"],
),
- ] # type: ignore
- }, # type: ignore
- config=types.GenerateContentConfig( # type: ignore
- temperature=0, max_output_tokens=8192
+ ]
+ },
+ config=types.GenerateContentConfig(
+ temperature=0,
+ max_output_tokens=20000,
+ thinking_config=types.ThinkingConfig(thinking_budget=10000),
),
): # type: ignore
- if response.text: # type: ignore
- full_response += response.text # type: ignore
- await callback(response.text) # type: ignore
+ if chunk.text:
+ full_response += chunk.text
+ await callback(chunk.text)
completion_time = time.time() - start_time
return {"duration": completion_time, "code": full_response}
diff --git a/backend/poetry.lock b/backend/poetry.lock
index 9a2a3dee..84036f2a 100644
--- a/backend/poetry.lock
+++ b/backend/poetry.lock
@@ -160,13 +160,13 @@ vertex = ["google-auth (>=2,<3)"]
[[package]]
name = "anyio"
-version = "4.7.0"
+version = "4.9.0"
description = "High level compatibility layer for multiple asynchronous event loop implementations"
optional = false
python-versions = ">=3.9"
files = [
- {file = "anyio-4.7.0-py3-none-any.whl", hash = "sha256:ea60c3723ab42ba6fff7e8ccb0488c898ec538ff4df1f1d5e642c3601d07e352"},
- {file = "anyio-4.7.0.tar.gz", hash = "sha256:2f834749c602966b7d456a7567cafcb309f96482b5081d14ac93ccd457f9dd48"},
+ {file = "anyio-4.9.0-py3-none-any.whl", hash = "sha256:9f76d541cad6e36af7beb62e978876f3b41e3e04f2c1fbf0884604c0a9c4d93c"},
+ {file = "anyio-4.9.0.tar.gz", hash = "sha256:673c0c244e15788651a4ff38710fea9675823028a6f08a5eda409e0c9840a028"},
]
[package.dependencies]
@@ -176,8 +176,8 @@ sniffio = ">=1.1"
typing_extensions = {version = ">=4.5", markers = "python_version < \"3.13\""}
[package.extras]
-doc = ["Sphinx (>=7.4,<8.0)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx_rtd_theme"]
-test = ["anyio[trio]", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "truststore (>=0.9.1)", "uvloop (>=0.21)"]
+doc = ["Sphinx (>=8.2,<9.0)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx_rtd_theme"]
+test = ["anyio[trio]", "blockbuster (>=1.5.23)", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "trustme", "truststore (>=0.9.1)", "uvloop (>=0.21)"]
trio = ["trio (>=0.26.1)"]
[[package]]
@@ -613,21 +613,23 @@ requests = ["requests (>=2.20.0,<3.0.0.dev0)"]
[[package]]
name = "google-genai"
-version = "0.3.0"
+version = "1.16.1"
description = "GenAI Python SDK"
optional = false
python-versions = ">=3.9"
files = [
- {file = "google_genai-0.3.0-py3-none-any.whl", hash = "sha256:e45eb1732cf5b1f7c5a4103fe64cc4b577981d7e592e3edfba6d34ec734f56be"},
- {file = "google_genai-0.3.0.tar.gz", hash = "sha256:1e080ca381268912dacc8e0cb15eb203eb4e38f51f6ae35cc5768e5af323c8cc"},
+ {file = "google_genai-1.16.1-py3-none-any.whl", hash = "sha256:6ae5d24282244f577ca4f0d95c09f75ab29e556602c9d3531b70161e34cd2a39"},
+ {file = "google_genai-1.16.1.tar.gz", hash = "sha256:4b4ed4ed781a9d61e5ce0fef1486dd3a5d7ff0a73bd76b9633d21e687ab998df"},
]
[package.dependencies]
-google-auth = ">=2.14.1,<3.0.0dev"
-pillow = ">=10.0.0,<12.0.0"
-pydantic = ">=2.0.0,<3.0.0dev"
-requests = ">=2.28.1,<3.0.0dev"
-websockets = ">=13.0,<15.0dev"
+anyio = ">=4.8.0,<5.0.0"
+google-auth = ">=2.14.1,<3.0.0"
+httpx = ">=0.28.1,<1.0.0"
+pydantic = ">=2.0.0,<3.0.0"
+requests = ">=2.28.1,<3.0.0"
+typing-extensions = ">=4.11.0,<5.0.0"
+websockets = ">=13.0.0,<15.1.0"
[[package]]
name = "h11"
@@ -663,13 +665,13 @@ trio = ["trio (>=0.22.0,<1.0)"]
[[package]]
name = "httpx"
-version = "0.25.2"
+version = "0.28.1"
description = "The next generation HTTP client."
optional = false
python-versions = ">=3.8"
files = [
- {file = "httpx-0.25.2-py3-none-any.whl", hash = "sha256:a05d3d052d9b2dfce0e3896636467f8a5342fb2b902c819428e1ac65413ca118"},
- {file = "httpx-0.25.2.tar.gz", hash = "sha256:8b8fcaa0c8ea7b05edd69a094e63a2094c4efcb48129fb757361bc423c0ad9e8"},
+ {file = "httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad"},
+ {file = "httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc"},
]
[package.dependencies]
@@ -677,13 +679,13 @@ anyio = "*"
certifi = "*"
httpcore = "==1.*"
idna = "*"
-sniffio = "*"
[package.extras]
brotli = ["brotli", "brotlicffi"]
cli = ["click (==8.*)", "pygments (==2.*)", "rich (>=10,<14)"]
http2 = ["h2 (>=3,<5)"]
socks = ["socksio (==1.*)"]
+zstd = ["zstandard (>=0.18.0)"]
[[package]]
name = "identify"
@@ -2036,4 +2038,4 @@ propcache = ">=0.2.0"
[metadata]
lock-version = "2.0"
python-versions = "^3.10"
-content-hash = "56a222ca97125f114acb4402eac856fd63d40f7f53407da6a48842eb6a709626"
+content-hash = "2056289f68d094e01e5e7b5ca7d4c2e03318565caadb89a76c09f4e4a510b734"
diff --git a/backend/pyproject.toml b/backend/pyproject.toml
index 1d7f0117..632e1302 100644
--- a/backend/pyproject.toml
+++ b/backend/pyproject.toml
@@ -13,7 +13,7 @@ websockets = "^14.1"
openai = "^1.2.4"
python-dotenv = "^1.0.0"
beautifulsoup4 = "^4.12.2"
-httpx = "^0.25.1"
+httpx = "^0.28.1"
pre-commit = "^3.6.2"
anthropic = "^0.49.0"
moviepy = "^1.0.3"
@@ -21,7 +21,7 @@ pillow = "^10.3.0"
types-pillow = "^10.2.0.20240520"
aiohttp = "^3.9.5"
pydantic = "^2.10"
-google-genai = "^0.3.0"
+google-genai = "^1.16.1"
[tool.poetry.group.dev.dependencies]
pytest = "^7.4.3"
diff --git a/backend/routes/generate_code.py b/backend/routes/generate_code.py
index 66edb8b7..53c6eda7 100644
--- a/backend/routes/generate_code.py
+++ b/backend/routes/generate_code.py
@@ -265,7 +265,7 @@ async def stream_code(websocket: WebSocket):
if openai_api_key and anthropic_api_key:
variant_models = [
claude_model,
- Llm.GPT_4O_2024_11_20,
+ Llm.GEMINI_2_5_PRO_PREVIEW_05_06,
]
elif openai_api_key:
variant_models = [
@@ -316,7 +316,7 @@ async def stream_code(websocket: WebSocket):
model == Llm.GEMINI_2_0_PRO_EXP
or model == Llm.GEMINI_2_0_FLASH_EXP
or model == Llm.GEMINI_2_0_FLASH
- or model == Llm.GEMINI_2_5_FLASH_PREVIEW_04_17
+ or model == Llm.GEMINI_2_5_FLASH_PREVIEW_05_20
or model == Llm.GEMINI_2_5_PRO_PREVIEW_05_06
):
tasks.append(