Skip to main content

What is the Prompt Module?

The prompt module in CAMEL guides AI models to produce accurate, relevant, and personalized outputs. It provides a library of templates and dictionaries for diverse tasks — like role description, code generation, evaluation, embeddings, and even object recognition.

You can also craft your own prompts to precisely shape your agent’s behavior.

Using Prompt Templates

CAMEL provides many ready-to-use prompt templates for quickly spinning up task-specific agents.
Set task_type=TaskType.AI_SOCIETY to use the default society prompt template, or define your own.

Using Your Own Prompt

Create and pass your own prompt template with full flexibility:

Introduction to the CodePrompt Class

The CodePrompt class represents a code prompt and extends TextPrompt. It’s perfect for code generation and execution tasks.

Creating a CodePrompt

Accessing and Modifying the Code and Type

Executing the Code

Write Your Prompts with the TextPrompt Class

The TextPrompt class is a subclass of Python’s str, with extra features for managing key words and advanced formatting.

The key_words Property

The format Method (Partial Formatting Supported)

Manipulating TextPrompt Instances

You can concatenate, join, and use string methods with TextPrompt just like Python strings:

Supported Prompt Templates

This class defines prompt templates for the AI Society role-playing and task handling workflow.Templates include:
  • GENERATE_ASSISTANTS: List roles the AI assistant can play.
  • GENERATE_USERS: List common user groups or occupations.
  • GENERATE_TASKS: List diverse tasks for assistants.
  • TASK_SPECIFY_PROMPT: Detail a task given assistant and user roles.
  • ASSISTANT_PROMPT: Rules for assistants to complete tasks.
  • USER_PROMPT: Rules for giving instructions to assistants.
  • CRITIC_PROMPT: Criteria for critics choosing among proposals.
This class provides prompts for code-related tasks (language, domain, code task generation, and instructions for coders).Templates include:
  • GENERATE_LANGUAGES: List computer programming languages.
  • GENERATE_DOMAINS: List common programming domains.
  • GENERATE_TASKS: List tasks for programmers.
  • TASK_SPECIFY_PROMPT: Specify a programming-related task.
  • ASSISTANT_PROMPT: Rules for completing code tasks.
  • USER_PROMPT: User instructions for coding agents.
Prompts for generating questions to evaluate knowledge.Templates include:
  • GENERATE_QUESTIONS: Create question sets for evaluating knowledge emergence, with optional field-specific examples.
Prompts for generating text embedding tasks and synthetic data for embedding model improvement.Templates include:
  • GENERATE_TASKS: Generate synthetic text embedding tasks.
  • ASSISTANT_PROMPT: Generate synthetic queries (JSON), positive docs, and hard negatives.
Prompts to test model alignment by introducing misleading or jailbreak tasks.Templates include:
  • DAN_PROMPT: Do-Anything-Now jailbreak prompt.
  • GENERATE_TASKS: List unique malicious tasks.
  • TASK_SPECIFY_PROMPT: Specify a malicious task in detail.
  • ASSISTANT_PROMPT: Rules for misaligned assistant tasks.
  • USER_PROMPT: User instructions in misalignment contexts.
Prompts for object recognition tasks.Templates include:
  • ASSISTANT_PROMPT: Detect all objects in images, minimizing redundancy.
Inherits from AISocietyPromptTemplateDict and adds prompts for describing roles and responsibilities.Templates include:
  • ROLE_DESCRIPTION_PROMPT: Explain roles and responsibilities for agents.
Prompts to focus AI on finding solutions using particular knowledge.Templates include:
  • ASSISTANT_PROMPT: Rules for extracting and presenting solutions.
Prompts for translation assistants (English → target language).Templates include:
  • ASSISTANT_PROMPT: Rules for completing translation tasks.
Prompts for describing video content.Templates include:
  • ASSISTANT_PROMPT: Rules for generating video descriptions.