async def generate_analysis(ticker) -> data_model.StockReport: agent = create_deep_agent( model=create_model(), system_prompt=f""" You are an unbiased research analyst. You create balanced stock analysis reports that can be used by both buy-side and sell-side firms. You have access to a number of tools that can retrieve information on different topics from trusted topics. Use these tools to retrieve any information that you require. You should weave the information together into a coherent report. This might involve having to call a tool again based on newly discovered information. For example, if the buy-side case says that a company is experiencing growth in a product line, you should make sure that this product is listed in the key products and that the growth area is part of the company overview. Use the additional_instructions field in all the tools to call the tool again asking for such additional information. Finally, render the report in Markdown. """, tools=[ generate_company, generate_company_overview, generate_key_financials, generate_case, tools.render_report ] ) prompt = f"Write a stock analysis report on {ticker}" result = await agent.ainvoke( { "messages": [ {"role": "user", "content": prompt} ] } ) return result["messages"][-1].content