Alpaca icon indicating copy to clipboard operation
Alpaca copied to clipboard

add thinking budget option for gemini

Open olumolu opened this issue 7 months ago • 4 comments

def generate():
client = genai.Client(
api_key=os.environ.get("GEMINI_API_KEY"),
)

model = "gemini-2.5-flash-preview-05-20"
contents = [
    types.Content(
        role="user",
        parts=[
            types.Part.from_text(text="""INSERT_INPUT_HERE"""),
        ],
    ),
]
generate_content_config = types.GenerateContentConfig(
    thinking_config = types.ThinkingConfig(
        thinking_budget=8000,
    ),
    response_mime_type="text/plain",
)

for chunk in client.models.generate_content_stream(
    model=model,
    contents=contents,
    config=generate_content_config,
):
    print(chunk.text, end="")

if name == "main":
generate()

add a small button so we can set thinking budget

olumolu avatar May 23 '25 09:05 olumolu

Great idea. After all, we've got to make good use of all the sugary sweet new things announced at I/O!

mags0ft avatar May 23 '25 14:05 mags0ft

Great idea. After all, we've got to make good use of all the sugary sweet new things announced at I/O!

as of now this is only supported in gemini-2.5-flash-preview-05-20 model

olumolu avatar May 23 '25 14:05 olumolu

I don't use Gemini's library so I don't think I can do that

Jeffser avatar May 24 '25 21:05 Jeffser

There'll probably be an option to set the budget with their API, but I don't know if the OpenAI library can access these fields. That's a question which is likely answered somewhere deeeep down in dusty documentation 😭

mags0ft avatar May 25 '25 01:05 mags0ft