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
Below are some common parameters used by many functions in this section.
Common Parameters
- Name
role
- Type
- string
- Required
- optional
- Description
Role of the note. Can be
assistant
,user
, orsystem
- Name
resource
- Type
- string
- Required
- optional
- Description
Resource of the note. Can be
agent
,knowledgebase
orfile
- Name
resource_id
- Type
- string
- Required
- optional
- Description
ID of the resource. If
resource=agent
, resource_id is the namespace of the agent Ifresource=knowledgebase
, resource_id is the knowledgeId of the agent Ifresource=file
, resource_id is the file_id of the agent
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
See "Common Parameters" at the start of this section.
- Name
resource
- Type
- string
- Required
- required
- Description
See "Common Parameters" at the start of this section.
- Name
resource_id
- Type
- string
- Required
- required
- Description
See "Common Parameters" at the start of this section.
- 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
{"status": "success", "noteId": "note_xyz789"}
Get Notes From Resource
Get notes for a resource.
Request parameters
- Name
resource
- Type
- string
- Required
- required
- Description
See "Common Parameters" at the start of this section.
- Name
resource_id
- Type
- string
- Required
- required
- Description
See "Common Parameters" at the start of this section.
Request
notes = client.notes.get_resource_notes(
resource="agent",
resource_id="agent_abc123"
)
Response
{
"notes": [
{
"content": "note content",
"created_timestamp": "YYYY-MM-DD hh:mm:ss",
"meta": {"type": "internal"},
"role": "user"
}
],
"meta": {"page": 1, "limit": 10}
}
Update a Note
Update a note.
Request parameters
- Name
note_id
- Type
- integer
- Required
- required
- Description
ID of the note
Request body
- Name
content
- Type
- string
- Required
- required
- Description
New content of the note
- Name
role
- Type
- string
- Required
- required
- Description
See "Common Parameters" at the start of this section.
- 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",
"meta": {"type": "update"}
}
Get a Note
Get a note by ID.
Request parameters
- Name
note_id
- Type
- integer
- Required
- required
- Description
ID of the note
Request
note = client.notes.get(note_id="note_xyz789")
Response
{
"content": "note content",
"created_timestamp": "YYYY-MM-DD hh:mm:ss",
"noteId": "note_xyz789",
"resource": "agent",
"resource_id": "agent_name",
"role": "user",
"updated_timestamp": "YYYY-MM-DD hh:mm:ss",
"userEmail": "username@email.com",
"userName": "FirstName LastName",
"meta": {"type": "internal"}
}
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
See "Common Parameters" at the start of this section.
- Name
resourceId
- Type
- string
- Required
- required
- Description
See "Common Parameters" at the start of this section.
Request body
- Name
values
- Type
- array
- Required
- optional
- Description
List of
note_ids
to delete corresponding to the resource and resourceId. Ifvalues
is not specified thendelete_all=True
must be specified. If both are specified thendelete_all
takes precedence.
- Name
delete_all
- Type
- boolean
- Required
- optional
- Description
Deletes all source if
delete_all=True
. Ifdelete_all
is not specified then values must be specified. If both are specified thendelete_all
takes precedence.
Request
response = client.notes.delete_notes(
resource="agent",
resource_id="agent_abc123",
values=["note_xyz789"], # or use delete_all=True
)
Response
{
"status": "success",
"message": "Notes deleted successfully"
}