powerpoint-generative-ai


Namepowerpoint-generative-ai JSON
Version 0.1.7 PyPI version JSON
download
home_pagehttps://github.com/Width-ai/powerpoint-generative-ai
SummaryLibrary written by Width.Ai. Streamlines the utilization of GPT models for automatic PowerPoint content generation. Also offers semantic searches on slide content, enabling you to quickly pinpoint relevant information
upload_time2023-09-20 05:42:26
maintainer
docs_urlNone
authorPatrick Hennis
requires_python
licenseMIT
keywords llm semantic search powerpoints
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PowerPoint-Generative-AI
This library streamlines the utilization of GPT models for automatic PowerPoint content generation. It further offers a class for loading PowerPoints and performing semantic searches on slide content, enabling you to quickly pinpoint relevant information.

## Setup
```
conda create -n 'powerpoint' python=3.10
conda activate powerpoint
pip install -r requirements.txt
```

## How to use
```python
from powerpoint_generative_ai import PowerPointGenerator, PowerPointAnalyzer


# set up two classes
ppt_gen = PowerPointGenerator(openai_key="...", model="gpt-4")
ppt_analyzer = PowerPointAnalyzer(openai_key="...", pinecone_key="...", pinecone_index="...", pinecone_env="...")


# Prompts to generate powerpoints for
USER_TEXTS = [
"""create a six slide powerpoint about the growing obesity rate and its effect on health insurance premiums. here is some data for a chart:
x axis: 2010, 2012, 2014, 2016, 2018, 2020, 2022, 2024
US: 5%, 10%, 15%, 20%, 25%, 30%, 35%, 40%
UK: 3%, 6%, 9%, 12%, 15%, 18%, 21%, 24%
RU: 2%, 4%, 6%, 8%, 10%, 12%, 14%, 16%
FR: 7%, 14%, 21%, 28%, 35%, 42%, 49%, 56%
IT: 1%, 2%, 3%, 4%, 5%, 6%, 7%, 8%""",
"""Create a five slide powerpoint about street racing in america, here is some data about insurance claims related to street racing in america for a bar chart:
x axis: 2010, 2012, 2014, 2016, 2018, 2020, 2022, 2024
insurance claims: 12, 84, 100, 103, 109, 114, 120, 127"""
]

# generate powerpoints
powerpoint_files = [ppt_gen.create_powerpoint(user_input=user_text) for user_text in USER_TEXTS]

# load powerpoints into pinecone
ppt_analyzer.load(file_paths=powerpoint_files)

# search on the slides indexed in pinecone and return the metadata metadata
relevant_slides = ppt_analyzer.search_for_relevant_slides(query="insurance rates")
```

## Custom Embeddings Function
By default, `PowerPointAnalyzer` utilizes OpenAI's `text-embedding-ada-002` embeddings. However, an optional parameter `custom_embeddings_function` allows the use of a user-defined embeddings solution in place of OpenAI's.

This function should follow the following signature:
```python

def custom_embeddings_function(texts: List[str]) -> List:
    # The function takes in a list of strings to calculate the embeddings for
    # ...
    # Return a list of lists that represent the embeddings of the input texts


# This can then be used when instantiating an analyzer class like this
ppt_analyzer = PowerPointAnalyzer(openai_key="...", pinecone_key="...", pinecone_index="...", pinecone_env="...", custom_embeddings_function=custom_embeddings_function)
```

## Generating Alt-Text for Images
The `PowerPointGenerator` has a function `create_alt_text_for_powerpoint`. It takes two parameters; `ppt_path` (the path to the powerpoint) and `device`. The `device` param has a few options, namely (`cuda`, `mps`, `cpu`). The function generates alt-text for images, sets them as the `descr` attribute (alt text), then saves them back to the path it read it from. Here is an example snippet using the function:

```python
from powerpoint_generative_ai.ppt_generator import PowerPointGenerator
ppt_gen = PowerPointGenerator(openai_key="...", model="gpt-4")
ppt_gen.create_alt_text_for_powerpoint(ppt_path="/path/to/slide_deck.pptx", device="mps")
```

The generated captions will also be logged for the user to see what has been generated.


## Cleaning up index
```python
ppt_analyzer.pinecone_index.delete(delete_all=True)
ppt_analyzer.pinecone_index.describe_index_stats()
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Width-ai/powerpoint-generative-ai",
    "name": "powerpoint-generative-ai",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "LLM,Semantic Search,PowerPoints",
    "author": "Patrick Hennis",
    "author_email": "patrick@width.ai",
    "download_url": "https://github.com/Width-ai/powerpoint-generative-ai/archive/refs/tags/v0.1.7.tar.gz",
    "platform": null,
    "description": "# PowerPoint-Generative-AI\nThis library streamlines the utilization of GPT models for automatic PowerPoint content generation. It further offers a class for loading PowerPoints and performing semantic searches on slide content, enabling you to quickly pinpoint relevant information.\n\n## Setup\n```\nconda create -n 'powerpoint' python=3.10\nconda activate powerpoint\npip install -r requirements.txt\n```\n\n## How to use\n```python\nfrom powerpoint_generative_ai import PowerPointGenerator, PowerPointAnalyzer\n\n\n# set up two classes\nppt_gen = PowerPointGenerator(openai_key=\"...\", model=\"gpt-4\")\nppt_analyzer = PowerPointAnalyzer(openai_key=\"...\", pinecone_key=\"...\", pinecone_index=\"...\", pinecone_env=\"...\")\n\n\n# Prompts to generate powerpoints for\nUSER_TEXTS = [\n\"\"\"create a six slide powerpoint about the growing obesity rate and its effect on health insurance premiums. here is some data for a chart:\nx axis: 2010, 2012, 2014, 2016, 2018, 2020, 2022, 2024\nUS: 5%, 10%, 15%, 20%, 25%, 30%, 35%, 40%\nUK: 3%, 6%, 9%, 12%, 15%, 18%, 21%, 24%\nRU: 2%, 4%, 6%, 8%, 10%, 12%, 14%, 16%\nFR: 7%, 14%, 21%, 28%, 35%, 42%, 49%, 56%\nIT: 1%, 2%, 3%, 4%, 5%, 6%, 7%, 8%\"\"\",\n\"\"\"Create a five slide powerpoint about street racing in america, here is some data about insurance claims related to street racing in america for a bar chart:\nx axis: 2010, 2012, 2014, 2016, 2018, 2020, 2022, 2024\ninsurance claims: 12, 84, 100, 103, 109, 114, 120, 127\"\"\"\n]\n\n# generate powerpoints\npowerpoint_files = [ppt_gen.create_powerpoint(user_input=user_text) for user_text in USER_TEXTS]\n\n# load powerpoints into pinecone\nppt_analyzer.load(file_paths=powerpoint_files)\n\n# search on the slides indexed in pinecone and return the metadata metadata\nrelevant_slides = ppt_analyzer.search_for_relevant_slides(query=\"insurance rates\")\n```\n\n## Custom Embeddings Function\nBy default, `PowerPointAnalyzer` utilizes OpenAI's `text-embedding-ada-002` embeddings. However, an optional parameter `custom_embeddings_function` allows the use of a user-defined embeddings solution in place of OpenAI's.\n\nThis function should follow the following signature:\n```python\n\ndef custom_embeddings_function(texts: List[str]) -> List:\n    # The function takes in a list of strings to calculate the embeddings for\n    # ...\n    # Return a list of lists that represent the embeddings of the input texts\n\n\n# This can then be used when instantiating an analyzer class like this\nppt_analyzer = PowerPointAnalyzer(openai_key=\"...\", pinecone_key=\"...\", pinecone_index=\"...\", pinecone_env=\"...\", custom_embeddings_function=custom_embeddings_function)\n```\n\n## Generating Alt-Text for Images\nThe `PowerPointGenerator` has a function `create_alt_text_for_powerpoint`. It takes two parameters; `ppt_path` (the path to the powerpoint) and `device`. The `device` param has a few options, namely (`cuda`, `mps`, `cpu`). The function generates alt-text for images, sets them as the `descr` attribute (alt text), then saves them back to the path it read it from. Here is an example snippet using the function:\n\n```python\nfrom powerpoint_generative_ai.ppt_generator import PowerPointGenerator\nppt_gen = PowerPointGenerator(openai_key=\"...\", model=\"gpt-4\")\nppt_gen.create_alt_text_for_powerpoint(ppt_path=\"/path/to/slide_deck.pptx\", device=\"mps\")\n```\n\nThe generated captions will also be logged for the user to see what has been generated.\n\n\n## Cleaning up index\n```python\nppt_analyzer.pinecone_index.delete(delete_all=True)\nppt_analyzer.pinecone_index.describe_index_stats()\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Library written by Width.Ai. Streamlines the utilization of GPT models for automatic PowerPoint content generation. Also offers semantic searches on slide content, enabling you to quickly pinpoint relevant information",
    "version": "0.1.7",
    "project_urls": {
        "Download": "https://github.com/Width-ai/powerpoint-generative-ai/archive/refs/tags/v0.1.7.tar.gz",
        "Homepage": "https://github.com/Width-ai/powerpoint-generative-ai"
    },
    "split_keywords": [
        "llm",
        "semantic search",
        "powerpoints"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eb9775c6ac356cd7bad820a48830b533cc5f3faf934233ea2221b5e2c7ec90be",
                "md5": "3f78f591626e1bd248f01cd2b3012c81",
                "sha256": "7d5bf630848f115ef2475aa207dca28ffc86859d708d90544edd3a10aa92948c"
            },
            "downloads": -1,
            "filename": "powerpoint_generative_ai-0.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3f78f591626e1bd248f01cd2b3012c81",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14755,
            "upload_time": "2023-09-20T05:42:26",
            "upload_time_iso_8601": "2023-09-20T05:42:26.791868Z",
            "url": "https://files.pythonhosted.org/packages/eb/97/75c6ac356cd7bad820a48830b533cc5f3faf934233ea2221b5e2c7ec90be/powerpoint_generative_ai-0.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-20 05:42:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Width-ai",
    "github_project": "powerpoint-generative-ai",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "powerpoint-generative-ai"
}
        
Elapsed time: 0.14582s