odin_slides package
Submodules
odin_slides.llm_ops module
llm_ops.py - Module for Language Model Operations.
This module provides functions for interacting with language models to perform various tasks, such as summarizing content and generating chat responses for creating or updating slide content.
- Module Functions:
- get_LLM_summarization(word_content, logger):
Get a summarization of the provided word content using a language model.
- get_chat_response(word_content, slideDeck, prompt, logger):
Get a chat response for creating or updating text content for slides.
- Dependencies:
os
requests
json
utils (custom utility functions in utils.py)
- Environment Variables:
ODIN_SLIDES_LLM_API_KEY: API key for accessing the language model services.
Note: This version of odinSlides only supports OpenAI APIs, but future updates will extend support for other LLMs.
- odin_slides.llm_ops.get_LLM_summarization(word_content, logger)
Get a summarization of the provided word content using a language model.
- Args:
word_content (str): The content to be summarized. logger (logging.Logger): The logger object to record any errors.
- Returns:
str or None: The summarized content or None if an error occurs.
- odin_slides.llm_ops.get_chat_response(word_content, slideDeck, prompt, logger)
Get a chat response for creating or updating text content for slides.
- Args:
word_content (str): The word content to consider while generating chat response. slideDeck (list): The existing slide deck represented as a list of dictionaries. prompt (str): The prompt to ask the chatbot. logger (logging.Logger): The logger object to record any errors.
- Returns:
str or None: The chat response or None if an error occurs.
odin_slides.main module
- odin_slides.main.main()
Entry point for the OdinSlides presentation creation tool.
Reads user input from command-line arguments and performs the necessary operations to create or update a PowerPoint presentation based on provided input files or resumes a previously saved session.
- Args:
None
- Returns:
None
odin_slides.presentation module
presentation.py - Module for PowerPoint Presentation Creation.
This module provides functions to create and modify PowerPoint presentations based on provided templates, user input, and language model responses.
- Module Functions:
- find_most_similar_layout(prs, target_name):
Find the most similar layout in the PowerPoint presentation to the target layout name.
- find_content_placeholder(slide):
Find the content placeholder in a slide.
- find_slide_layout_by_name(prs, layout_name):
Find a slide layout by its name in the PowerPoint presentation.
- create_presentation(template_file, slide_content, output_file, logger):
Create a new PowerPoint presentation based on a template and slide content.
- build_slides_with_llm(template_file, word_content, output_file, session_file, logger):
Build slides using a language model (LLM) based on user input.
- Dependencies:
difflib
json
os
pickle
pptx (from python-pptx package)
pptx.enum.shapes.MSO_SHAPE_TYPE
utils (custom utility functions in utils.py)
llm_ops (custom functions in llm_ops.py)
- odin_slides.presentation.build_slides_with_llm(template_file, word_content, output_file, session_file, logger)
Build slides using a language model (LLM) based on user input.
- Args:
template_file (str): The path to the template PowerPoint file. word_content (str): The content for the language model input. output_file (str): The path to save the final PowerPoint presentation. session_file (str): The path to the session file to resume a previously saved session. logger (logging.Logger): The logger object to record any errors.
- odin_slides.presentation.create_presentation(template_file, slide_content, output_file, logger)
Create a new PowerPoint presentation based on a template and slide content.
- Args:
template_file (str): The path to the pptx PowerPoint file to use the template from. slide_content (list): A list of dictionaries representing slide content. output_file (str): The path to save the new PowerPoint presentation. logger (logging.Logger): The logger object to record any errors.
- odin_slides.presentation.find_content_placeholder(slide)
Find the content placeholder in a slide.
- Args:
slide (pptx.slide.Slide): The slide to search for the content placeholder.
- Returns:
pptx.shapes.placeholder.Placeholder or None: The content placeholder if found, else None.
- odin_slides.presentation.find_most_similar_layout(prs, target_name)
Find the most similar layout in the PowerPoint presentation to the target layout name.
- Args:
prs (pptx.Presentation): The PowerPoint presentation object. target_name (str): The name of the layout to find.
- Returns:
pptx.slide.SlideLayout or None: The most similar layout if found, else None.
- odin_slides.presentation.find_slide_layout_by_name(prs, layout_name)
Find a slide layout by its name in the PowerPoint presentation.
- Args:
prs (pptx.Presentation): The PowerPoint presentation object. layout_name (str): The name of the layout to find.
- Returns:
pptx.slide.SlideLayout or None: The slide layout if found, else None.
odin_slides.utils module
utils.py - Module for Utility Functions.
This module provides utility functions used in the PowerPoint presentation creation process, including formatting messages with colors, setting up a debug logger, and reading Word files.
- Module Functions:
- format_prompt(message):
Format the given message as a cyan-colored prompt.
- format_info(message):
Format the given message as a green-colored information.
- format_warning(message):
Format the given message as a yellow-colored warning.
- format_error(message):
Format the given message as a red-colored error.
- setup_debug_logger(debug_mode):
Setup and configure a debug logger.
- read_word_file(file_path, logger):
Read the content of a Word file.
- read_big_word_file(file_path, chunk_size, logger):
Read a big Word file in chunks.
- ensure_list(result):
Ensure the result is a list.
- Dependencies:
logging
docx (from python-docx package)
colorama
- odin_slides.utils.ensure_list(result)
Ensure the result is a list.
- Args:
result (dict or list): The result to be converted to a list.
- Returns:
list: The result as a list.
- Raises:
TypeError: If the result is neither a dictionary nor a list.
- odin_slides.utils.format_error(message)
Format the given message as a red-colored error.
- Args:
message (str): The message to be formatted.
- Returns:
str: The formatted message.
- odin_slides.utils.format_info(message)
Format the given message as a green-colored information.
- Args:
message (str): The message to be formatted.
- Returns:
str: The formatted message.
- odin_slides.utils.format_prompt(message)
Format the given message as a cyan-colored prompt.
- Args:
message (str): The message to be formatted.
- Returns:
str: The formatted message.
- odin_slides.utils.format_warning(message)
Format the given message as a yellow-colored warning.
- Args:
message (str): The message to be formatted.
- Returns:
str: The formatted message.
- odin_slides.utils.read_big_word_file(file_path, chunk_size, logger)
Read a big Word file in chunks.
- Args:
file_path (str): The path of the Word file to read. chunk_size (int): The maximum size of each chunk (in words). logger (logging.Logger): The logger object to record any errors.
- Returns:
list or None: A list of chunks containing the full text content of the Word file, or None if an error occurs.
- odin_slides.utils.read_word_file(file_path, logger)
Read the content of a Word file.
- Args:
file_path (str): The path of the Word file to read. logger (logging.Logger): The logger object to record any errors.
- Returns:
str or None: The full text content of the Word file, or None if an error occurs.
- odin_slides.utils.setup_debug_logger(debug_mode)
Setup and configure a debug logger.
- Args:
debug_mode (bool): Whether to enable console logging.
- Returns:
logging.Logger: The configured logger object.