Skip to content

Instantly share code, notes, and snippets.

@SmetDenis
Last active May 16, 2025 08:28
Show Gist options
  • Save SmetDenis/b65550b7bb8d970ec9d26db2d1ae376b to your computer and use it in GitHub Desktop.
Save SmetDenis/b65550b7bb8d970ec9d26db2d1ae376b to your computer and use it in GitHub Desktop.
from google import genai
from google.genai import types
import traceback
import os
import re
response_file = './workdir/response.md'
def getFile(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()
content = re.sub(r'^---\s*\n(?:.*\n)*?---\s*\n', '', content)
return content
try:
client = genai.Client(api_key=os.getenv('API_KEY').strip())
response = client.models.generate_content(
model="gemini-2.5-flash-preview-04-17",
# model="gemini-2.5-pro-preview-05-06",
contents=[
'## Context',
getFile('./workdir/context.md'),
'## core/types.ts',
getFile('./src/core/types.ts'),
'## core/utils.ts',
getFile('./src/core/utils.ts'),
'## core/history.ts',
getFile('./src/core/history.ts'),
'## history.tsx',
getFile('./src/history.tsx'),
'## Your task',
getFile('./workdir/question.md')
],
config=types.GenerateContentConfig(
thinking_config=types.ThinkingConfig(include_thoughts=True, thinking_budget=16000),
system_instruction=getFile('./DeepThinking.md'),
max_output_tokens=128000,
temperature=0.3,
top_p=0.95
),
)
# print(response.text)
with open(response_file, "w", encoding="utf-8") as f:
f.write(response.text)
for key, value in response.usage_metadata:
if (value is not None):
print(f"{key}: {value}")
except Exception as e:
print(f"Ошибка: {e}")
traceback.print_exc()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment