Skip to main content
Ctrl+K

SlideDeck AI documentation

  • Installation
  • Usage
  • Models
  • LLM Configuration and Propagation Flow
  • API Reference
  • Installation
  • Usage
  • Models
  • LLM Configuration and Propagation Flow
  • API Reference

Section Navigation

Core Modules and Classes

  • slidedeckai.cli
    • slidedeckai.cli.format_model_help
    • slidedeckai.cli.format_models_as_bullets
    • slidedeckai.cli.format_models_list
    • slidedeckai.cli.group_models_by_provider
    • slidedeckai.cli.main
    • slidedeckai.cli.CustomArgumentParser
    • slidedeckai.cli.CustomHelpFormatter
  • slidedeckai.core
    • slidedeckai.core.SlideDeckAI
  • slidedeckai.helpers.chat_helper
    • slidedeckai.helpers.chat_helper.AIMessage
    • slidedeckai.helpers.chat_helper.ChatMessage
    • slidedeckai.helpers.chat_helper.ChatMessageHistory
    • slidedeckai.helpers.chat_helper.ChatPromptTemplate
    • slidedeckai.helpers.chat_helper.HumanMessage
  • slidedeckai.helpers.file_manager
    • slidedeckai.helpers.file_manager.get_pdf_contents
    • slidedeckai.helpers.file_manager.validate_page_range
  • slidedeckai.helpers.icons_embeddings
    • slidedeckai.helpers.icons_embeddings.find_icons
    • slidedeckai.helpers.icons_embeddings.get_embeddings
    • slidedeckai.helpers.icons_embeddings.get_icons_list
    • slidedeckai.helpers.icons_embeddings.load_saved_embeddings
    • slidedeckai.helpers.icons_embeddings.main
    • slidedeckai.helpers.icons_embeddings.save_icons_embeddings
  • slidedeckai.helpers.image_search
    • slidedeckai.helpers.image_search.extract_dimensions
    • slidedeckai.helpers.image_search.get_image_from_url
    • slidedeckai.helpers.image_search.get_photo_url_from_api_response
    • slidedeckai.helpers.image_search.search_pexels
  • slidedeckai.helpers.llm_helper
    • slidedeckai.helpers.llm_helper.get_langchain_llm
    • slidedeckai.helpers.llm_helper.get_litellm_llm
    • slidedeckai.helpers.llm_helper.get_litellm_model_name
    • slidedeckai.helpers.llm_helper.get_provider_model
    • slidedeckai.helpers.llm_helper.is_valid_llm_provider_model
    • slidedeckai.helpers.llm_helper.stream_litellm_completion
  • slidedeckai.helpers.pptx_helper
    • slidedeckai.helpers.pptx_helper.add_bulleted_items
    • slidedeckai.helpers.pptx_helper.format_text
    • slidedeckai.helpers.pptx_helper.generate_powerpoint_presentation
    • slidedeckai.helpers.pptx_helper.get_flat_list_of_contents
    • slidedeckai.helpers.pptx_helper.get_slide_placeholders
    • slidedeckai.helpers.pptx_helper.print_slide_layouts
    • slidedeckai.helpers.pptx_helper.remove_slide_number_from_heading
  • slidedeckai.helpers.text_helper
    • slidedeckai.helpers.text_helper.fix_malformed_json
    • slidedeckai.helpers.text_helper.get_clean_json
    • slidedeckai.helpers.text_helper.is_valid_prompt
  • API Reference
  • slidedeckai.helpers.image_search

slidedeckai.helpers.image_search#


Search photos using Pexels API.

extract_dimensions

Extracts the height and width from the URL parameters.

get_image_from_url

Fetches an image from the specified URL and returns it as a BytesIO object.

get_photo_url_from_api_response

Return a randomly chosen photo from a Pexels search API response.

search_pexels

Searches for images on Pexels using the provided query.

Search photos using Pexels API.

slidedeckai.helpers.image_search.extract_dimensions(url: str) → tuple[int, int][source]#

Extracts the height and width from the URL parameters.

Parameters:

url – The URL containing the image dimensions.

Returns:

A tuple containing the width and height as integers.

slidedeckai.helpers.image_search.get_image_from_url(url: str) → BytesIO[source]#

Fetches an image from the specified URL and returns it as a BytesIO object.

This function sends a GET request to the provided URL, retrieves the image data, and wraps it in a BytesIO object, which can be used like a file.

Parameters:

url – The URL of the image to be fetched.

Returns:

A BytesIO object containing the image data.

Raises:

requests.exceptions.RequestException – If the request to the URL fails.

slidedeckai.helpers.image_search.get_photo_url_from_api_response(json_response: dict) → tuple[str | None, str | None][source]#

Return a randomly chosen photo from a Pexels search API response. In addition, also return the original URL of the page on Pexels.

Parameters:

json_response – The JSON response.

Returns:

The selected photo URL and page URL or None. Empty tuple if no photos found or API key is not set.

slidedeckai.helpers.image_search.search_pexels(query: str, size: Literal['small', 'medium', 'large'] = 'medium', per_page: int = 3) → dict[source]#

Searches for images on Pexels using the provided query.

This function sends a GET request to the Pexels API with the specified search query and authorization header containing the API key. It returns the JSON response from the API.

[2024-08-31] Note: curl succeeds but API call via Python requests fail. Apparently, this could be due to Cloudflare (or others) blocking the requests, perhaps identifying as Web-scraping. So, changing the user-agent to Firefox. https://stackoverflow.com/a/74674276/147021 https://stackoverflow.com/a/51268523/147021 https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox#linux

Parameters:
  • query – The search query for finding images.

  • size – The size of the images: small, medium, or large.

  • per_page – No. of results to be displayed per page.

Returns:

The JSON response from the Pexels API containing search results. Empty dict if API key is not set.

Raises:

requests.exceptions.RequestException – If the request to the Pexels API fails.

previous

slidedeckai.helpers.icons_embeddings.save_icons_embeddings

next

slidedeckai.helpers.image_search.extract_dimensions

On this page
  • extract_dimensions()
  • get_image_from_url()
  • get_photo_url_from_api_response()
  • search_pexels()

This Page

  • Show Source

© Copyright 2025, Barun Saha.

Created using Sphinx 8.1.3.

Built with the PyData Sphinx Theme 0.16.1.