Notes
Add notes to resources within AI Library agent
, knowledgebase
, or file
.
The spirit of notes is to provide a way to add comments, feedback, or any other information to a resource.
Notes can have three roles - assistant
, user
, or system
. This helps in identifying the source of the note for transparency and accountability.
Notes provide a meta field to store custom json data. This can be used to store additional information about the note.
Possible use cases:
- Save a generation from an AI model, add a comment to it, and then refer to it later
- Save a generation as an article with a json containing meta data about the article like title, seo description, etc. This can then be used to display the article in a blog or website on your website
- Add a note to a knowledgebase or file to provide context or additional information
Add a Note
Add a note to a resource.
Request body
- Name
content
- Type
- string
- Required
- required
- Description
Content of the note
- Name
role
- Type
- string
- Required
- required
- Description
Role of the note. Can be
assistant
,user
orsystem
.
- Name
resource
- Type
- string
- Required
- required
- Description
Resource of the note. Can be
agent
,knowledgebase
orfile
- Name
resource_id
- Type
- string
- Required
- required
- Description
ID of the resource
- For agent, it is
namespace
- For knowledgebase, it is
knowledgeId
- For file, it is
id
- For agent, it is
- Name
meta
- Type
- string
- Required
- optional
- Description
Custom json value
Request
{
"content": "hello",
"role": "assistant", //assistant, user, system
"resource": "agent",
"resource_id": "my-agent-namespace",
"meta": "{'id':'1'}" // custom json value
}
Response
{
"content": "hello",
"role": "assistant",
"resource": "agent",
"resource_id": "my-agent-namespace",
"meta": "{'id':'1'}" // custom json value
}
Get Notes
Get notes for a resource.
Request parameters
- Name
resource
- Type
- string
- Required
- required
- Description
Resource of the note. Can be
agent
,knowledgebase
orfile
- Name
resource_id
- Type
- string
- Required
- required
- Description
ID of the resource For agent, it is the
namespace
For knowledgebase, it is theknowledgeId
For file, it is thefileId
Request
import requests
url = "https://api.ailibrary.ai/v1/notes/agent/my-agent-namespace"
headers = {
"X-Library-Key": "<your-api-key>"
}
response = requests.request("GET", url, headers=headers)
Response
[
{
"notes": [
{
"content": "hello",
"created_timestamp": "2025-01-09 13:05:03",
"noteId": "fcaca8a1-049c-4441-b69a-326ef221b9dd",
"resource": "agent",
"resource_id": "my-agent-namespace",
"role": "assistant",
"updated_timestamp": "2025-01-09 13:05:03",
"userEmail": "arani@ailibrary.ai",
"userName": "Arani Chaudhuri"
},
//...
],
"meta": {
"current_page": 1,
"limit": 50,
"next_page": "",
"prev_page": "",
"total_items": 1,
"total_pages": 1
}
}
]
Update a Note
Update a note.
Request parameters
- Name
noteId
- Type
- string
- Required
- required
- Description
ID of the note
Request body
- Name
content
- Type
- string
- Required
- required
- Description
Content of the note
- Name
role
- Type
- string
- Required
- required
- Description
Role of the note. Can be
assistant
,user
orsystem
.
- Name
meta
- Type
- string
- Required
- optional
- Description
Custom json value
Request
{
"content": "hello",
"role": "assistant", //assistant, user, system
"meta": "{'id':'1'}" // custom json value
}
Response
{
"status": "success",
"message": "Note updated successfully"
}
Get a Note
Get a note by ID.
Request parameters
- Name
noteId
- Type
- string
- Required
- required
- Description
ID of the note
Request
import requests
url = "https://api.ailibrary.ai/v1/notes/my-agent-namespace"
headers = {
"X-Library-Key": "<your-api-key>"
}
response = requests.request("GET", url, headers=headers)
Response
{
"content": "hello",
"created_timestamp": "2025-01-09 13:05:03",
"meta": {
"id": "1"
},
"noteId": "fcaca8a1-049c-4441-b69a-326ef221b9dd",
"resource": "agent",
"resource_id": "my-agent-namespace",
"role": "assistant",
"updated_timestamp": "2025-01-09 13:05:03",
"userEmail": "arani@ailibrary.ai",
"userName": "Arani Chaudhuri"
}
Delete Notes
Delete all notes in a specific resource. For example, detele all notes in an agent, knowledgebase, or file.
Request parameters
- Name
resource
- Type
- string
- Required
- required
- Description
Resource of the note. Can be
agent
,knowledgebase
orfile
- Name
resourceId
- Type
- string
- Required
- required
- Description
ID of the resource For agent, it is the
namespace
For knowledgebase, it is theknowledgeId
For file, it is thefileId
Request body
- Name
values
- Type
- array
- Required
- optional
- Description
List of
noteIds
to delete corresponding to the resource and resourceId
- Name
delete_all
- Type
- boolean
- Required
- optional
- Description
true
to delete all sources.
Request
import requests
url = "https://api.ailibrary.ai/v1/notes/agent/my-agent-namespace"
body = {
"delete_all": true,
"values": [
"fcaca8a1-049c-4441-b69a-326ef221b9dd",
//...
]
}
headers = {
"X-Library-Key": "<your-api-key>"
}
response = requests.request("DELETE", url, headers=headers)
Response
{
"status": "success",
"message": "Notes deleted successfully"
}
Delete a Note
Delete a note.
Request parameters
- Name
noteId
- Type
- string
- Required
- required
- Description
ID of the note
Request
import requests
url = "https://api.ailibrary.ai/v1/notes/my-agent-namespace"
headers = {
"X-Library-Key": "<your-api-key>"
}
response = requests.request("DELETE", url, headers=headers)
Response
{
"message": "Note deleted successfully"
}