class_docstr: Question-answering using OpenAI or open-source GPT or GPT-like generative LLM models
class_docstr_tok: ["Question-answering","using","OpenAI","or","open-source","GPT","or","GPT-like","generative","LLM","models"]
docstr: ```
  Add documents to the data store
  
  Args:
    path(str): Path to the document.  Mutually-exclusive with text parameter.
    text(str): text of document. Mutually-exclusive with path parameter.
    citation(str):  The citation for document that will appear in references below answer.
                    If omitted, the LLM will be used to infer the correct citation from the document text.
    key(str): The key for the document that will appear within the body of the answer when referenced.
              If omitted, the LLM will be used to infer the correct citaiton from the document text.
    disable_check(bool): A check of the text of the document.
    chunk_chars(int): This is how many characters documents are split into.
  
  Returns:
    None
  ```
docstr_tok: ["``","`","Add","documents","to","the","data","store","Args",":","path","(","str",")",":","Path","to","the","document",".","Mutually-exclusive","with","text","parameter",".","text","(","str",")",":","text","of","document",".","Mutually-exclusive","with","path","parameter",".","citation","(","str",")",":","The","citation","for","document","that","will","appear","in","references","below","answer",".","If","omitted",",","the","LLM","will","be","used","to","infer","the","correct","citation","from","the","document","text",".","key","(","str",")",":","The","key","for","the","document","that","will","appear","within","the","body","of","the","answer","when","referenced",".","If","omitted",",","the","LLM","will","be","used","to","infer","the","correct","citaiton","from","the","document","text",".","disable_check","(","bool",")",":","A","check","of","the","text","of","the","document",".","chunk_chars","(","int",")",":","This","is","how","many","characters","documents","are","split","into",".","Returns",":","None","``","`"]
code: def add_doc(
      self,
      path: Optional[str] = None,
      text: Optional[str] = None,
      citation: Optional[str] = None,
      key: Optional[str] = None,
      disable_check: bool = True,
      chunk_chars: Optional[int] = 3000,
  ):
      """
      ```
      Add documents to the data store
  
      Args:
        path(str): Path to the document.  Mutually-exclusive with text parameter.
        text(str): text of document. Mutually-exclusive with path parameter.
        citation(str):  The citation for document that will appear in references below answer.
                        If omitted, the LLM will be used to infer the correct citation from the document text.
        key(str): The key for the document that will appear within the body of the answer when referenced.
                  If omitted, the LLM will be used to infer the correct citaiton from the document text.
        disable_check(bool): A check of the text of the document.
        chunk_chars(int): This is how many characters documents are split into.
  
      Returns:
        None
      ```
      """
      if (path is not None and text is not None) or (
          path is None and text is None
      ):
          raise ValueError(
              "The path and text parameters are mutually-exclusive and exactly one must be supplied."
          )
      if (
          path is not None
          and not path.lower().endswith(".pdf")
          and not path.lower().endswith(".txt")
      ):
          raise ValueError(
              "Currently, the path parameter only accepts files that end with either a .pdf or .txt extension."
          )
  
      if text is not None:
          import os
          import tempfile
  
          fd, fpath = tempfile.mkstemp()
          os.rename(fpath, fpath + ".txt")
          fpath = fpath + ".txt"
          try:
              with os.fdopen(fd, "w") as tmp:
                  # do stuff with temp file
                  tmp.write(text)
              key, citation = self.default_key_and_citation(
                  fpath, key=key, citation=citation
              )
              self.add_doc(
                  fpath,
                  citation=citation,
                  key=key,
                  disable_check=disable_check,
                  chunk_chars=chunk_chars,
              )
          finally:
              pass
          return
      key, citation = self.default_key_and_citation(
          path, key=key, citation=citation
      )
      self.docs.add(
          path=path,
          citation=citation,
          key=key,
          disable_check=disable_check,
          chunk_chars=chunk_chars,
      )
      return
  
file_path: ktrain/ktrain/text/qa/generative_qa.py
imports: import sys
  import os
  import pickle
  from typing import Optional
  from pathlib import Path
label_desc: Use image node_id 5 for calling the GenerativeQA obj's underlying member method code with example usage: obj.add_doc(path, text, citation, key, disable_check, chunk_chars) without return types