Skip to content

Latest commit

 

History

History
225 lines (146 loc) · 15.8 KB

File metadata and controls

225 lines (146 loc) · 15.8 KB

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 its documents.
  • update - Update a library.

list

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

Example Usage

from mistralai.client import Mistral
import os


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

    res = mistral.beta.libraries.list(page_size=100, page=0)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
page_size Optional[int] N/A
page Optional[int] N/A
search OptionalNullable[str] Case-insensitive search on the library name.
filter_owned_by_me OptionalNullable[bool] Filter libraries by whether they were created by the current authenticated identity. Set to true for created by me, false for only libraries shared with me, or None to disable this filter.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ListLibrariesResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.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.client 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.Library

Errors

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

get

Given a library id, details information about that Library.

Example Usage

from mistralai.client 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.Library

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.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.client 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.Library

Errors

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

update

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

Example Usage

from mistralai.client 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.Library

Errors

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