Skip to content

Latest commit

 

History

History
221 lines (142 loc) · 11.2 KB

File metadata and controls

221 lines (142 loc) · 11.2 KB

Libraries

(beta.libraries)

Overview

(beta) Libraries API to create and manage libraries - index your documents to enhance agent capabilities.

Available Operations

  • list - List all libraries you have access to.
  • create - Create a new Library.
  • get - Detailed information about a specific Library.
  • delete - Delete a library and all of it's document.
  • update - Update a library.

list

List all libraries that you have created or have been shared with you.

Example Usage

from mistralai import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.list()

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ListLibraryOut

Errors

Error Type Status Code Content Type
models.SDKError 4XX, 5XX */*

create

Create a new Library, you will be marked as the owner and only you will have the possibility to share it with others. When first created this will only be accessible by you.

Example Usage

from mistralai import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.create(name="<value>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
name str ✔️ N/A
description OptionalNullable[str] N/A
chunk_size OptionalNullable[int] N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.LibraryOut

Errors

Error Type Status Code Content Type
models.HTTPValidationError 422 application/json
models.SDKError 4XX, 5XX */*

get

Given a library id, details information about that Library.

Example Usage

from mistralai import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.get(library_id="d0d23a1e-bfe5-45e7-b7bb-22a4ea78d47f")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
library_id str ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.LibraryOut

Errors

Error Type Status Code Content Type
models.HTTPValidationError 422 application/json
models.SDKError 4XX, 5XX */*

delete

Given a library id, deletes it together with all documents that have been uploaded to that library.

Example Usage

from mistralai import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.delete(library_id="6cad0b6e-fd2e-4d11-a48b-21d30fb7c17a")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
library_id str ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.LibraryOut

Errors

Error Type Status Code Content Type
models.HTTPValidationError 422 application/json
models.SDKError 4XX, 5XX */*

update

Given a library id, you can update the name and description.

Example Usage

from mistralai import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.update(library_id="e01880c3-d0b5-4a29-8b1b-abdb8ce917e4")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
library_id str ✔️ N/A
name OptionalNullable[str] N/A
description OptionalNullable[str] N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.LibraryOut

Errors

Error Type Status Code Content Type
models.HTTPValidationError 422 application/json
models.SDKError 4XX, 5XX */*