Skip to content

Instantly share code, notes, and snippets.

@googlefan256
Created June 23, 2025 07:39
Show Gist options
  • Save googlefan256/a9555445974ad1e368d56a44c22becde to your computer and use it in GitHub Desktop.
Save googlefan256/a9555445974ad1e368d56a44c22becde to your computer and use it in GitHub Desktop.
def ai(prompt: str):
from google import genai
client = genai.Client(api_key="")
response = client.models.generate_content(
model="gemini-2.5-flash-lite-preview-06-17",
contents=f"Write a python3 code only, no explanation. {prompt}"
)
code = response.text
if code.startswith("```python"):
code = code.removeprefix("```python").strip()
if code.endswith("```"):
code = code.removesuffix("```").strip()
exec(code, globals())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment