code: from fastapi import FastAPI
  from pydantic import BaseModel
  import asyncio
  import whisper
  from llama_index.embeddings import OpenAIEmbedding
  from llama_index.llms import OpenAI
  from llama_index.ingestion import IngestionPipeline
  from llama_index.extractors import TitleExtractor, SummaryExtractor
  from llama_index.text_splitter import SentenceSplitter
  from llama_index.schema import MetadataMode
  # from langchain.embeddings.huggingface import HuggingFaceBgeEmbeddings
  # from llama_index.embeddings import *
  from llama_index.embeddings import HuggingFaceEmbedding
  from llm import LLMClient
  from llama_index.llms import Ollama
  from llama_index import ServiceContext
  from llama_index.vector_stores import AstraDBVectorStore
  from llama_index import Document
  from llama_index.text_splitter import TokenTextSplitter
  from llama_index import set_global_service_context
  from llama_index.llms import LangChainLLM
  from langchain_nvidia_ai_endpoints import ChatNVIDIA
  import os
  import asyncio
  
  
  
  token = os.environ['token']
  api_endpoint = os.environ['api_endpoint']
  
  def create_pipeline_astra_db(llm_type='nvidia',embed_model='local',collection_name='video_transcript'):
      print("Loading Pipeline")
      if embed_model=='local':
          print("embed_model local")
          embed_model = "BAAI/bge-base-en"
          embed_model_dim = 768
          embed_model = HuggingFaceEmbedding(model_name=embed_model)
      elif embed_model=='nvidia':
          print("embed_model nviida")
          embed_model_dim = 1024
          embed_model = HuggingFaceEmbedding(model_name=embed_model)
      else:
          print("embed_model else")
          embed_model = HuggingFaceEmbedding(model_name=embed_model)
      
      if llm_type=='nvidia':
          print('llm nvidia')
          nvai_llm = ChatNVIDIA(model='llama2_70b')
          llm = LangChainLLM(llm=nvai_llm)
      elif llm_type=='ollama':
          print('llm_ollama')
          llm = Ollama(model='stablelm2', temperature=0.1)
      else:
          print('llm else')
          llm = OpenAI(model="gpt-3.5-turbo-1106", temperature=0.1)
  
  
      service_context = ServiceContext.from_defaults(embed_model=embed_model, llm=llm)
      set_global_service_context(service_context) 
      astra_db_store = AstraDBVectorStore(
          token=token,
          api_endpoint=api_endpoint,
          collection_name=collection_name,
          embedding_dimension=embed_model_dim,
      )
  
      transformations = [
          SentenceSplitter(chunk_size=1024, chunk_overlap=100),
          # TitleExtractor(llm=llm, metadata_mode=MetadataMode.EMBED, num_workers=8),
          # SummaryExtractor(llm=llm, metadata_mode=MetadataMode.EMBED, num_workers=8),
          embed_model,
      ]
      # text_splitter = TokenTextSplitter(chunk_size=512)
      return IngestionPipeline(transformations=transformations,vector_store=astra_db_store)
  
  class AudioData(BaseModel):
      audio_file_path: str
  pipeline = create_pipeline_astra_db(llm_type='nvidia',collection_name="video_test_collection")
  app = FastAPI()
  @app.get("/status")
  def read_status():
      return {"status": "running"}    
  
  @app.post("/transcribe")
  async def transcribe(audio_data:AudioData):
      return {"transcription": whisper.transcribe(audio_data.audio_file_path)["text"]}
  
  
  @app.post("/transcribe_v2")
  async def transcribe(audio_data:AudioData):
  
      return {"transcription": whisper.transcribe(audio_data.audio_file_path,path_or_hf_repo="mlx-community/whisper-medium-mlx")["text"]}
  
  class ingest_data(BaseModel):
      text: str
      metadata:dict
  
  @app.post("/ingest")
  def ingest(ingest_data:ingest_data):
      doc = [Document(text=ingest_data.text,metadata=ingest_data.metadata)]
      pipeline.run(documents=doc,num_workers=4)
      return {"Done"}
apis: llama_index.vector_stores.AstraDBVectorStore llama_index.ServiceContext.from_defaults llama_index.llms.Ollama llama_index.llms.OpenAI llama_index.llms.LangChainLLM llama_index.embeddings.HuggingFaceEmbedding llama_index.text_splitter.SentenceSplitter llama_index.set_global_service_context llama_index.Document llama_index.ingestion.IngestionPipeline
extract_api: [((2944, 2953), 'fastapi.FastAPI', 'FastAPI', ([], {}), '()\n', (2951, 2953), False, 'from fastapi import FastAPI\n'), ((2058, 2120), 'llama_index.ServiceContext.from_defaults', 'ServiceContext.from_defaults', ([], {'embed_model': 'embed_model', 'llm': 'llm'}), '(embed_model=embed_model, llm=llm)\n', (2086, 2120), False, 'from llama_index import ServiceContext\n'), ((2125, 2168), 'llama_index.set_global_service_context', 'set_global_service_context', (['service_context'], {}), '(service_context)\n', (2151, 2168), False, 'from llama_index import set_global_service_context\n'), ((2191, 2324), 'llama_index.vector_stores.AstraDBVectorStore', 'AstraDBVectorStore', ([], {'token': 'token', 'api_endpoint': 'api_endpoint', 'collection_name': 'collection_name', 'embedding_dimension': 'embed_model_dim'}), '(token=token, api_endpoint=api_endpoint, collection_name=\n    collection_name, embedding_dimension=embed_model_dim)\n', (2209, 2324), False, 'from llama_index.vector_stores import AstraDBVectorStore\n'), ((2710, 2789), 'llama_index.ingestion.IngestionPipeline', 'IngestionPipeline', ([], {'transformations': 'transformations', 'vector_store': 'astra_db_store'}), '(transformations=transformations, vector_store=astra_db_store)\n', (2727, 2789), False, 'from llama_index.ingestion import IngestionPipeline\n'), ((1345, 1389), 'llama_index.embeddings.HuggingFaceEmbedding', 'HuggingFaceEmbedding', ([], {'model_name': 'embed_model'}), '(model_name=embed_model)\n', (1365, 1389), False, 'from llama_index.embeddings import HuggingFaceEmbedding\n'), ((1746, 1776), 'langchain_nvidia_ai_endpoints.ChatNVIDIA', 'ChatNVIDIA', ([], {'model': '"""llama2_70b"""'}), "(model='llama2_70b')\n", (1756, 1776), False, 'from langchain_nvidia_ai_endpoints import ChatNVIDIA\n'), ((1791, 1817), 'llama_index.llms.LangChainLLM', 'LangChainLLM', ([], {'llm': 'nvai_llm'}), '(llm=nvai_llm)\n', (1803, 1817), False, 'from llama_index.llms import LangChainLLM\n'), ((2392, 2444), 'llama_index.text_splitter.SentenceSplitter', 'SentenceSplitter', ([], {'chunk_size': '(1024)', 'chunk_overlap': '(100)'}), '(chunk_size=1024, chunk_overlap=100)\n', (2408, 2444), False, 'from llama_index.text_splitter import SentenceSplitter\n'), ((3529, 3591), 'llama_index.Document', 'Document', ([], {'text': 'ingest_data.text', 'metadata': 'ingest_data.metadata'}), '(text=ingest_data.text, metadata=ingest_data.metadata)\n', (3537, 3591), False, 'from llama_index import Document\n'), ((1511, 1555), 'llama_index.embeddings.HuggingFaceEmbedding', 'HuggingFaceEmbedding', ([], {'model_name': 'embed_model'}), '(model_name=embed_model)\n', (1531, 1555), False, 'from llama_index.embeddings import HuggingFaceEmbedding\n'), ((1622, 1666), 'llama_index.embeddings.HuggingFaceEmbedding', 'HuggingFaceEmbedding', ([], {'model_name': 'embed_model'}), '(model_name=embed_model)\n', (1642, 1666), False, 'from llama_index.embeddings import HuggingFaceEmbedding\n'), ((1889, 1931), 'llama_index.llms.Ollama', 'Ollama', ([], {'model': '"""stablelm2"""', 'temperature': '(0.1)'}), "(model='stablelm2', temperature=0.1)\n", (1895, 1931), False, 'from llama_index.llms import Ollama\n'), ((1982, 2033), 'llama_index.llms.OpenAI', 'OpenAI', ([], {'model': '"""gpt-3.5-turbo-1106"""', 'temperature': '(0.1)'}), "(model='gpt-3.5-turbo-1106', temperature=0.1)\n", (1988, 2033), False, 'from llama_index.llms import OpenAI\n'), ((3129, 3175), 'whisper.transcribe', 'whisper.transcribe', (['audio_data.audio_file_path'], {}), '(audio_data.audio_file_path)\n', (3147, 3175), False, 'import whisper\n'), ((3289, 3392), 'whisper.transcribe', 'whisper.transcribe', (['audio_data.audio_file_path'], {'path_or_hf_repo': '"""mlx-community/whisper-medium-mlx"""'}), "(audio_data.audio_file_path, path_or_hf_repo=\n    'mlx-community/whisper-medium-mlx')\n", (3307, 3392), False, 'import whisper\n')]