code: import argparse
  import logging
  import sys
  import re
  import os
  import argparse
  
  import requests
  from pathlib import Path
  from urllib.parse import urlparse
  
  from llama_index import ServiceContext, StorageContext
  from llama_index import set_global_service_context
  from llama_index import VectorStoreIndex, SimpleDirectoryReader, Document
  from llama_index.llms import OpenAI
  from llama_index.readers.file.flat_reader import FlatReader
  from llama_index.vector_stores import MilvusVectorStore
  from llama_index.embeddings import HuggingFaceEmbedding
  from llama_index.node_parser.text import SentenceWindowNodeParser
  
  from llama_index.prompts import ChatPromptTemplate, ChatMessage, MessageRole, PromptTemplate
  from llama_index.postprocessor import MetadataReplacementPostProcessor
  from llama_index.postprocessor import SentenceTransformerRerank
  #from llama_index.indices import ZillizCloudPipelineIndex
  from custom.zilliz.base import ZillizCloudPipelineIndex
  from llama_index.indices.query.schema import QueryBundle
  from llama_index.schema import BaseNode, ImageNode, MetadataMode
  
  from custom.history_sentence_window import HistorySentenceWindowNodeParser
  from custom.llms.QwenLLM import QwenUnofficial
  from custom.llms.GeminiLLM import Gemini
  from custom.llms.proxy_model import ProxyModel
  from pymilvus import MilvusClient
  
  QA_PROMPT_TMPL_STR = (
      "请你仔细阅读相关内容，结合历史资料进行回答,每一条史资料使用'出处：《书名》原文内容'的形式标注 (如果回答请清晰无误地引用原文,先给出回答，再贴上对应的原文，使用《书名》[]对原文进行标识),，如果发现资料无法得到答案，就回答不知道 \n"
      "搜索的相关历史资料如下所示.\n"
      "---------------------\n"
      "{context_str}\n"
      "---------------------\n"
      "问题: {query_str}\n"
      "答案: "
  )
  
  QA_SYSTEM_PROMPT = "你是一个严谨的历史知识问答智能体，你会仔细阅读历史材料并给出准确的回答,你的回答都会非常准确，因为你在回答的之后，使用在《书名》[]内给出原文用来支撑你回答的证据.并且你会在开头说明原文是否有回答所需的知识"
  
  REFINE_PROMPT_TMPL_STR = ( 
      "你是一个历史知识回答修正机器人，你严格按以下方式工作"
      "1.只有原答案为不知道时才进行修正,否则输出原答案的内容\n"
      "2.修正的时候为了体现你的精准和客观，你非常喜欢使用《书名》[]将原文展示出来.\n"
      "3.如果感到疑惑的时候，就用原答案的内容回答。"
      "新的知识: {context_msg}\n"
      "问题: {query_str}\n"
      "原答案: {existing_answer}\n"
      "新答案: "
  )
  
  def is_valid_url(url):
      try:
          result = urlparse(url)
          return all([result.scheme, result.netloc])
      except ValueError:
          return False
  
  def is_github_folder_url(url):
      return url.startswith('https://raw.githubusercontent.com/') and '.' not in os.path.basename(url)
  
  
  def get_branch_head_sha(owner, repo, branch):
      url = f"https://api.github.com/repos/{owner}/{repo}/git/ref/heads/{branch}"
      response = requests.get(url)
      data = response.json()
      sha = data['object']['sha']
      return sha
  
  def get_github_repo_contents(repo_url):
      # repo_url example: https://raw.githubusercontent.com/wxywb/history_rag/master/data/history_24/
      repo_owner = repo_url.split('/')[3]
      repo_name = repo_url.split('/')[4]
      branch = repo_url.split('/')[5]
      folder_path = '/'.join(repo_url.split('/')[6:])
      sha = get_branch_head_sha(repo_owner, repo_name, branch)
      url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/git/trees/{sha}?recursive=1"
      try:
          response = requests.get(url)
          if response.status_code == 200:
              data = response.json()
  
              raw_urls = []
              for file in data['tree']:
                  if file['path'].startswith(folder_path) and file['path'].endswith('.txt'):
                      raw_url = f"https://raw.githubusercontent.com/{repo_owner}/{repo_name}/{branch}/{file['path']}"
                      raw_urls.append(raw_url)
              return raw_urls
          else:
              print(f"Failed to fetch contents. Status code: {response.status_code}")
      except Exception as e:
          print(f"Failed to fetch contents. Error: {str(e)}")
      return []
  
  class Executor:
      def __init__(self, model):
          pass
  
      def build_index(self, path, overwrite):
          pass
  
      def build_query_engine(self):
          pass
       
      def delete_file(self, path):
          pass
      
      def query(self, question):
          pass
   
  
  class MilvusExecutor(Executor):
      def __init__(self, config):
          self.index = None
          self.query_engine = None
          self.config = config
          self.node_parser = HistorySentenceWindowNodeParser.from_defaults(
              sentence_splitter=lambda text: re.findall("[^,.;。？！]+[,.;。？！]?", text),
              window_size=config.milvus.window_size,
              window_metadata_key="window",
              original_text_metadata_key="original_text",)
  
          embed_model = HuggingFaceEmbedding(model_name=config.embedding.name)
  
          # 使用Qwen 通义千问模型
          if config.llm.name.find("qwen") != -1:
              llm = QwenUnofficial(temperature=config.llm.temperature, model=config.llm.name, max_tokens=2048)
          elif config.llm.name.find("gemini") != -1:
              llm = Gemini(temperature=config.llm.temperature, model_name=config.llm.name, max_tokens=2048)
          elif 'proxy_model' in config.llm:
              llm = ProxyModel(model_name=config.llm.name, api_base=config.llm.api_base, api_key=config.llm.api_key,
                               temperature=config.llm.temperature,  max_tokens=2048)
              print(f"使用{config.llm.name},PROXY_SERVER_URL为{config.llm.api_base},PROXY_API_KEY为{config.llm.api_key}")
          else:
              api_base = None
              if 'api_base' in config.llm:
                  api_base = config.llm.api_base
              llm = OpenAI(api_base = api_base, temperature=config.llm.temperature, model=config.llm.name, max_tokens=2048)
  
          service_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)
          set_global_service_context(service_context)
          rerank_k = config.milvus.rerank_topk
          self.rerank_postprocessor = SentenceTransformerRerank(
              model=config.rerank.name, top_n=rerank_k)
          self._milvus_client = None
          self._debug = False
          
      def set_debug(self, mode):
          self._debug = mode
  
      def build_index(self, path, overwrite):
          config = self.config
          vector_store = MilvusVectorStore(
              uri = f"http://{config.milvus.host}:{config.milvus.port}",
              collection_name = config.milvus.collection_name,
              overwrite=overwrite,
              dim=config.embedding.dim)
          self._milvus_client = vector_store.milvusclient
           
          if path.endswith('.txt'):
              if os.path.exists(path) is False:
                  print(f'(rag) 没有找到文件{path}')
                  return
              else:
                  documents = FlatReader().load_data(Path(path))
                  documents[0].metadata['file_name'] = documents[0].metadata['filename'] 
          elif os.path.isfile(path):           
              print('(rag) 目前仅支持txt文件')
          elif os.path.isdir(path):
              if os.path.exists(path) is False:
                  print(f'(rag) 没有找到目录{path}')
                  return
              else:
                  documents = SimpleDirectoryReader(path).load_data()
          else:
              return
  
          storage_context = StorageContext.from_defaults(vector_store=vector_store)
          nodes = self.node_parser.get_nodes_from_documents(documents)
          self.index = VectorStoreIndex(nodes, storage_context=storage_context, show_progress=True)
  
      def _get_index(self):
          config = self.config
          vector_store = MilvusVectorStore(
              uri = f"http://{config.milvus.host}:{config.milvus.port}",
              collection_name = config.milvus.collection_name,
              dim=config.embedding.dim)
          self.index = VectorStoreIndex.from_vector_store(vector_store=vector_store)
          self._milvus_client = vector_store.milvusclient
  
      def build_query_engine(self):
          config = self.config
          if self.index is None:
              self._get_index()
          self.query_engine = self.index.as_query_engine(node_postprocessors=[
              self.rerank_postprocessor,
              MetadataReplacementPostProcessor(target_metadata_key="window")
          ])
          self.query_engine._retriever.similarity_top_k=config.milvus.retrieve_topk
  
          message_templates = [
              ChatMessage(content=QA_SYSTEM_PROMPT, role=MessageRole.SYSTEM),
              ChatMessage(
                  content=QA_PROMPT_TMPL_STR,
                  role=MessageRole.USER,
              ),
          ]
          chat_template = ChatPromptTemplate(message_templates=message_templates)
          self.query_engine.update_prompts(
              {"response_synthesizer:text_qa_template": chat_template}
          )
          self.query_engine._response_synthesizer._refine_template.conditionals[0][1].message_templates[0].content = REFINE_PROMPT_TMPL_STR
  
      def delete_file(self, path):
          config = self.config
          if self._milvus_client is None:
              self._get_index()
          num_entities_prev = self._milvus_client.query(collection_name='history_rag',filter="",output_fields=["count(*)"])[0]["count(*)"]
          res = self._milvus_client.delete(collection_name=config.milvus.collection_name, filter=f"file_name=='{path}'")
          num_entities = self._milvus_client.query(collection_name='history_rag',filter="",output_fields=["count(*)"])[0]["count(*)"]
          print(f'(rag) 现有{num_entities}条，删除{num_entities_prev - num_entities}条数据')
      
      def query(self, question):
          if self.index is None:
              self._get_index()
          if question.endswith('?') or question.endswith('？'):
              question = question[:-1]
          if self._debug is True:
              contexts = self.query_engine.retrieve(QueryBundle(question))
              for i, context in enumerate(contexts): 
                  print(f'{question}', i)
                  content = context.node.get_content(metadata_mode=MetadataMode.LLM)
                  print(content)
              print('-------------------------------------------------------参考资料---------------------------------------------------------')
          response = self.query_engine.query(question)
          return response
  
  class PipelineExecutor(Executor):
      def __init__(self, config):
          self.ZILLIZ_CLUSTER_ID = os.getenv("ZILLIZ_CLUSTER_ID")
          self.ZILLIZ_TOKEN = os.getenv("ZILLIZ_TOKEN")
          self.ZILLIZ_PROJECT_ID = os.getenv("ZILLIZ_PROJECT_ID") 
          self.ZILLIZ_CLUSTER_ENDPOINT = f"https://{self.ZILLIZ_CLUSTER_ID}.api.gcp-us-west1.zillizcloud.com"
      
          self.config = config
          if len(self.ZILLIZ_CLUSTER_ID) == 0:
              print('ZILLIZ_CLUSTER_ID 参数为空')
              exit()
  
          if len(self.ZILLIZ_TOKEN) == 0:
              print('ZILLIZ_TOKEN 参数为空')
              exit()
          
          self.config = config
          self._debug = False
  
          if config.llm.name.find("qwen") != -1:
              llm = QwenUnofficial(temperature=config.llm.temperature, model=config.llm.name, max_tokens=2048)
          elif config.llm.name.find("gemini") != -1:
              llm = Gemini(model_name=config.llm.name, temperature=config.llm.temperature, max_tokens=2048)
          else:
              api_base = None
              if 'api_base' in config.llm:
                  api_base = config.llm.api_base
              llm = OpenAI(api_base = api_base, temperature=config.llm.temperature, model=config.llm.name, max_tokens=2048)
  
          service_context = ServiceContext.from_defaults(llm=llm, embed_model=None)
          self.service_context = service_context
          set_global_service_context(service_context)
          self._initialize_pipeline(service_context)
  
          #rerank_k = config.rerankl
          #self.rerank_postprocessor = SentenceTransformerRerank(
          #    model="BAAI/bge-reranker-large", top_n=rerank_k)
  
      def set_debug(self, mode):
          self._debug = mode
  
      def _initialize_pipeline(self, service_context: ServiceContext):
          config = self.config
          try:
              self.index = ZillizCloudPipelineIndex(
                  project_id = self.ZILLIZ_PROJECT_ID,
                  cluster_id=self.ZILLIZ_CLUSTER_ID,
                  token=self.ZILLIZ_TOKEN,
                  collection_name=config.pipeline.collection_name,
                  service_context=service_context,
               )
              if len(self._list_pipeline_ids()) == 0:
                  self.index.create_pipelines(
                      metadata_schema={"digest_from":"VarChar"}, chunk_size=self.config.pipeline.chunk_size
                  )
          except Exception as e:
              print('(rag) zilliz pipeline 连接异常', str(e))
              exit()
          try:
              self._milvus_client = MilvusClient(
                  uri=self.ZILLIZ_CLUSTER_ENDPOINT, 
                  token=self.ZILLIZ_TOKEN 
              )
          except Exception as e:
              print('(rag) zilliz cloud 连接异常', str(e))
  
      def build_index(self, path, overwrite):
          config = self.config
          if not is_valid_url(path) or 'github' not in path:
              print('(rag) 不是一个合法的url，请尝试`https://raw.githubusercontent.com/wxywb/history_rag/master/data/history_24/baihuasanguozhi.txt`')
              return
          if overwrite == True:
              self._milvus_client.drop_collection(config.pipeline.collection_name)
              pipeline_ids = self._list_pipeline_ids()
              self._delete_pipeline_ids(pipeline_ids)
  
              self._initialize_pipeline(self.service_context)
  
          if is_github_folder_url(path):
              urls = get_github_repo_contents(path)
              for url in urls:
                  print(f'(rag) 正在构建索引 {url}')
                  self.build_index(url, False)  # already deleted original collection
          elif path.endswith('.txt'):
              self.index.insert_doc_url(
                  url=path,
                  metadata={"digest_from": HistorySentenceWindowNodeParser.book_name(os.path.basename(path))},
              )
          else:
              print('(rag) 只有github上以txt结尾或文件夹可以被支持。')
  
      def build_query_engine(self):
          config = self.config
          self.query_engine = self.index.as_query_engine(
            search_top_k=config.pipeline.retrieve_topk)
          message_templates = [
              ChatMessage(content=QA_SYSTEM_PROMPT, role=MessageRole.SYSTEM),
              ChatMessage(
                  content=QA_PROMPT_TMPL_STR,
                  role=MessageRole.USER,
              ),
          ]
          chat_template = ChatPromptTemplate(message_templates=message_templates)
          self.query_engine.update_prompts(
              {"response_synthesizer:text_qa_template": chat_template}
          )
          self.query_engine._response_synthesizer._refine_template.conditionals[0][1].message_templates[0].content = REFINE_PROMPT_TMPL_STR
  
  
      def delete_file(self, path):
          config = self.config
          if self._milvus_client is None:
              self._get_index()
          num_entities_prev = self._milvus_client.query(collection_name='history_rag',filter="",output_fields=["count(*)"])[0]["count(*)"]
          res = self._milvus_client.delete(collection_name=config.milvus.collection_name, filter=f"doc_name=='{path}'")
          num_entities = self._milvus_client.query(collection_name='history_rag',filter="",output_fields=["count(*)"])[0]["count(*)"]
          print(f'(rag) 现有{num_entities}条，删除{num_entities_prev - num_entities}条数据')
  
      def query(self, question):
          if self.index is None:
              self.get_index()
          if question.endswith("?") or question.endswith("？"):
              question = question[:-1]
          if self._debug is True:
              contexts = self.query_engine.retrieve(QueryBundle(question))
              for i, context in enumerate(contexts): 
                  print(f'{question}', i)
                  content = context.node.get_content(metadata_mode=MetadataMode.LLM)
                  print(content)
              print('-------------------------------------------------------参考资料---------------------------------------------------------')
          response = self.query_engine.query(question)
          return response
  
      def _list_pipeline_ids(self):
          url = f"https://controller.api.gcp-us-west1.zillizcloud.com/v1/pipelines?projectId={self.ZILLIZ_PROJECT_ID}"
          headers = {
              "Authorization": f"Bearer {self.ZILLIZ_TOKEN}",
              "Accept": "application/json",
              "Content-Type": "application/json",
          }
  
          collection_name = self.config.milvus.collection_name
          response = requests.get(url, headers=headers)
          if response.status_code != 200:
              raise RuntimeError(response.text)
          response_dict = response.json()
          if response_dict["code"] != 200:
              raise RuntimeError(response_dict)
          pipeline_ids = []
          for pipeline in response_dict['data']: 
              if collection_name in  pipeline['name']:
                  pipeline_ids.append(pipeline['pipelineId'])
              
          return pipeline_ids
  
      def _delete_pipeline_ids(self, pipeline_ids):
          for pipeline_id in pipeline_ids:
              url = f"https://controller.api.gcp-us-west1.zillizcloud.com/v1/pipelines/{pipeline_id}/"
              headers = {
                  "Authorization": f"Bearer {self.ZILLIZ_TOKEN}",
                  "Accept": "application/json",
                  "Content-Type": "application/json",
              }
  
              response = requests.delete(url, headers=headers)
              if response.status_code != 200:
                  raise RuntimeError(response.text)
  
  
apis: llama_index.postprocessor.MetadataReplacementPostProcessor llama_index.readers.file.flat_reader.FlatReader llama_index.prompts.ChatMessage llama_index.ServiceContext.from_defaults llama_index.StorageContext.from_defaults llama_index.VectorStoreIndex llama_index.SimpleDirectoryReader llama_index.VectorStoreIndex.from_vector_store llama_index.llms.OpenAI llama_index.embeddings.HuggingFaceEmbedding llama_index.vector_stores.MilvusVectorStore llama_index.prompts.ChatPromptTemplate llama_index.postprocessor.SentenceTransformerRerank llama_index.set_global_service_context llama_index.indices.query.schema.QueryBundle
extract_api: [((2448, 2465), 'requests.get', 'requests.get', (['url'], {}), '(url)\n', (2460, 2465), False, 'import requests\n'), ((2063, 2076), 'urllib.parse.urlparse', 'urlparse', (['url'], {}), '(url)\n', (2071, 2076), False, 'from urllib.parse import urlparse\n'), ((3032, 3049), 'requests.get', 'requests.get', (['url'], {}), '(url)\n', (3044, 3049), False, 'import requests\n'), ((4423, 4477), 'llama_index.embeddings.HuggingFaceEmbedding', 'HuggingFaceEmbedding', ([], {'model_name': 'config.embedding.name'}), '(model_name=config.embedding.name)\n', (4443, 4477), False, 'from llama_index.embeddings import HuggingFaceEmbedding\n'), ((5451, 5513), 'llama_index.ServiceContext.from_defaults', 'ServiceContext.from_defaults', ([], {'llm': 'llm', 'embed_model': 'embed_model'}), '(llm=llm, embed_model=embed_model)\n', (5479, 5513), False, 'from llama_index import ServiceContext, StorageContext\n'), ((5522, 5565), 'llama_index.set_global_service_context', 'set_global_service_context', (['service_context'], {}), '(service_context)\n', (5548, 5565), False, 'from llama_index import set_global_service_context\n'), ((5647, 5714), 'llama_index.postprocessor.SentenceTransformerRerank', 'SentenceTransformerRerank', ([], {'model': 'config.rerank.name', 'top_n': 'rerank_k'}), '(model=config.rerank.name, top_n=rerank_k)\n', (5672, 5714), False, 'from llama_index.postprocessor import SentenceTransformerRerank\n'), ((5955, 6132), 'llama_index.vector_stores.MilvusVectorStore', 'MilvusVectorStore', ([], {'uri': 'f"""http://{config.milvus.host}:{config.milvus.port}"""', 'collection_name': 'config.milvus.collection_name', 'overwrite': 'overwrite', 'dim': 'config.embedding.dim'}), "(uri=f'http://{config.milvus.host}:{config.milvus.port}',\n    collection_name=config.milvus.collection_name, overwrite=overwrite, dim\n    =config.embedding.dim)\n", (5972, 6132), False, 'from llama_index.vector_stores import MilvusVectorStore\n'), ((6938, 6993), 'llama_index.StorageContext.from_defaults', 'StorageContext.from_defaults', ([], {'vector_store': 'vector_store'}), '(vector_store=vector_store)\n', (6966, 6993), False, 'from llama_index import ServiceContext, StorageContext\n'), ((7084, 7160), 'llama_index.VectorStoreIndex', 'VectorStoreIndex', (['nodes'], {'storage_context': 'storage_context', 'show_progress': '(True)'}), '(nodes, storage_context=storage_context, show_progress=True)\n', (7100, 7160), False, 'from llama_index import VectorStoreIndex, SimpleDirectoryReader, Document\n'), ((7240, 7391), 'llama_index.vector_stores.MilvusVectorStore', 'MilvusVectorStore', ([], {'uri': 'f"""http://{config.milvus.host}:{config.milvus.port}"""', 'collection_name': 'config.milvus.collection_name', 'dim': 'config.embedding.dim'}), "(uri=f'http://{config.milvus.host}:{config.milvus.port}',\n    collection_name=config.milvus.collection_name, dim=config.embedding.dim)\n", (7257, 7391), False, 'from llama_index.vector_stores import MilvusVectorStore\n'), ((7450, 7511), 'llama_index.VectorStoreIndex.from_vector_store', 'VectorStoreIndex.from_vector_store', ([], {'vector_store': 'vector_store'}), '(vector_store=vector_store)\n', (7484, 7511), False, 'from llama_index import VectorStoreIndex, SimpleDirectoryReader, Document\n'), ((8241, 8296), 'llama_index.prompts.ChatPromptTemplate', 'ChatPromptTemplate', ([], {'message_templates': 'message_templates'}), '(message_templates=message_templates)\n', (8259, 8296), False, 'from llama_index.prompts import ChatPromptTemplate, ChatMessage, MessageRole, PromptTemplate\n'), ((9980, 10010), 'os.getenv', 'os.getenv', (['"""ZILLIZ_CLUSTER_ID"""'], {}), "('ZILLIZ_CLUSTER_ID')\n", (9989, 10010), False, 'import os\n'), ((10039, 10064), 'os.getenv', 'os.getenv', (['"""ZILLIZ_TOKEN"""'], {}), "('ZILLIZ_TOKEN')\n", (10048, 10064), False, 'import os\n'), ((10098, 10128), 'os.getenv', 'os.getenv', (['"""ZILLIZ_PROJECT_ID"""'], {}), "('ZILLIZ_PROJECT_ID')\n", (10107, 10128), False, 'import os\n'), ((11138, 11193), 'llama_index.ServiceContext.from_defaults', 'ServiceContext.from_defaults', ([], {'llm': 'llm', 'embed_model': 'None'}), '(llm=llm, embed_model=None)\n', (11166, 11193), False, 'from llama_index import ServiceContext, StorageContext\n'), ((11249, 11292), 'llama_index.set_global_service_context', 'set_global_service_context', (['service_context'], {}), '(service_context)\n', (11275, 11292), False, 'from llama_index import set_global_service_context\n'), ((14123, 14178), 'llama_index.prompts.ChatPromptTemplate', 'ChatPromptTemplate', ([], {'message_templates': 'message_templates'}), '(message_templates=message_templates)\n', (14141, 14178), False, 'from llama_index.prompts import ChatPromptTemplate, ChatMessage, MessageRole, PromptTemplate\n'), ((16170, 16204), 'requests.get', 'requests.get', (['url'], {'headers': 'headers'}), '(url, headers=headers)\n', (16182, 16204), False, 'import requests\n'), ((2283, 2304), 'os.path.basename', 'os.path.basename', (['url'], {}), '(url)\n', (2299, 2304), False, 'import os\n'), ((4568, 4662), 'custom.llms.QwenLLM.QwenUnofficial', 'QwenUnofficial', ([], {'temperature': 'config.llm.temperature', 'model': 'config.llm.name', 'max_tokens': '(2048)'}), '(temperature=config.llm.temperature, model=config.llm.name,\n    max_tokens=2048)\n', (4582, 4662), False, 'from custom.llms.QwenLLM import QwenUnofficial\n'), ((6573, 6593), 'os.path.isfile', 'os.path.isfile', (['path'], {}), '(path)\n', (6587, 6593), False, 'import os\n'), ((8020, 8082), 'llama_index.prompts.ChatMessage', 'ChatMessage', ([], {'content': 'QA_SYSTEM_PROMPT', 'role': 'MessageRole.SYSTEM'}), '(content=QA_SYSTEM_PROMPT, role=MessageRole.SYSTEM)\n', (8031, 8082), False, 'from llama_index.prompts import ChatPromptTemplate, ChatMessage, MessageRole, PromptTemplate\n'), ((8096, 8158), 'llama_index.prompts.ChatMessage', 'ChatMessage', ([], {'content': 'QA_PROMPT_TMPL_STR', 'role': 'MessageRole.USER'}), '(content=QA_PROMPT_TMPL_STR, role=MessageRole.USER)\n', (8107, 8158), False, 'from llama_index.prompts import ChatPromptTemplate, ChatMessage, MessageRole, PromptTemplate\n'), ((10611, 10705), 'custom.llms.QwenLLM.QwenUnofficial', 'QwenUnofficial', ([], {'temperature': 'config.llm.temperature', 'model': 'config.llm.name', 'max_tokens': '(2048)'}), '(temperature=config.llm.temperature, model=config.llm.name,\n    max_tokens=2048)\n', (10625, 10705), False, 'from custom.llms.QwenLLM import QwenUnofficial\n'), ((11702, 11913), 'custom.zilliz.base.ZillizCloudPipelineIndex', 'ZillizCloudPipelineIndex', ([], {'project_id': 'self.ZILLIZ_PROJECT_ID', 'cluster_id': 'self.ZILLIZ_CLUSTER_ID', 'token': 'self.ZILLIZ_TOKEN', 'collection_name': 'config.pipeline.collection_name', 'service_context': 'service_context'}), '(project_id=self.ZILLIZ_PROJECT_ID, cluster_id=self\n    .ZILLIZ_CLUSTER_ID, token=self.ZILLIZ_TOKEN, collection_name=config.\n    pipeline.collection_name, service_context=service_context)\n', (11726, 11913), False, 'from custom.zilliz.base import ZillizCloudPipelineIndex\n'), ((12376, 12447), 'pymilvus.MilvusClient', 'MilvusClient', ([], {'uri': 'self.ZILLIZ_CLUSTER_ENDPOINT', 'token': 'self.ZILLIZ_TOKEN'}), '(uri=self.ZILLIZ_CLUSTER_ENDPOINT, token=self.ZILLIZ_TOKEN)\n', (12388, 12447), False, 'from pymilvus import MilvusClient\n'), ((13902, 13964), 'llama_index.prompts.ChatMessage', 'ChatMessage', ([], {'content': 'QA_SYSTEM_PROMPT', 'role': 'MessageRole.SYSTEM'}), '(content=QA_SYSTEM_PROMPT, role=MessageRole.SYSTEM)\n', (13913, 13964), False, 'from llama_index.prompts import ChatPromptTemplate, ChatMessage, MessageRole, PromptTemplate\n'), ((13978, 14040), 'llama_index.prompts.ChatMessage', 'ChatMessage', ([], {'content': 'QA_PROMPT_TMPL_STR', 'role': 'MessageRole.USER'}), '(content=QA_PROMPT_TMPL_STR, role=MessageRole.USER)\n', (13989, 14040), False, 'from llama_index.prompts import ChatPromptTemplate, ChatMessage, MessageRole, PromptTemplate\n'), ((17063, 17100), 'requests.delete', 'requests.delete', (['url'], {'headers': 'headers'}), '(url, headers=headers)\n', (17078, 17100), False, 'import requests\n'), ((4728, 4819), 'custom.llms.GeminiLLM.Gemini', 'Gemini', ([], {'temperature': 'config.llm.temperature', 'model_name': 'config.llm.name', 'max_tokens': '(2048)'}), '(temperature=config.llm.temperature, model_name=config.llm.name,\n    max_tokens=2048)\n', (4734, 4819), False, 'from custom.llms.GeminiLLM import Gemini\n'), ((6292, 6312), 'os.path.exists', 'os.path.exists', (['path'], {}), '(path)\n', (6306, 6312), False, 'import os\n'), ((6657, 6676), 'os.path.isdir', 'os.path.isdir', (['path'], {}), '(path)\n', (6670, 6676), False, 'import os\n'), ((9436, 9457), 'llama_index.indices.query.schema.QueryBundle', 'QueryBundle', (['question'], {}), '(question)\n', (9447, 9457), False, 'from llama_index.indices.query.schema import QueryBundle\n'), ((10771, 10862), 'custom.llms.GeminiLLM.Gemini', 'Gemini', ([], {'model_name': 'config.llm.name', 'temperature': 'config.llm.temperature', 'max_tokens': '(2048)'}), '(model_name=config.llm.name, temperature=config.llm.temperature,\n    max_tokens=2048)\n', (10777, 10862), False, 'from custom.llms.GeminiLLM import Gemini\n'), ((11007, 11113), 'llama_index.llms.OpenAI', 'OpenAI', ([], {'api_base': 'api_base', 'temperature': 'config.llm.temperature', 'model': 'config.llm.name', 'max_tokens': '(2048)'}), '(api_base=api_base, temperature=config.llm.temperature, model=config.\n    llm.name, max_tokens=2048)\n', (11013, 11113), False, 'from llama_index.llms import OpenAI\n'), ((15313, 15334), 'llama_index.indices.query.schema.QueryBundle', 'QueryBundle', (['question'], {}), '(question)\n', (15324, 15334), False, 'from llama_index.indices.query.schema import QueryBundle\n'), ((4209, 4248), 're.findall', 're.findall', (['"""[^,.;。？！]+[,.;。？！]?"""', 'text'], {}), "('[^,.;。？！]+[,.;。？！]?', text)\n", (4219, 4248), False, 'import re\n'), ((4876, 5033), 'custom.llms.proxy_model.ProxyModel', 'ProxyModel', ([], {'model_name': 'config.llm.name', 'api_base': 'config.llm.api_base', 'api_key': 'config.llm.api_key', 'temperature': 'config.llm.temperature', 'max_tokens': '(2048)'}), '(model_name=config.llm.name, api_base=config.llm.api_base,\n    api_key=config.llm.api_key, temperature=config.llm.temperature,\n    max_tokens=2048)\n', (4886, 5033), False, 'from custom.llms.proxy_model import ProxyModel\n'), ((5320, 5426), 'llama_index.llms.OpenAI', 'OpenAI', ([], {'api_base': 'api_base', 'temperature': 'config.llm.temperature', 'model': 'config.llm.name', 'max_tokens': '(2048)'}), '(api_base=api_base, temperature=config.llm.temperature, model=config.\n    llm.name, max_tokens=2048)\n', (5326, 5426), False, 'from llama_index.llms import OpenAI\n'), ((6460, 6470), 'pathlib.Path', 'Path', (['path'], {}), '(path)\n', (6464, 6470), False, 'from pathlib import Path\n'), ((7821, 7883), 'llama_index.postprocessor.MetadataReplacementPostProcessor', 'MetadataReplacementPostProcessor', ([], {'target_metadata_key': '"""window"""'}), "(target_metadata_key='window')\n", (7853, 7883), False, 'from llama_index.postprocessor import MetadataReplacementPostProcessor\n'), ((6437, 6449), 'llama_index.readers.file.flat_reader.FlatReader', 'FlatReader', ([], {}), '()\n', (6447, 6449), False, 'from llama_index.readers.file.flat_reader import FlatReader\n'), ((6693, 6713), 'os.path.exists', 'os.path.exists', (['path'], {}), '(path)\n', (6707, 6713), False, 'import os\n'), ((6838, 6865), 'llama_index.SimpleDirectoryReader', 'SimpleDirectoryReader', (['path'], {}), '(path)\n', (6859, 6865), False, 'from llama_index import VectorStoreIndex, SimpleDirectoryReader, Document\n'), ((13579, 13601), 'os.path.basename', 'os.path.basename', (['path'], {}), '(path)\n', (13595, 13601), False, 'import os\n')]