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

  • Name
    resource
    Type
    string
    Required
    optional
    Description

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

  • Name
    resource_id
    Type
    string
    Required
    optional
    Description

    ID of the resource. If resource=agent, resource_id is the namespace of the agent If resource=knowledgebase, resource_id is the knowledgeId of the agent If resource=file, resource_id is the file_id of the agent


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

    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

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

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

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

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

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

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

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

Response

{
    "status": "success",
    "message": "Note updated successfully",
    "meta": {"type": "update"}
}

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

Get a Note

Get a note by ID.

Request parameters

  • Name
    note_id
    Type
    integer
    Required
    required
    Description

    ID of the note

Request

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

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

    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. If values is not specified then delete_all=True must be specified. If both are specified then delete_all takes precedence.

  • Name
    delete_all
    Type
    boolean
    Required
    optional
    Description

    Deletes all source if delete_all=True. If delete_all is not specified then values must be specified. If both are specified then delete_all takes precedence.

Request

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

Was this page helpful?