gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

Centralize creation of the AI object

Open allenhutchison opened this issue 1 year ago • 5 comments

In #587 @NTaylorMullen was asking for centralization of our ai object so that we can track tokens in a single place. https://github.com/google-gemini/gemini-cli/pull/587#discussion_r2112915544 need to do that refactor to support different sub-agent tools.

allenhutchison avatar May 29 '25 17:05 allenhutchison

@allenhutchison were you going to tackle this or should I leave up for grabs?

NTaylorMullen avatar May 31 '25 04:05 NTaylorMullen

@NTaylorMullen @allenhutchison do you mean you want one GoogleGenAI object or once GeminiClient that wraps this? I assume GeminiClient and you would track all the tokens in this client

scottdensmore avatar Jun 01 '25 20:06 scottdensmore

@NTaylorMullen @allenhutchison do you mean you want one GoogleGenAI object or once GeminiClient that wraps this? I assume GeminiClient and you would track all the tokens in this client

Ya I think 1 GeminiClient which indirectly will enforce 1 GoogleGenAI object. Currently the web fetch and google search tools use the GoolgeGenAI object directly which is probably a miss. We should expand our client object to allow more general requests. That way we can ensure we have centralized token counting

NTaylorMullen avatar Jun 01 '25 20:06 NTaylorMullen

Yep.. just need to find how to inject the client through the system

scottdensmore avatar Jun 01 '25 21:06 scottdensmore

Yep.. just need to find how to inject the client through the system

https://github.com/google-gemini/gemini-cli/blob/main/packages/core/src/config/config.ts is where I'd do it. In a way it's our "DI" container in a lot of ways 😄

NTaylorMullen avatar Jun 01 '25 21:06 NTaylorMullen