Skip to content

armgit / camel

Public Imported from GitHub
0

๐Ÿซ CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

docs: Add pptx cookbook (#2666)

Sarthak Bhardwaj3eaf35db95a9
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index 0b089824f..ba9c7ce9e 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -26,7 +26,7 @@ body:
attributes:
label: What version of camel are you using?
description: Run command `python3 -c 'print(__import__("camel").__version__)'` in your shell and paste the output here.
- placeholder: E.g., 0.2.75a3
+ placeholder: E.g., 0.2.75a4
validations:
required: true
diff --git a/camel/__init__.py b/camel/__init__.py
index 05b30bf6f..33ba24760 100644
--- a/camel/__init__.py
+++ b/camel/__init__.py
@@ -14,7 +14,7 @@
from camel.logger import disable_logging, enable_logging, set_log_level
-__version__ = '0.2.75a3'
+__version__ = '0.2.75a4'
__all__ = [
'__version__',
diff --git a/docs/conf.py b/docs/conf.py
index 7fc8554ea..ed1420a85 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -27,7 +27,7 @@ sys.path.insert(0, os.path.abspath('..'))
project = 'CAMEL'
copyright = '2024, CAMEL-AI.org'
author = 'CAMEL-AI.org'
-release = '0.2.75a3'
+release = '0.2.75a4'
html_favicon = (
'https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png'
diff --git a/docs/cookbooks/applications/index.rst b/docs/cookbooks/applications/index.rst
index 60c7b95e8..78afe52f0 100644
--- a/docs/cookbooks/applications/index.rst
+++ b/docs/cookbooks/applications/index.rst
@@ -16,4 +16,5 @@ Applications
customer_service_Discord_bot_with_agentic_RAG
customer_service_Discord_bot_using_SambaNova_with_agentic_RAG
customer_service_Discord_bot_using_local_model_with_agentic_RAG
- finance_discord_bot
\ No newline at end of file
+ finance_discord_bot
+ pptx_toolkit
\ No newline at end of file
diff --git a/docs/cookbooks/applications/pptx_toolkit.ipynb b/docs/cookbooks/applications/pptx_toolkit.ipynb
new file mode 100644
index 000000000..ff55a3941
--- /dev/null
+++ b/docs/cookbooks/applications/pptx_toolkit.ipynb
@@ -0,0 +1,209 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "k-xIA7Qjuiwu"
+ },
+ "source": [
+ "# ๐Ÿซ ๐Ÿ“Š CAMEL-AI PPTXToolkit Cookbook\n",
+ "\n",
+ "This notebook shows you how to **automatically generate** and **assemble** professional PowerPoint decks using CAMEL-AIโ€™s PPTXToolkit. Youโ€™ll learn how to:\n",
+ "\n",
+ "- Prompt an LLM to produce **fully structured JSON** for every slide \n",
+ "- Turn that JSON into a polished `.pptx` with **titles**, **bullets**, **step diagrams**, **tables**, and **images** \n",
+ "- Leverage **Markdown** styling (`**bold**`, `*italic*`) and **Pexels** image search via `img_keywords` \n",
+ "- Plug in your **own .pptx templates** (modern, boardroom, minimalist, etc.) \n",
+ "- Enjoy **auto-layout** selection for text, diagrams, and tables \n",
+ "\n",
+ "<hr />\n",
+ "\n",
+ "## ๐Ÿšฅ Pipeline Overview\n",
+ "\n",
+ "1. **Single Agent: Content โ†’ JSON** \n",
+ " - You send one prompt to the LLM \n",
+ " - It returns a JSON list with:\n",
+ " - A **title slide** (`title`, `subtitle`) \n",
+ " - At least one **step-by-step** slide (all bullets start with `>>`) \n",
+ " - At least one **table** slide (`table`: `{headers, rows}`) \n",
+ " - Two or more slides with meaningful `img_keywords` \n",
+ " - All **bullet slides** using Markdown formatting \n",
+ "\n",
+ "2. **PPTXToolkit: JSON โ†’ `.pptx`** \n",
+ " - Pass that JSON into `PPTXToolkit.create_presentation(...)` \n",
+ " - Renders slides with your chosen template, images via `img_keywords`, chevrons/pentagons, and tables \n",
+ " - Outputs a ready-to-share PowerPoint file \n",
+ "\n",
+ "---\n",
+ "\n",
+ "Ready to build your next deck? Letโ€™s get started! ๐ŸŽ‰ \n",
+ "\n",
+ "You can also check this cookbook in colab [here](https://colab.research.google.com/drive/1W_dsoq1jrO8A_TzwUxzAr4wFSWeXLmn7?usp=sharing)\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true,
+ "id": "kR2UeIHFUBMf"
+ },
+ "outputs": [],
+ "source": [
+ "%pip install \"camel-ai[all]==0.2.66\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "FIz0b9O_wqkW"
+ },
+ "source": [
+ "## โš™๏ธ Configuration\n",
+ "Set your API keys securely:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "id": "HGpgR_XitX_B"
+ },
+ "outputs": [],
+ "source": [
+ "from getpass import getpass\n",
+ "import os\n",
+ "\n",
+ "# Prompt the user securely (input is hidden)\n",
+ "os.environ[\"OPENAI_API_KEY\"] = getpass(\"๐Ÿ”‘ Enter your OpenAI API key: \")\n",
+ "os.environ[\"PEXELS_API_KEY\"] = getpass(\"๐Ÿ”‘ Enter your Pexels API key (leave blank if not using images): \")\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "HtP_ej5CyUNT"
+ },
+ "source": [
+ "## โœ๏ธ Agent #1: Generate Structured JSON\n",
+ "One single LLM call to produce exactly the JSON your toolkit expects."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 118,
+ "metadata": {
+ "id": "ClqLd4HKypTI"
+ },
+ "outputs": [],
+ "source": [
+ "import os, json\n",
+ "from camel.agents import ChatAgent\n",
+ "from camel.models import ModelFactory\n",
+ "from camel.types import ModelPlatformType, ModelType\n",
+ "\n",
+ "def generate_slides_json(topic: str, slide_count: int) -> list:\n",
+ " # Build our strict prompt\n",
+ " prompt = f\"\"\"\n",
+ "You are a world-class PowerPoint generator for CAMEL-AI's PPTXToolkit.\n",
+ "\n",
+ "Create a presentation about \"{topic}\" with exactly {slide_count + 1} slides (1 title + {slide_count} content).\n",
+ "MANDATORY:\n",
+ "1. First slide: title & subtitle.\n",
+ "2. โ‰ฅ1 step-by-step slide (all bullets start with \">>\").\n",
+ "3. โ‰ฅ1 table slide (with headers & rows).\n",
+ "4. โ‰ฅ2 slides with non-empty img_keywords (search terms only).\n",
+ "5. Bullet slides use Markdown (**bold**, *italic*) in bullet_points.\n",
+ "6. Output MUST BE raw JSON (list of dicts), no markdown fences or commentary.\n",
+ "\n",
+ "Example:\n",
+ "[\n",
+ " {{\"title\":\"...\",\"subtitle\":\"...\"}},\n",
+ " {{\"heading\":\"...\",\"bullet_points\":[\"...\",\"...\"],\"img_keywords\":\"...\"}},\n",
+ " {{\"heading\":\"...\",\"bullet_points\":[\">> Step 1...\"],\"img_keywords\":\"...\"}},\n",
+ " {{\"heading\":\"...\",\"table\":{{\"headers\":[\"A\",\"B\"],\"rows\":[[\"1\",\"2\"],[\"3\",\"4\"]]}},\"img_keywords\":\"...\"}}\n",
+ "]\n",
+ "\"\"\"\n",
+ " agent = ChatAgent(\n",
+ " system_message=\"You strictly output valid JSON for PowerPoint slides.\",\n",
+ " message_window_size=5,\n",
+ " model=ModelFactory.create(\n",
+ " model_platform=ModelPlatformType.OPENAI,\n",
+ " model_type=ModelType.GPT_4_1,\n",
+ " model_config_dict={\"temperature\": 0.0},\n",
+ " )\n",
+ " )\n",
+ " resp = agent.step(prompt)\n",
+ " slides = json.loads(resp.msgs[0].content)\n",
+ " return slides\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "z35CIla3zBF4"
+ },
+ "source": [
+ "## ๐Ÿ“ฆ Build & Save PPTX\n",
+ "\n",
+ "Local code uses PPTXToolkit to turn that JSON into a .pptx file:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "id": "QkURpvVUT9Rk"
+ },
+ "outputs": [],
+ "source": [
+ "from camel.toolkits.pptx_toolkit import PPTXToolkit\n",
+ "\n",
+ "def build_pptx(slides_json: list, out_name: str = \"presentation.pptx\") -> str:\n",
+ " kit = PPTXToolkit(output_dir=\".\")\n",
+ " kit.create_presentation(json.dumps(slides_json), out_name)\n",
+ " return out_name"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "-WXOG-Hr1ibN"
+ },
+ "source": [
+ "## ๐Ÿ”— Run the Pipeline"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "id": "WnOXRacP1fbB"
+ },
+ "outputs": [],
+ "source": [
+ "if __name__ == \"__main__\":\n",
+ " topic = input(\"๐ŸŽฏ Topic: \")\n",
+ " n = int(input(\"๐Ÿ“„ # of content slides: \"))\n",
+ " slides = generate_slides_json(topic, n)\n",
+ " filename = f\"{topic.replace(' ','_')}.pptx\"\n",
+ " path = build_pptx(slides, out_name=filename)\n",
+ " print(f\"โœ… Deck saved to: {path}\")\n"
+ ]
+ }
+ ],
+ "metadata": {
+ "colab": {
+ "provenance": []
+ },
+ "kernelspec": {
+ "display_name": "Python 3",
+ "name": "python3"
+ },
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/pyproject.toml b/pyproject.toml
index 086e42b7b..7ba996e92 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "camel-ai"
-version = "0.2.75a3"
+version = "0.2.75a4"
description = "Communicative Agents for AI Society Study"
authors = [{ name = "CAMEL-AI.org" }]
requires-python = ">=3.10,<3.13"
diff --git a/uv.lock b/uv.lock
index 7c06c7f75..7e55b01d4 100644
--- a/uv.lock
+++ b/uv.lock
@@ -663,7 +663,7 @@ wheels = [
[[package]]
name = "camel-ai"
-version = "0.2.75a3"
+version = "0.2.75a4"
source = { editable = "." }
dependencies = [
{ name = "colorama" },