Knowledge studio is a document management studio built to help teams curate and maintain the content powering the shared knowledge base.
With Knowledge studio, you can:
- Organize documents used in agent responses
- Select and manage what’s included in the shared knowledge base
- Keep knowledge updated and consistent over time
In the steps below, you will learn how to upload documents and refresh the Knowledge base the Agent relies on through Knowledge studio.
Before you begin, make sure you are logged in and that your account has the necessary permissions to access the Agent builder and make changes.
Step 1: Navigate to the Knowledge section and click + Upload new document to start the setup process.
Here you will make sure that you upload the document of interest, input information such as version, document name, select agent(s) that should have access to this document, description and custom metadata fields that can be used for filtering.
Important notes
- The agent that you assign the documentation to MUST have a skill defined, including retriever_tool (you may find an example of the definition in the section “Retriever tool definition example”). This enables the agent to perform flexible and semantic search through RAG on top of the provided documentation.
- The document version is suitable in case there are two documents with the same name.
- Document name may be arbitrary and is used to have a better overview of all available documents and make distinction when and where needed.
Here is an example of upload document inputs.
Once you are done, click on Upload file.
Step 2. Click on Refresh knowledge button, in order to trigger the pipeline for data processing so that the uploaded document is parsed and ready for use. You won’t be able to click on this button for another ~10 minutes, because the pipeline is ran in the background and there is a control check enabled not to trigger the pipeline multiple times at the same time.
Note: This step is mandatory, otherwise the agent won’t be aware of the new documents.
Once your documents are ready - you will be informed via email, and after that you will be able to test the agent you assigned the documentation to and ask queries related to uploaded documentation.
Once you receive this email - you agent is ready for use!
Step 3. Test the agent
This is the response of the agent before uploading the document and refreshing the knowledge.
This is the answer after the new documentation is uploaded, assigned to the specific agent, and the knowledge base gets refreshed.
Editing and deletion of document(s)
You can delete a document or multiple documents at once, as well as edit a specific document and its fields.
How to delete a document or multiple documents
To delete a specific document, go to Knowledge section and find it within the tables where all documents are listed. Go to actions and click on Delete.
To delete multiple documents at once, click on Trash bin icon and select the documents you would like to delete.
How to edit a document
To edit a specific document, go to Knowledge section and find it within the tables where all documents are listed. Go to actions and click on Edit.
Note: after every edit/delete action, you must click on Refresh knowledge, in order to have the latest updates available.
Retriever tool definition example
class RetrieverToolTS(Tool):
@property
def name(self):
return "knowledge_retriever_tool"
@property
def description(self):
return "Get a list of documents based on the provided query."
@property
def parameters(self):
return {
"type": "object",
"properties": {
"keyword_query": {
"type": "string",
"description": "The query for the keyword search for documents.",
},
"semantic_query": {
"type": "string",
"description": "The query for the semantic search for documents.",
},
},
"required": ["keyword_query", "semantic_query"],
}
@staticmethod
def bold_text(s):
bold_map = {
"0":"𝟬","1":"𝟭","2":"𝟮","3":"𝟯","4":"𝟰","5":"𝟱","6":"𝟲","7":"𝟳","8":"𝟴","9":"𝟵"
}
return "".join(bold_map.get(c, c) for c in s)
async def __call__(self, keyword_query, semantic_query):
try:
tool_resource = "documents"
filters = details.get().get("filters", {})
tenant_id = settings.get().get("tenant_id")
agent_id = settings.get().get("agent_id")
authorization = user.get().get("authorization")
retrieval_api_url = "https://app-eu.workforcehub.ai/api/latest/retrieval-api"
filter_rules = filters.get("rules", {}) if filters.get("resource") == tool_resource else {}
async with httpx.AsyncClient() as client:
response = await client.get(url=f"{retrieval_api_url}/resources/{tool_resource}",
params={"keyword_query": keyword_query, "semantic_query": semantic_query,
"keyword_n_results": 3, "semantic_n_results": 3, **filter_rules,
"agents": agent_id},
headers={"Authorization": authorization, "Ts-Tenant-ID": tenant_id})
if response.status_code == 200:
content = response.json()
documents = {"documents": [{"content": f"[Reference {i+1}]: {document.get('content')}"} for i, document in enumerate(content.get("documents"))]}
context_documents = {"documents": [{"content": RetrieverToolTS.bold_text(f"[𝗥𝗲𝗳𝗲𝗿𝗲𝗻𝗰𝗲 {i + 1}]: ") + document.get('content')} for i, document in enumerate(content.get("documents"))]}
else:
logger.error(f"Failed to retrieve documents with status code: {response.status_code}")
documents = {"documents": []}
context.set(context_documents)
return documents
except Exception as error:
message = "Failed to use retrieval tool"
logger.error(f"{message} with error: {error}")
return message
Comments
0 comments
Please sign in to leave a comment.