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

POSThttps://api.ailibrary.ai/v1/notes

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 or system.

  • Name
    resource
    Type
    string
    Required
    required
    Description

    Resource of the note. Can be agent, knowledgebase or file

  • 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
  • Name
    meta
    Type
    string
    Required
    optional
    Description

    Custom json value

Request

POST
/v1/notes
{
    "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
}

GEThttps://api.ailibrary.ai/v1/notes/{resource}/{resource_id}

Get Notes

Get notes for a resource.

Request parameters

  • Name
    resource
    Type
    string
    Required
    required
    Description

    Resource of the note. Can be agent, knowledgebase or file

  • Name
    resource_id
    Type
    string
    Required
    required
    Description

    ID of the resource For agent, it is the namespace For knowledgebase, it is the knowledgeId For file, it is the fileId

Request

GET
/v1/notes/{resource}/{resource_id}
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
        }
    }
]

PUThttps://api.ailibrary.ai/v1/notes/{noteId}

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 or system.

  • Name
    meta
    Type
    string
    Required
    optional
    Description

    Custom json value

Request

PUT
/v1/notes/{noteId}
{
    "content": "hello",
    "role": "assistant", //assistant, user, system
    "meta": "{'id':'1'}" // custom json value
}

Response

{
    "status": "success",
    "message": "Note updated successfully"
}

GEThttps://api.ailibrary.ai/v1/notes/{noteId}

Get a Note

Get a note by ID.

Request parameters

  • Name
    noteId
    Type
    string
    Required
    required
    Description

    ID of the note

Request

GET
/v1/notes/{noteId}
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"
}

DELETEhttps://api.ailibrary.ai/v1/notes/{resource}/{resourceId}

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 or file

  • Name
    resourceId
    Type
    string
    Required
    required
    Description

    ID of the resource For agent, it is the namespace For knowledgebase, it is the knowledgeId For file, it is the fileId

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

DELETE
/v1/notes/{resource}/{resourceId}
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"
}

DELETEhttps://api.ailibrary.ai/v1/notes/{noteId}

Delete a Note

deprecated

Delete a note.

Request parameters

  • Name
    noteId
    Type
    string
    Required
    required
    Description

    ID of the note

Request

DELETE
/v1/notes/{noteId}
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"
}

Was this page helpful?