Skip to content

Latest commit

 

History

History
272 lines (177 loc) · 26 KB

File metadata and controls

272 lines (177 loc) · 26 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.
  • libraries_update_v1 - Update a library. ⚠️ Deprecated

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] : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

Deprecated: this parameter will be removed in a future version.
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] : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

The size of the chunks (in characters) to split document text into. Must be between 256 and 32768.
owner_type OptionalNullable[models.OwnerType] Determines who owns the created library. 'User' creates a private library accessible only to its owner. 'Workspace' creates a library shared with the workspace. Defaults to 'Workspace' for API key sessions. Only API keys with the 'Private and shared connectors' connector access scope can create private, user-owned libraries.
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. Warning: the response will change from 200 (returning the deleted library) to 204 No Content in a future version.

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="74a30b7a-ba52-49f7-a8a3-7157e1adf565")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
library_id str ✔️ N/A
name Optional[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 */*

libraries_update_v1

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

⚠️ DEPRECATED: Use the PATCH method instead. This PUT endpoint will be removed in a future version..

Example Usage

from mistralai.client import Mistral
import os


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

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

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
library_id str ✔️ N/A
name Optional[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 */*