> ## Documentation Index
> Fetch the complete documentation index at: https://docs.camel-ai.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Camel.prompts.base

<a id="camel.prompts.base" />

<a id="camel.prompts.base.return_prompt_wrapper" />

## return\_prompt\_wrapper

```python theme={"system"}
def return_prompt_wrapper(cls: Any, func: Callable):
```

Wrapper that converts the return value of a function to an input
class instance if it's a string.

**Parameters:**

* **cls** (Any): The class to convert to.
* **func** (Callable): The function to decorate.

**Returns:**

Callable\[..., Union\[Any, str]]: Decorated function that
returns the decorated class instance if the return value is a
string.

<a id="camel.prompts.base.wrap_prompt_functions" />

## wrap\_prompt\_functions

```python theme={"system"}
def wrap_prompt_functions(cls: T):
```

Decorator that wraps functions of a class inherited from :obj:`str`
with the :obj:`return_text_prompt` decorator.

**Parameters:**

* **cls** (type): The class to decorate.

**Returns:**

type: Decorated class with wrapped functions.

<a id="camel.prompts.base.TextPrompt" />

## TextPrompt

```python theme={"system"}
class TextPrompt(str):
```

A class that represents a text prompt. The :obj:`TextPrompt` class
extends the built-in :obj:`str` class to provide a property for retrieving
the set of keywords in the prompt.

**Parameters:**

* **key\_words** (set): A set of strings representing the keywords in the prompt.

<a id="camel.prompts.base.TextPrompt.key_words" />

### key\_words

```python theme={"system"}
def key_words(self):
```

Returns a set of strings representing the keywords in the prompt.

<a id="camel.prompts.base.TextPrompt.format" />

### format

```python theme={"system"}
def format(self, *args: Any, **kwargs: Any):
```

Overrides the built-in :obj:`str.format` method to allow for
default values in the format string. This is used to allow formatting
the partial string.

**Returns:**

TextPrompt: A new :obj:`TextPrompt` object with the format string
replaced with the formatted string.

<a id="camel.prompts.base.CodePrompt" />

## CodePrompt

```python theme={"system"}
class CodePrompt(TextPrompt):
```

A class that represents a code prompt. It extends the :obj:`TextPrompt`
class with a :obj:`code_type` property.

**Parameters:**

* **code\_type** (str, optional): The type of code. Defaults to None.

<a id="camel.prompts.base.CodePrompt.__new__" />

### **new**

```python theme={"system"}
def __new__(cls, *args: Any, **kwargs: Any):
```

Creates a new instance of the :obj:`CodePrompt` class.

**Returns:**

CodePrompt: The created :obj:`CodePrompt` instance.

<a id="camel.prompts.base.CodePrompt.code_type" />

### code\_type

```python theme={"system"}
def code_type(self):
```

**Returns:**

Optional\[str]: The type of code.

<a id="camel.prompts.base.CodePrompt.set_code_type" />

### set\_code\_type

```python theme={"system"}
def set_code_type(self, code_type: str):
```

Sets the type of code.

**Parameters:**

* **code\_type** (str): The type of code.

<a id="camel.prompts.base.CodePrompt.execute" />

### execute

```python theme={"system"}
def execute(
    self,
    interpreter: Optional[BaseInterpreter] = None,
    **kwargs: Any
):
```

Executes the code string using the provided interpreter.

This method runs a code string through either a specified interpreter
or a default one. It supports additional keyword arguments for
flexibility.

**Parameters:**

* **interpreter** (Optional\[BaseInterpreter]): The interpreter instance to use for execution. If `None`, a default interpreter is used. (default: :obj:`None`) \*\*kwargs: Additional keyword arguments passed to the interpreter to run the code.

**Returns:**

str: The result of the code execution. If the execution fails, this
should include sufficient information to diagnose and correct
the issue.

<a id="camel.prompts.base.TextPromptDict" />

## TextPromptDict

```python theme={"system"}
class TextPromptDict:
```

A dictionary class that maps from key to :obj:`TextPrompt` object.

<a id="camel.prompts.base.TextPromptDict.__init__" />

### **init**

```python theme={"system"}
def __init__(self, *args: Any, **kwargs: Any):
```
