Create Knowledgebase
The Tror Gen AI SDK empowers you to create and manage knowledge bases that enhance the capabilities of your Large Language Models (LLMs). This knowledge base serves as a source of information for the LLMs, enabling them to deliver more informed and comprehensive responses during chat interactions.
This section outlines the various methods you can utilize to construct your knowledge base within the SDK:
Uploading Files:
This option allows you to directly upload relevant files containing the knowledge you want to incorporate. Here's what's involved:
-
createknowledgebasefile function: This function within the SDK handles file-based knowledge base creation.
-
Arguments:
-
knowledgebasename (str): A clear and descriptive name for your knowledge base.
-
file_paths (List[str]): A list containing the file paths of the documents you want to upload.
-
file_types (List[str]): A list specifying the file types of the uploaded documents (e.g., ["txt", "pdf"]).
-
File Uploads: The function creates a knowledge base using the content of the uploaded files. Ensure the files contain relevant information that aligns with the desired functionalities of your LLMs.
-
Example (uploading a text file and a PDF):
import trorgenai
knowledgebase_name = "Product Documentation"
file_paths = ["user_manual.txt", "technical_specs.pdf"]
file_types = ["txt", "pdf"]
trorgenai.createknowledgebasefile(knowledgebase_name, file_paths, file_types)
Connecting to a SQL Database:
If your knowledge resides in a structured format within a SQL database, you can leverage this method for integration.
-
createknowledgebasesql function: This function facilitates knowledge base creation using data from a SQL server.
-
Arguments:
- knowledgebasename (str): A name for your knowledge base.
- sqlserverdata (dict): A dictionary containing your SQL server connection details and any specific queries to retrieve relevant data. Connection and Data Retrieval: The function establishes a connection to your SQL server using the provided credentials and executes any specified queries to extract the knowledge for your LLM.
Required SQL Data:
The sqlserverdata dictionary requires the following information to establish a connection and retrieve data from your SQL server:
-
"host":
-
"port":
- "username":
- "password":
- "database_schema":
- "schemaname":
Example
import trorgenai
trorgenai.createknowledgebasesql(knowledgebasename,sqldata)
Integrating with Confluence:
For knowledge stored within a Confluence instance, you can utilize this integration method.
-
createknowledgebaseconfluence function: This function enables knowledge base creation by accessing content from your Confluence workspace.
-
Arguments:
- knowledgebasename (str): A name for your knowledge base. confluencedetails (dict): A dictionary containing your Confluence access credentials and details about the specific content you want to integrate (e.g., page IDs or search queries).
- Authorization and Content Selection: The function utilizes the provided Confluence credentials to access your workspace and retrieves the specified content for building your knowledge base.
Required SQL Data:
The confluence dictionary requires the following information to establish a connection and retrieve data from your confluence:
-
"confluence_url":
-
"username":
-
"api_key":
-
"space_key":
Example
import trorgenai
trorgenai.createknowledgebaseconfluence(knowledgebasename,confluencedata)
Choosing the Right Approach:
-
The optimal method for creating your knowledge base depends on the format and location of your existing knowledge.
-
Use file upload for readily available documents on your local system.
-
Choose SQL database integration if your knowledge is stored in a structured format within an SQL server.
-
Leverage Confluence integration if your knowledge resides within your Confluence workspace.