code: # Load indices from disk
  from llama_index.core import load_index_from_storage
  from llama_index.core import StorageContext
  from llama_index.core.tools import QueryEngineTool, ToolMetadata
  from llama_index.llms.openai import OpenAI
  from llama_index.core.query_engine import SubQuestionQueryEngine
  from llama_index.agent.openai import OpenAIAgent
  import json
  import os
  import openai
  
  script_dir = os.path.dirname(os.path.realpath(__file__))
  config_path = os.path.join(script_dir, "config.json")
  with open(config_path) as f:
      config = json.load(f)
  
  storage_dir = os.path.join(script_dir, config['storage-dir'])
  
  os.environ["OPENAI_API_KEY"] = config['OPENAI_API_KEY']
  openai.api_key = os.environ["OPENAI_API_KEY"]
  
  # Load the cached data and create a query engine for each year which can be
  # used by a chat model. 
  index_set = {}
  individual_query_engine_tools = []
  for year in config['years']:
      storage_context = StorageContext.from_defaults(
          persist_dir=os.path.join(storage_dir, f"{year}")
      )
      cur_index = load_index_from_storage(
          storage_context,
      )
      index_set[year] = cur_index
      tool = QueryEngineTool(
          query_engine=index_set[year].as_query_engine(),
          metadata=ToolMetadata(
              name=f"vector_index_{year}",
              description=f"useful for when you want to answer queries about the {year} SEC 10-K for Uber",
          ),
      )
      individual_query_engine_tools.append(tool)
  
  # Create a tool that can query filings across multiple years
  query_engine = SubQuestionQueryEngine.from_defaults(
      query_engine_tools=individual_query_engine_tools,
      llm=OpenAI(model="gpt-3.5-turbo"),
  )
  
  query_engine_tool = QueryEngineTool(
      query_engine=query_engine,
      metadata=ToolMetadata(
          name="sub_question_query_engine",
          description="useful for when you want to answer queries that require analyzing multiple SEC 10-K documents for Uber",
      ),
  )
  
  # Pass all of the tools to the chat model agent
  tools = individual_query_engine_tools + [query_engine_tool]
  agent = OpenAIAgent.from_tools(tools)
  
apis: llama_index.agent.openai.OpenAIAgent.from_tools llama_index.core.tools.ToolMetadata llama_index.core.load_index_from_storage llama_index.llms.openai.OpenAI
extract_api: [((452, 491), 'os.path.join', 'os.path.join', (['script_dir', '"""config.json"""'], {}), "(script_dir, 'config.json')\n", (464, 491), False, 'import os\n'), ((562, 609), 'os.path.join', 'os.path.join', (['script_dir', "config['storage-dir']"], {}), "(script_dir, config['storage-dir'])\n", (574, 609), False, 'import os\n'), ((2039, 2068), 'llama_index.agent.openai.OpenAIAgent.from_tools', 'OpenAIAgent.from_tools', (['tools'], {}), '(tools)\n', (2061, 2068), False, 'from llama_index.agent.openai import OpenAIAgent\n'), ((410, 436), 'os.path.realpath', 'os.path.realpath', (['__file__'], {}), '(__file__)\n', (426, 436), False, 'import os\n'), ((534, 546), 'json.load', 'json.load', (['f'], {}), '(f)\n', (543, 546), False, 'import json\n'), ((1025, 1065), 'llama_index.core.load_index_from_storage', 'load_index_from_storage', (['storage_context'], {}), '(storage_context)\n', (1048, 1065), False, 'from llama_index.core import load_index_from_storage\n'), ((1616, 1645), 'llama_index.llms.openai.OpenAI', 'OpenAI', ([], {'model': '"""gpt-3.5-turbo"""'}), "(model='gpt-3.5-turbo')\n", (1622, 1645), False, 'from llama_index.llms.openai import OpenAI\n'), ((1731, 1905), 'llama_index.core.tools.ToolMetadata', 'ToolMetadata', ([], {'name': '"""sub_question_query_engine"""', 'description': '"""useful for when you want to answer queries that require analyzing multiple SEC 10-K documents for Uber"""'}), "(name='sub_question_query_engine', description=\n    'useful for when you want to answer queries that require analyzing multiple SEC 10-K documents for Uber'\n    )\n", (1743, 1905), False, 'from llama_index.core.tools import QueryEngineTool, ToolMetadata\n'), ((966, 1002), 'os.path.join', 'os.path.join', (['storage_dir', 'f"""{year}"""'], {}), "(storage_dir, f'{year}')\n", (978, 1002), False, 'import os\n'), ((1214, 1359), 'llama_index.core.tools.ToolMetadata', 'ToolMetadata', ([], {'name': 'f"""vector_index_{year}"""', 'description': 'f"""useful for when you want to answer queries about the {year} SEC 10-K for Uber"""'}), "(name=f'vector_index_{year}', description=\n    f'useful for when you want to answer queries about the {year} SEC 10-K for Uber'\n    )\n", (1226, 1359), False, 'from llama_index.core.tools import QueryEngineTool, ToolMetadata\n')]