Phrazor SDK
Get API KeyPhrazor API
  • 👋Welcome
  • Docs
    • ⚡Quick Start
    • 🔑Get your API Key
    • Documentation
      • 📥Download and Import
      • 🔗Connect your Data
      • 🛠️Setup your Analysis
        • Descriptor
        • Change
        • Trend
        • Compare
        • Target vs Achievement
        • Budget vs Expense
        • Others
          • Filter your Data
      • 📋Generate your Insights
      • 📝Generate your Summary
      • 🔌Integrations
      • 💣Rate Limits
Powered by GitBook
On this page
  • Set OpenAI API Key
  • Get Summary
  • Output Response
  • Examples
  1. Docs
  2. Documentation

Generate your Summary

Explains how to create summary reports or narratives from the insights.

Set OpenAI API Key

To generate a summary of topics or analysis you need to set OpenAI API Key.

You can set the OpenAI API key as given below:

import phrazor
phrazor.OPENAI_KEY = '<OPENAI API KEY>'

Summary Generation won't work without setting up the OpenAI API Key.

Get Summary

The get_summary method is designed to allows users to obtain a summarized overview of either a specific set of topics or of generated insights within an analysis, all with the flexibility to customize the level of verbosity and the intended personality in the output. Whether you're working with a complex analysis or a collection of topics, this function simplifies the process of extracting key takeaways.

User can even provide a custom prompt to OpenAI to generate a customized summary of their own.

Method Signature:

get_summary(
    on: Union[list, str], focus_on_value: Union[list, str] = None, 
    compare_value_1: str = None, compare_value_2: str = None, 
    personality: str = 'default', verbosity: str = 'low',
    custom_prompt: str = ''
) -> dict

Parameter
Type
Description

on

list/str

Analysis Name/Topics that are to be used to create a summary. This is the most important parameter of the function. Analysis Name Accepted Values : "descriptor","change","trend", "compare_measure",compare_dimension, "target","budget"

It should be passed as a string.

focus_on_value

list/str

Narrow down the analysis to a specific value/values within the chosen dimension. Enables you to target a particular data point. For Example, If dimension is set as "Region", specifying focus_on_value as "South" will direct the function to specifically analyze and summarize feedback related to South Region. It can be either a string or list of values. It is an optional parameter.

compare_value_1

str

Used to contrast or compare against the value provided in compare_value_2. To be used with compare_dimension analysis and topics like compare_by_contribution, compare_by_performance and compare_by_rank. Should be kept blank for other analyses and topics.

compare_value_2

str

Used to contrast or compare against the value provided in compare_value_1. To be used with compare_dimension analysis and topics like compare_by_contribution, compare_by_performance and compare_by_rank. Should be kept blank for other analyses and topics.

personality

str

Allows you to define a specific personality or audience for whom the generated summaries are tailored. By specifying a personality, you can adapt the tone, style, and content of the output to match the preferences and needs of the intended audience. Some examples of personality can be "Product Manager", "Marketing Manager","Sales Manager". It is an optional parameter.

verbosity

str

Provides control over the level of detail in the generated summaries. You can adjust this parameter to choose between concise, high-level summaries or more detailed, comprehensive summaries, depending on your requirements. Default: low Accepted Values: low,medium,high It is an optional parameter.

custom_prompt

str

Allows you to provide a custom instruction or prompt to guide the summary generation process which is sent to OpenAI. It is an optional parameter.

Output Response

{
  "sections": [
    {
      "summary": "<Summary>",
      "name": "<Metric Name>"
    }
  ],
  "time_taken": <Time Taken>
}
Key
Type
Description

sections

list

Contains multiple dictionaries for each metric that is passed.

summary

str

Summary for the analysis/topics that is selected.

name

str

Name of the metric for which the summary is generated.

time_taken

float

Time taken for generation(in seconds).

Examples

Summary by Analysis

In the snippet given below, a basic code block has been added to generate a summary for Change analysis.

import phrazor

phrazor.API_KEY = 'YOUR API KEY'
phrazor.OPENAI_KEY = 'YOUR OPENAI API KEY'
phrzr = phrazor.Phrazor()


phrzr.set_data(<YOUR DATA>)

phrzr.set_column_meta(
    date_column="<DATE COLUMN>", 
    metric_column="<METRIC COLUMN>", 
    dimension_column="<DIMENSION COLUMN>"
)

summary = phrzr.get_summary(on="change")

print(summary)

Similarly we can add a focus_on_value parameter in the get_summary function call to get summary on a specified data point.

summary = phrzr.get_summary(on="change", focus_on_value=["<Val 1>"])

Summary by Topics

In the snippet given below, a basic code block has been added to generate a summary for topics of Descriptor analysis.

import phrazor

phrazor.API_KEY = 'YOUR API KEY'
phrazor.OPENAI_KEY = 'YOUR OPENAI API KEY'
phrzr = phrazor.Phrazor()


phrzr.set_data(<YOUR DATA>)

phrzr.set_column_meta(
    date_column="<DATE COLUMN>", 
    metric_column="<METRIC COLUMN>", 
    dimension_column="<DIMENSION COLUMN>"
)

summary = phrzr.get_summary(
    on=["best_performing","least_contribution","top_ranked"],
    verbosity:"high",
    personality:"Sales Manager"
)

print(summary)

Similarly for topics that are selected for Compare Analysis we can pass which values should be compared. Lets say we want to compare Sales of East and West Region then code would look something like:

phrzr.set_column_meta(
    date_column="Date", 
    metric_column="Sales", 
    dimension_column="Region"
)
              
summary = phrzr.get_summary(
    on=["compare_by_performance","compare_by_rank"],
    compare_value_1="East",
    compare_value_2="West"
)

print(summary)
PreviousGenerate your InsightsNextIntegrations

Last updated 1 year ago

Topics can take the values that are fetched from methods. All topics should belong to same analysis. It should be pass as a list.

Run function before generating summary by topic to get the list of topics that can be passed.

📝
show_topics
show_topics