Skip to content

Latest commit

 

History

History
690 lines (460 loc) · 61.8 KB

File metadata and controls

690 lines (460 loc) · 61.8 KB

Beta.Rag.SearchIndexes

Overview

Available Operations

register

Register (or re-register) a search index

Example Usage

from mistralai.client import Mistral
import os


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

    res = mistral.beta.rag.search_indexes.register(name="<value>", index={
        "type": "vespa",
        "k8s_cluster": "<value>",
        "k8s_namespace": "<value>",
        "vespa_instance_name": "<value>",
        "vespa_version": "<value>",
        "schemas": [
            {
                "name": "<value>",
                "fields": [],
                "sd": "<value>",
            },
        ],
        "query_url": "https://shiny-range.com/",
    }, status="offline")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
name str ✔️ N/A
index models.RegisterSearchIndexRequestIndexIndex ✔️ N/A
status Optional[models.RegisterSearchIndexRequestIndexStatus] N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.RegisterSearchIndexResponseIndex

Errors

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

get_index_summaries

Fetch summary view of all indexes available to a user

Example Usage

from mistralai.client import Mistral
import os


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

    res = mistral.beta.rag.search_indexes.get_index_summaries()

    # Handle response
    print(res)

Parameters

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

Response

List[models.GetSearchIndexSummaryResponseIndex]

Errors

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

unregister

Delete all information about an index

Example Usage

from mistralai.client import Mistral
import os


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

    res = mistral.beta.rag.search_indexes.unregister(index_id="0e59f390-f2e4-428e-a81c-c9c2f2ced09e")

    # Handle response
    print(res)

Parameters

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

Response

Any

Errors

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

update_index_metrics

Update the metrics for a given index

Example Usage

from mistralai.client import Mistral
import os


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

    res = mistral.beta.rag.search_indexes.update_index_metrics(index_id="cb562a81-38ce-49a7-86ec-592676de32a8", request_body={
        "status": "online",
        "document_count": 864436,
        "schema_metrics": [
            {
                "name": "<value>",
                "document_count": 109412,
            },
        ],
    })

    # Handle response
    print(res)

Parameters

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

Response

Any

Errors

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

get_index_detail

Get a detailed view of the stored data for a single index

Example Usage

from mistralai.client import Mistral
import os


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

    res = mistral.beta.rag.search_indexes.get_index_detail(index_id="f6ffec01-1f00-47ec-bf94-a08bdc049edc")

    # Handle response
    print(res)

Parameters

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

Response

models.GetSearchIndexDetailResponseIndex

Errors

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

get_index_summary

Retrieve the summary field for an index if it exists

Example Usage

from mistralai.client import Mistral
import os


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

    res = mistral.beta.rag.search_indexes.get_index_summary(index_id="d83e93f2-1d03-4133-90d2-fae51463c71e", language="pt_br")

    # Handle response
    print(res)

Parameters

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

Response

models.GetSummaryResponseSummary

Errors

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

generate_index_summary

Streams a summary for the index in chunks of json.

The first chunk contains metadata for the summary, the following contain chunks of 'content' that should be joined together to form a full summary.

Example Usage

from mistralai.client import Mistral
import os


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

    res = mistral.beta.rag.search_indexes.generate_index_summary(index_id="b0cfd77c-9cc3-46b6-ad70-1024386259b9", language="pl")

    with res as jsonl_stream:
        for event in jsonl_stream:
            # handle event
            print(event, flush=True)

Parameters

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

Response

Union[jsonl.JsonLStream[models.GenerateIndexSummaryV1RagIndexesIndexIndexIDSummaryFieldLanguagePostSummaryStreamTypes], jsonl.JsonLStreamAsync[models.GenerateIndexSummaryV1RagIndexesIndexIndexIDSummaryFieldLanguagePostSummaryStreamTypes]]

Errors

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

set_index_summary

Update the summary field for an index

Example Usage

from mistralai.client import Mistral
import os


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

    res = mistral.beta.rag.search_indexes.set_index_summary(index_id="e199a723-75b3-43fe-98fb-5d576435c591", language="pt_br", content="<value>", status="handwritten", translated=True)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
index_id str ✔️ N/A
language models.SetIndexSummaryV1RagIndexesIndexIndexIDSummaryFieldLanguagePutLanguage ✔️ N/A
content str ✔️ N/A
status models.UpdateSummaryRequestSummaryStatus ✔️ N/A
translated bool ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

Any

Errors

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

get_schema_summary

Retrieve the summary field for a schema if it exists

Example Usage

from mistralai.client import Mistral
import os


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

    res = mistral.beta.rag.search_indexes.get_schema_summary(index_id="077fb72c-10cd-442d-832e-51fd35136195", schema_id="39f80401-7fc3-4ade-8b1c-b2cd613bab20", language="en")

    # Handle response
    print(res)

Parameters

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

Response

models.GetSummaryResponseSummary

Errors

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

generate_schema_summary

Streams a summary for the schema in chunks of json.

The first chunk contains metadata for the summary, the following contain chunks of 'content' that should be joined together to form a full summary.

Example Usage

from mistralai.client import Mistral
import os


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

    res = mistral.beta.rag.search_indexes.generate_schema_summary(index_id="582076c8-276e-4a50-b7a6-2f266925a448", schema_id="5c471724-f36e-41cc-a302-af4f92ea7413", language="it")

    with res as jsonl_stream:
        for event in jsonl_stream:
            # handle event
            print(event, flush=True)

Parameters

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

Response

Union[jsonl.JsonLStream[models.GenerateSchemaSummaryPostV1RagIndexesIndexIndexIDSchemasSchemaSchemaIDSummaryFieldLanguagePostSummaryStreamTypes], jsonl.JsonLStreamAsync[models.GenerateSchemaSummaryPostV1RagIndexesIndexIndexIDSchemasSchemaSchemaIDSummaryFieldLanguagePostSummaryStreamTypes]]

Errors

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

set_schema_summary

Update the summary field for an index

Example Usage

from mistralai.client import Mistral
import os


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

    res = mistral.beta.rag.search_indexes.set_schema_summary(index_id="d22ebdfa-6465-4f25-9a27-3e59d85ee544", schema_id="cc29f795-986b-483d-a658-acb000a16f70", language="nl", content="<value>", status="generated_confirmed", translated=True)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
index_id str ✔️ N/A
schema_id str ✔️ N/A
language models.SetSchemaSummaryV1RagIndexesIndexIndexIDSchemasSchemaSchemaIDSummaryFieldLanguagePutLanguage ✔️ N/A
content str ✔️ N/A
status models.UpdateSummaryRequestSummaryStatus ✔️ N/A
translated bool ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

Any

Errors

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

get_index_schema_detail

Get a detailed view of the stored information for a schema

Example Usage

from mistralai.client import Mistral
import os


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

    res = mistral.beta.rag.search_indexes.get_index_schema_detail(index_id="af850b81-3290-4f41-83af-f0d2ac1b070d", schema_id="fc2825a7-a8ef-4bec-9729-f7486e8327cb")

    # Handle response
    print(res)

Parameters

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

Response

models.GetSearchIndexSchemaDetailResponseSchemaModel

Errors

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

get_index_schema_file

Get Index Schema File

Example Usage

from mistralai.client import Mistral
import os


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

    res = mistral.beta.rag.search_indexes.get_index_schema_file(index_id="252c6de5-4c9b-43b5-8c30-54524a59cb57", schema_id="93166e46-2e3c-4b20-b9a5-8607304372d2")

    # Handle response
    print(res)

Parameters

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

Response

models.GetSearchIndexSchemaSDFileResponseSDFile

Errors

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

document_lookup

Fetch stored information about a retrievable element stored in an index

Example Usage

from mistralai.client import Mistral
import os


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

    res = mistral.beta.rag.search_indexes.document_lookup(index_id="77308a24-2d8e-4392-9ab4-38770b2bb993", schema_id="1fe735e7-4ec0-4264-b715-12a944fe2b87", document_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
index_id str ✔️ N/A
schema_id str ✔️ N/A
document_id str ✔️ the native ID in the underlying index
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.VespaGetRetrievableResponseRetrievable

Errors

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

documents_fetch

Fetch a few stored retrievable elements from the index/schema

Example Usage

from mistralai.client import Mistral
import os


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

    res = mistral.beta.rag.search_indexes.documents_fetch(index_id="7c9f7007-1a54-48fd-b6da-93e91f31f6aa", schema_id="7eb7703c-1b80-4ecc-8a8b-288b43e1f30e")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
index_id str ✔️ N/A
schema_id str ✔️ N/A
group_id OptionalNullable[str] Only retrieve from this group
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

List[models.VespaGetRetrievableResponseRetrievable]

Errors

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