Skip to main content
Version: v5.0

KnowledgeBase

A KnowledgeBase contains the converted vectorized embeddings of a file you upload to the File Service. Equip your agents with relevant KnowledgeBases to give them more context during RAG.

File types#

Currently, the following file types​ are supported:

  • .txt
  • .md
  • .csv
  • .pdf

Creating and equipping a KnowledgeBase#

  1. Upload a file to File Service, for example, using IafFileSvc.addFileResumable.
    const file = fs.createReadStream(filePath);const options = { headers: { "Content-Type": "application/pdf" }};const fileObj = IafFileSvc.addFileResumable(file, ctx, options);
  2. Create the KnowledgeBase with IafAISvc.createKnowledgeBases and reference the created file and version:
    const kb = {   _name: 'Warranty Docs',   _fileId: '94a1eb2b-06bd-426e-a3ce-e7ab609ea231',  _fileVersionId: '35a1ab2c-16bd-426e-b3ce-a7ab609ea482',   _userType: 'warranty_documents',   _namespaces: ['ws1'] };const kb = await IafAISvc.createKnowledgeBases(kb, ctx);
  3. Get the KnowledgeBase using IafAISvc.getKnowledgeBase:
    const kb = await IafAISvc.getKnowledgeBase('94a1eb2b-06bd-426e-a3ce-e7ab609ea231', ctx);
  4. Create an agent using IafAISvc.createAgents and equip it with the KnowledgeBase:
    const agent = await IafAISvc.createAgents([{  _name: "Warranty Info Provider",  _background: "You are responsible providing information about warranty data",  _userType: "warranty_info_provider",  _type: "user_agent",  _namespaces: [     "IPUTTheExchange_EleSnXBw"  ],  _config: {    _model: "gpt-4o",    _provider: "openai"  },  _knowledgebases: [    "warranty_documents"  ]}]); 

Notes on KnowledgeBases#

Consider the following restrictions on the use of KnowledgeBases:

  • A maximum of ten KnowledgeBases are allowed
  • Each KnowledgeBase can have a maximum size of 10 MB

Additionally, whereever the agent object is referenced, prefix _config.model and _config.provider with an underscore as shown below.

_config: {  _model: "gpt-4o",  _provider: "openai" }