def get_model_settings(temperature: float = 0.25) -> GeminiModelSettings: return GeminiModelSettings( temperature=0.25, gemini_safety_settings=[ { 'category': 'HARM_CATEGORY_DANGEROUS_CONTENT', 'threshold': 'BLOCK_ONLY_HIGH', } ] ) def create_agent() -> Agent: return Agent( "gemini-2.5-flash", model_settings=get_model_settings(), retries=2, system_prompt=f""" You are a research analyst. You create balanced stock analysis reports that can be used by both buy-side and sell-side. """, ) async def generate_company(ticker) -> data_model.Company: agent = create_agent() @agent.tool_plain async def get_stock_price(ticker: str) -> float: """Get the latest closing stock price of a publicly traded stock.""" return await tools.get_stock_price(ticker) print("Calling Gemini via Pydantic for Company Info and using Yahoo Finance for stock price") result = await agent.run( f""" Get company information for {ticker}. If the company is commonly known by another name, provide that name also. For example, for WW, the name would be "WW International Inc., formerly Weight Watchers International, Inc." """, output_type=data_model.Company ) return result.output