code: from langchain.callbacks import CallbackManager
  from llama_index import ServiceContext, PromptHelper, LLMPredictor
  from core.callback_handler.std_out_callback_handler import DifyStdOutCallbackHandler
  from core.embedding.openai_embedding import OpenAIEmbedding
  from core.llm.llm_builder import LLMBuilder
  
  
  class IndexBuilder:
      @classmethod
      def get_default_service_context(cls, tenant_id: str) -> ServiceContext:
          # set number of output tokens
          num_output = 512
  
          # only for verbose
          callback_manager = CallbackManager([DifyStdOutCallbackHandler()])
  
          llm = LLMBuilder.to_llm(
              tenant_id=tenant_id,
              model_name='text-davinci-003',
              temperature=0,
              max_tokens=num_output,
              callback_manager=callback_manager,
          )
  
          llm_predictor = LLMPredictor(llm=llm)
  
          # These parameters here will affect the logic of segmenting the final synthesized response.
          # The number of refinement iterations in the synthesis process depends
          # on whether the length of the segmented output exceeds the max_input_size.
          prompt_helper = PromptHelper(
              max_input_size=3500,
              num_output=num_output,
              max_chunk_overlap=20
          )
  
          provider = LLMBuilder.get_default_provider(tenant_id)
  
          model_credentials = LLMBuilder.get_model_credentials(
              tenant_id=tenant_id,
              model_provider=provider,
              model_name='text-embedding-ada-002'
          )
  
          return ServiceContext.from_defaults(
              llm_predictor=llm_predictor,
              prompt_helper=prompt_helper,
              embed_model=OpenAIEmbedding(**model_credentials),
          )
  
      @classmethod
      def get_fake_llm_service_context(cls, tenant_id: str) -> ServiceContext:
          llm = LLMBuilder.to_llm(
              tenant_id=tenant_id,
              model_name='fake'
          )
  
          return ServiceContext.from_defaults(
              llm_predictor=LLMPredictor(llm=llm),
              embed_model=OpenAIEmbedding()
          )
  
apis: llama_index.PromptHelper llama_index.LLMPredictor
extract_api: [((599, 745), 'core.llm.llm_builder.LLMBuilder.to_llm', 'LLMBuilder.to_llm', ([], {'tenant_id': 'tenant_id', 'model_name': '"""text-davinci-003"""', 'temperature': '(0)', 'max_tokens': 'num_output', 'callback_manager': 'callback_manager'}), "(tenant_id=tenant_id, model_name='text-davinci-003',\n    temperature=0, max_tokens=num_output, callback_manager=callback_manager)\n", (616, 745), False, 'from core.llm.llm_builder import LLMBuilder\n'), ((838, 859), 'llama_index.LLMPredictor', 'LLMPredictor', ([], {'llm': 'llm'}), '(llm=llm)\n', (850, 859), False, 'from llama_index import ServiceContext, PromptHelper, LLMPredictor\n'), ((1148, 1226), 'llama_index.PromptHelper', 'PromptHelper', ([], {'max_input_size': '(3500)', 'num_output': 'num_output', 'max_chunk_overlap': '(20)'}), '(max_input_size=3500, num_output=num_output, max_chunk_overlap=20)\n', (1160, 1226), False, 'from llama_index import ServiceContext, PromptHelper, LLMPredictor\n'), ((1293, 1335), 'core.llm.llm_builder.LLMBuilder.get_default_provider', 'LLMBuilder.get_default_provider', (['tenant_id'], {}), '(tenant_id)\n', (1324, 1335), False, 'from core.llm.llm_builder import LLMBuilder\n'), ((1365, 1485), 'core.llm.llm_builder.LLMBuilder.get_model_credentials', 'LLMBuilder.get_model_credentials', ([], {'tenant_id': 'tenant_id', 'model_provider': 'provider', 'model_name': '"""text-embedding-ada-002"""'}), "(tenant_id=tenant_id, model_provider=\n    provider, model_name='text-embedding-ada-002')\n", (1397, 1485), False, 'from core.llm.llm_builder import LLMBuilder\n'), ((1836, 1893), 'core.llm.llm_builder.LLMBuilder.to_llm', 'LLMBuilder.to_llm', ([], {'tenant_id': 'tenant_id', 'model_name': '"""fake"""'}), "(tenant_id=tenant_id, model_name='fake')\n", (1853, 1893), False, 'from core.llm.llm_builder import LLMBuilder\n'), ((554, 581), 'core.callback_handler.std_out_callback_handler.DifyStdOutCallbackHandler', 'DifyStdOutCallbackHandler', ([], {}), '()\n', (579, 581), False, 'from core.callback_handler.std_out_callback_handler import DifyStdOutCallbackHandler\n'), ((1679, 1715), 'core.embedding.openai_embedding.OpenAIEmbedding', 'OpenAIEmbedding', ([], {}), '(**model_credentials)\n', (1694, 1715), False, 'from core.embedding.openai_embedding import OpenAIEmbedding\n'), ((2000, 2021), 'llama_index.LLMPredictor', 'LLMPredictor', ([], {'llm': 'llm'}), '(llm=llm)\n', (2012, 2021), False, 'from llama_index import ServiceContext, PromptHelper, LLMPredictor\n'), ((2047, 2064), 'core.embedding.openai_embedding.OpenAIEmbedding', 'OpenAIEmbedding', ([], {}), '()\n', (2062, 2064), False, 'from core.embedding.openai_embedding import OpenAIEmbedding\n')]