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: ```
  Query for cited answers
  ```
docstr_tok: ["``","`","Query","for","cited","answers","``","`"]
code: def query(
      self,
      query: str,
      k: int = 10,
      max_sources: int = 5,
      length_prompt: str = "about 100 words",
      marginal_relevance: bool = True,
      answer=None,
      key_filter: Optional[bool] = None,
      show_token_usage=False,
      # get_callbacks: Callable[[str], AsyncCallbackHandler] = lambda x: [],
  ):
      """
      ```
      Query for cited answers
      ```
      """
      try:
          result = self.docs.query(
              query=query,
              k=k,
              max_sources=max_sources,
              length_prompt=length_prompt,
              marginal_relevance=marginal_relevance,
              answer=answer,
              key_filter=key_filter,
          )
          if not show_token_usage:
              result.formatted_answer = result.formatted_answer.split(
                  "Tokens Used"
              )[0]
          return result
      except RuntimeError:
          raise Exception(
              "There was a RuntimeError - try addding  the following to the top of your notebook:\nimport nest_asyncio\nnest_asyncio.apply()"
          )
  
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 6 for calling the GenerativeQA obj's underlying member method code with example usage: obj.query(query, k, max_sources, length_prompt, marginal_relevance, answer, key_filter, show_token_usage) and returns: result