{"version":3,"file":"vectorstore.cjs","names":["Tool","VectorDBQAChain"],"sources":["../../src/tools/vectorstore.ts"],"sourcesContent":["import type { BaseLanguageModelInterface } from \"@langchain/core/language_models/base\";\nimport type { VectorStoreInterface } from \"@langchain/core/vectorstores\";\nimport { Tool } from \"@langchain/core/tools\";\nimport { VectorDBQAChain } from \"../chains/vector_db_qa.js\";\n\n/**\n * Interface for tools that interact with a Vector Store.\n */\ninterface VectorStoreTool {\n  vectorStore: VectorStoreInterface;\n  llm: BaseLanguageModelInterface;\n}\n\n/**\n * A tool for the VectorDBQA chain to interact with a Vector Store. It is\n * used to answer questions about a specific topic. The input to this tool\n * should be a fully formed question.\n */\nexport class VectorStoreQATool extends Tool implements VectorStoreTool {\n  static lc_name() {\n    return \"VectorStoreQATool\";\n  }\n\n  vectorStore: VectorStoreInterface;\n\n  llm: BaseLanguageModelInterface;\n\n  name: string;\n\n  description: string;\n\n  chain: VectorDBQAChain;\n\n  constructor(name: string, description: string, fields: VectorStoreTool) {\n    super(...arguments);\n    this.name = name;\n    this.description = description;\n    this.vectorStore = fields.vectorStore;\n    this.llm = fields.llm;\n    this.chain = VectorDBQAChain.fromLLM(this.llm, this.vectorStore);\n  }\n\n  /**\n   * Returns a string that describes what the tool does.\n   * @param name The name of the tool.\n   * @param description A description of what the tool does.\n   * @returns A string that describes what the tool does.\n   */\n  static getDescription(name: string, description: string): string {\n    return `Useful for when you need to answer questions about ${name}. Whenever you need information about ${description} you should ALWAYS use this. Input should be a fully formed question.`;\n  }\n\n  /** @ignore */\n  async _call(input: string) {\n    return this.chain.run(input);\n  }\n}\n"],"mappings":";;;;;;;;;AAkBA,IAAa,oBAAb,cAAuCA,sBAAAA,KAAgC;CACrE,OAAO,UAAU;AACf,SAAO;;CAGT;CAEA;CAEA;CAEA;CAEA;CAEA,YAAY,MAAc,aAAqB,QAAyB;AACtE,QAAM,GAAG,UAAU;AACnB,OAAK,OAAO;AACZ,OAAK,cAAc;AACnB,OAAK,cAAc,OAAO;AAC1B,OAAK,MAAM,OAAO;AAClB,OAAK,QAAQC,qBAAAA,gBAAgB,QAAQ,KAAK,KAAK,KAAK,YAAY;;;;;;;;CASlE,OAAO,eAAe,MAAc,aAA6B;AAC/D,SAAO,sDAAsD,KAAK,wCAAwC,YAAY;;;CAIxH,MAAM,MAAM,OAAe;AACzB,SAAO,KAAK,MAAM,IAAI,MAAM"}