Summarization uses a Select AI profile to summarize inline text or content available from a URI. The profile supplies the AI provider, model, credential, and generation settings. The summarize APIs are available on both Profile and AsyncProfile.

Use one content source per call:

  • content for inline text.

  • location_uri for content available from a URL, object storage URI, or supported file location.

Use credential_name when the location_uri requires a database credential, such as object storage access. Use prompt to guide what the summary should focus on.

1. Inline content

profile = select_ai.Profile(profile_name="oci_ai_profile")

summary = profile.summarize(
    content="Long text to summarize...",
    prompt="Summarize the key business implications.",
)
print(summary)

2. Content from a URI

profile = select_ai.Profile(profile_name="oci_ai_profile")

summary = profile.summarize(
    location_uri="https://en.wikipedia.org/wiki/Astronomy",
)
print(summary)

3. Content from object storage

Pass credential_name when the target location requires authentication:

profile = select_ai.Profile(profile_name="oci_ai_profile")

summary = profile.summarize(
    location_uri=(
        "https://objectstorage.us-ashburn-1.oraclecloud.com/"
        "n/namespace/b/bucket/o/document.txt"
    ),
    credential_name="OBJECT_STORE_CRED",
)
print(summary)

4. Summary parameters

Use SummaryParams to control output length, output style, chunk processing, and extractiveness:

params = select_ai.summary.SummaryParams(
    min_words=50,
    max_words=150,
    summary_style=select_ai.summary.Style.LIST,
    chunk_processing_method=(
        select_ai.summary.ChunkProcessingMethod.MAP_REDUCE
    ),
    extractiveness_level=select_ai.summary.ExtractivenessLevel.MEDIUM,
)

summary = profile.summarize(
    content="Long text to summarize...",
    params=params,
)

5. Async summary

async_profile = await select_ai.AsyncProfile(
    profile_name="async_oci_ai_profile",
)

summary = await async_profile.summarize(
    content="Long text to summarize...",
    prompt="Summarize the main points.",
)
print(summary)

6. Validation

summarize requires exactly one of content or location_uri. Passing both, or passing neither, raises an error.

6.1. SummaryParams

class select_ai.summary.SummaryParams(min_words: int | None = None, max_words: int | None = None, summary_style: Style | None = None, chunk_processing_method: ChunkProcessingMethod | None = None, extractiveness_level: ExtractivenessLevel | None = None)

Customize summary generation using these parameters

Parameters:
  • min_words (int) – approximate minimum number of words the generated summary is expected to contain.

  • max_words (int) – approximate maximum number of words the generated summary is expected to contain.

  • summary_style (select_ai.summary.Style) – Specifies the format style for the summary

  • chunk_processing_method (select_ai.summary.ChunkProcessingMethod) – When the text exceeds the token limit that the LLM can process, it must be split into manageable chunks

  • extractiveness_level (select_ai.summary.ExtractivenessLevel) – Determines how closely the summary follows the original wording of the input

6.2. ChunkProcessingMethod

class select_ai.summary.ChunkProcessingMethod(*values)

When the text exceeds the token limit that the LLM can process, it must be split into manageable chunks. This parameter enables you to choose the method for processing these chunks - ChunkProcessingMethod.ITERATIVE_REFINEMENT - ChunkProcessingMethod.MAP_REDUCE

6.3. ExtractivenessLevel

class select_ai.summary.ExtractivenessLevel(*values)

Determines how closely the summary follows the original wording of the input. It controls the degree to which the model extracts versus rephrases it. The following are the options: - ExtractivenessLevel.LOW - ExtractivenessLevel.MEDIUM - ExtractivenessLevel.HIGH

6.4. SummaryStyle

class select_ai.summary.Style(*values)

Specifies the format style for the summary. The following are the available summary format options: - Style.PARAGRAPH - the summary is presented in one or more paragraphs. - Style.LIST - the summary is a list of key points from the text.