code: # retrivel from PDF
  import os
  import sys
  from pydantic import BaseModel, Field
  from langchain.chat_models import AzureChatOpenAI
  from langchain.embeddings import AzureOpenAIEmbeddings
  from langchain.chains import LLMChain, HypotheticalDocumentEmbedder
  from langchain.prompts import PromptTemplate
  from langchain.embeddings import HuggingFaceEmbeddings
  from openai import AzureOpenAI
  
  # Get the directory of the current script
  current_script_dir = os.path.dirname(os.path.abspath(__file__))
  
  # Get the parent directory (applied_rag) by navigating up one level from the current script
  parent_dir = os.path.dirname(current_script_dir)
  
  # Add the parent directory to sys.path
  sys.path.append(parent_dir)
  
  import settings
  from langchain.vectorstores import LanceDB
  import lancedb
  from langchain.text_splitter import RecursiveCharacterTextSplitter
  from langchain.document_loaders import PyPDFLoader
  
  # Configuration data class
  class AppConfig(BaseModel):
      openai_api_key: str
      openai_api_base: str
      openai_api_type: str
      deployment_name: str
      model_name: str
      openai_api_version: str
  
  # Load configuration from settings
  config = AppConfig(
      openai_api_key=settings.openai_api_key,
      openai_api_base=settings.openai_api_base,
      openai_api_type=settings.openai_api_type,
      deployment_name=settings.deployment_name,
      model_name=settings.model_name,
      openai_api_version=settings.openai_api_version
  )
  
  # Initialize Azure LLM
  llm = AzureChatOpenAI(
      deployment_name=config.deployment_name,
      openai_api_key=config.openai_api_key,
      openai_api_base=config.openai_api_base,
      openai_api_type=config.openai_api_type,
      openai_api_version=config.openai_api_version,
      model_name=config.model_name,
      temperature=0.0
  )
  
  emebeddings = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2")
  
  embeddings = HypotheticalDocumentEmbedder.from_llm(llm, emebeddings, "web_search")
  
  
  prompt_template = """
  As a knowledgeable and helpful research assistant, your task is to provide informative answers based on the given context. Use your extensive knowledge base to offer clear, concise, and accurate responses to the user's inquiries.
  if quetion is not related to documents simply say you dont know
  Question: {question}
  
  Answer:
  """
  
  prompt = PromptTemplate(input_variables=["question"], template=prompt_template)
  
  llm_chain = LLMChain(llm=llm, prompt=prompt)
  embeddings = HypotheticalDocumentEmbedder(
      llm_chain=llm_chain,
      base_embeddings=embeddings
  )
  
  # Loading data from pdf
  pdf_folder_path = '/workspaces/rag/02_Hyde/pamphlet.pdf'
  
  loader = PyPDFLoader(pdf_folder_path)
  docs = loader.load_and_split()
  
  text_splitter = RecursiveCharacterTextSplitter(
      chunk_size=128,
      chunk_overlap=50,
  )
  documents = text_splitter.split_documents(docs)
  
  
  
  # lancedb as vectorstore
  db = lancedb.connect('/tmp/lancedb')
  table = db.create_table("documentsai", data=[
      {"vector": embeddings.embed_query("アジャイル"), "text": "アジャイル", "id": "1"}
  ], mode="overwrite")
  vector_store = LanceDB.from_documents(documents, embeddings, connection=table)
  
  # passing in the string query to get some refrence
  # query = "which factors appear to be the major nutritional limitations of fast-food meals"
  query = "Ridgelinezアジャイルサービスとその優位性を説明してください。"
  
  # result = vector_store.similarity_search(query)
  # print(result)
  
  answer = llm_chain.run(query)
  print(answer)
apis: lancedb.connect
extract_api: [((596, 631), 'os.path.dirname', 'os.path.dirname', (['current_script_dir'], {}), '(current_script_dir)\n', (611, 631), False, 'import os\n'), ((672, 699), 'sys.path.append', 'sys.path.append', (['parent_dir'], {}), '(parent_dir)\n', (687, 699), False, 'import sys\n'), ((1453, 1733), 'langchain.chat_models.AzureChatOpenAI', 'AzureChatOpenAI', ([], {'deployment_name': 'config.deployment_name', 'openai_api_key': 'config.openai_api_key', 'openai_api_base': 'config.openai_api_base', 'openai_api_type': 'config.openai_api_type', 'openai_api_version': 'config.openai_api_version', 'model_name': 'config.model_name', 'temperature': '(0.0)'}), '(deployment_name=config.deployment_name, openai_api_key=\n    config.openai_api_key, openai_api_base=config.openai_api_base,\n    openai_api_type=config.openai_api_type, openai_api_version=config.\n    openai_api_version, model_name=config.model_name, temperature=0.0)\n', (1468, 1733), False, 'from langchain.chat_models import AzureChatOpenAI\n'), ((1765, 1817), 'langchain.embeddings.HuggingFaceEmbeddings', 'HuggingFaceEmbeddings', ([], {'model_name': '"""all-MiniLM-L6-v2"""'}), "(model_name='all-MiniLM-L6-v2')\n", (1786, 1817), False, 'from langchain.embeddings import HuggingFaceEmbeddings\n'), ((1832, 1901), 'langchain.chains.HypotheticalDocumentEmbedder.from_llm', 'HypotheticalDocumentEmbedder.from_llm', (['llm', 'emebeddings', '"""web_search"""'], {}), "(llm, emebeddings, 'web_search')\n", (1869, 1901), False, 'from langchain.chains import LLMChain, HypotheticalDocumentEmbedder\n'), ((2264, 2334), 'langchain.prompts.PromptTemplate', 'PromptTemplate', ([], {'input_variables': "['question']", 'template': 'prompt_template'}), "(input_variables=['question'], template=prompt_template)\n", (2278, 2334), False, 'from langchain.prompts import PromptTemplate\n'), ((2348, 2380), 'langchain.chains.LLMChain', 'LLMChain', ([], {'llm': 'llm', 'prompt': 'prompt'}), '(llm=llm, prompt=prompt)\n', (2356, 2380), False, 'from langchain.chains import LLMChain, HypotheticalDocumentEmbedder\n'), ((2394, 2471), 'langchain.chains.HypotheticalDocumentEmbedder', 'HypotheticalDocumentEmbedder', ([], {'llm_chain': 'llm_chain', 'base_embeddings': 'embeddings'}), '(llm_chain=llm_chain, base_embeddings=embeddings)\n', (2422, 2471), False, 'from langchain.chains import LLMChain, HypotheticalDocumentEmbedder\n'), ((2574, 2602), 'langchain.document_loaders.PyPDFLoader', 'PyPDFLoader', (['pdf_folder_path'], {}), '(pdf_folder_path)\n', (2585, 2602), False, 'from langchain.document_loaders import PyPDFLoader\n'), ((2651, 2715), 'langchain.text_splitter.RecursiveCharacterTextSplitter', 'RecursiveCharacterTextSplitter', ([], {'chunk_size': '(128)', 'chunk_overlap': '(50)'}), '(chunk_size=128, chunk_overlap=50)\n', (2681, 2715), False, 'from langchain.text_splitter import RecursiveCharacterTextSplitter\n'), ((2808, 2839), 'lancedb.connect', 'lancedb.connect', (['"""/tmp/lancedb"""'], {}), "('/tmp/lancedb')\n", (2823, 2839), False, 'import lancedb\n'), ((2998, 3061), 'langchain.vectorstores.LanceDB.from_documents', 'LanceDB.from_documents', (['documents', 'embeddings'], {'connection': 'table'}), '(documents, embeddings, connection=table)\n', (3020, 3061), False, 'from langchain.vectorstores import LanceDB\n'), ((463, 488), 'os.path.abspath', 'os.path.abspath', (['__file__'], {}), '(__file__)\n', (478, 488), False, 'import os\n')]