What is Knowledeg Base?

The Knowledge Base feature in the Upsonic framework serves as a critical component that supplies essential task-related data to the LLM during its analysis and processing operations. By providing relevant information to either task-performing agents or direct LLM calls, this feature significantly enhances the probability of successful task completion.

A notable advantage of the Knowledge Base feature is its seamless integration with context compression, optimizing the handling of large datasets. The framework implements this functionality through two distinct types of knowledge bases 

  • The one that directly provides the data that needs to be kept and analyzed alongside each prompt.

  • Knowledge bases that exist as tools that the LLM can search when needed.

While both groups have their own benefits, especially in cases requiring RAG (Retrieval-Augmented Generation), and when dealing with large or unstructured data, the LLM (Large Language Model) will return more successful results since it determines the search query by itself.

Key benefits of using Knowledge:

  • Enhance agents for domain-specific situations

  • Enhance decisions with real-world data

Creating an Knowledge Base

To create a knowledge base, it’s sufficient to directly import the KnowledgeBase class. Then, we will create an object belonging to this class and add it to the context list within the Task. KnowledgeBase works compatibly with every place where context can be used.

from upsonic import KnowledgeBase

resume_list = KnowledgeBase(
  files=["resume1.pdf", "resume2.pdf"]
)

For file-Based Knowledge Sources, make sure to place your files in a current work directory. Also, you can use full path.

Put a Knowledge Base into to Task

You can easily add the KnowledgeBase object you created to any task’s context list. The Agent or LLM will evaluate these contexts while performing operations.

from upsonic import Task

task1 = Task(
  "Summerize the resumes",

  context=[resume_list] # Adding Knowledge Base to the task
)

Supported Formats

Supported Files

  • - PDF

  • - PowerPoint

  • - Word

  • - Excel

  • - Images

  • - Audio

  • - HTML

  • - CSV

  • - JSON

  • - XML

  • - ZIP

Supported Variables

  • - STRING