> ## 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.schemas.outlines converter

<a id="camel.schemas.outlines_converter" />

<a id="camel.schemas.outlines_converter.OutlinesConverter" />

## OutlinesConverter

```python theme={"system"}
class OutlinesConverter(BaseConverter):
```

OutlinesConverter is a class that converts a string or a function
into a BaseModel schema.

**Parameters:**

* **model\_type** (str, optional): The model type to be used.
* **platform** (str, optional): The platform to be used. 1. transformers 2. mamba 3. vllm 4. llamacpp 5. mlx (default: "transformers") \*\*kwargs: The keyword arguments to be used. See the outlines documentation for more details. See
* **https**: //dottxt-ai.github.io/outlines/latest/reference/models/models/

<a id="camel.schemas.outlines_converter.OutlinesConverter.__init__" />

### **init**

```python theme={"system"}
def __init__(
    self,
    model_type: str,
    platform: Literal['vllm', 'transformers', 'mamba', 'llamacpp', 'mlx'] = 'transformers',
    **kwargs: Any
):
```

<a id="camel.schemas.outlines_converter.OutlinesConverter.convert_regex" />

### convert\_regex

```python theme={"system"}
def convert_regex(self, content: str, regex_pattern: str):
```

Convert the content to the specified regex pattern.

**Parameters:**

* **content** (str): The content to be converted.
* **regex\_pattern** (str): The regex pattern to be used.

**Returns:**

str: The converted content.

<a id="camel.schemas.outlines_converter.OutlinesConverter.convert_json" />

### convert\_json

```python theme={"system"}
def convert_json(self, content: str, output_schema: Union[str, Callable]):
```

Convert the content to the specified JSON schema given by
output\_schema.

**Parameters:**

* **content** (str): The content to be converted.
* **output\_schema** (Union\[str, Callable]): The expected format of the response.

**Returns:**

dict: The converted content in JSON format.

<a id="camel.schemas.outlines_converter.OutlinesConverter.convert_pydantic" />

### convert\_pydantic

```python theme={"system"}
def convert_pydantic(self, content: str, output_schema: Type[BaseModel]):
```

Convert the content to the specified Pydantic schema.

**Parameters:**

* **content** (str): The content to be converted.
* **output\_schema** (Type\[BaseModel]): The expected format of the response.

**Returns:**

BaseModel: The converted content in pydantic model format.

<a id="camel.schemas.outlines_converter.OutlinesConverter.convert_type" />

### convert\_type

```python theme={"system"}
def convert_type(self, content: str, type_name: type):
```

Convert the content to the specified type.

The following types are currently available:

1. int
2. float
3. bool
4. datetime.date
5. datetime.time
6. datetime.datetime
7. custom types ([https://dottxt-ai.github.io/outlines/latest/reference/generation/types/](https://dottxt-ai.github.io/outlines/latest/reference/generation/types/))

**Parameters:**

* **content** (str): The content to be converted.
* **type\_name** (type): The type to be used.

**Returns:**

str: The converted content.

<a id="camel.schemas.outlines_converter.OutlinesConverter.convert_choice" />

### convert\_choice

```python theme={"system"}
def convert_choice(self, content: str, choices: List[str]):
```

Convert the content to the specified choice.

**Parameters:**

* **content** (str): The content to be converted.
* **choices** (List\[str]): The choices to be used.

**Returns:**

str: The converted content.

<a id="camel.schemas.outlines_converter.OutlinesConverter.convert_grammar" />

### convert\_grammar

```python theme={"system"}
def convert_grammar(self, content: str, grammar: str):
```

Convert the content to the specified grammar.

**Parameters:**

* **content** (str): The content to be converted.
* **grammar** (str): The grammar to be used.

**Returns:**

str: The converted content.

<a id="camel.schemas.outlines_converter.OutlinesConverter.convert" />

### convert

```python theme={"system"}
def convert(
    self,
    content: str,
    type: Literal['regex', 'json', 'type', 'choice', 'grammar'],
    **kwargs
):
```

Formats the input content into the expected BaseModel.

**Parameters:**

* **type** (`Literal["regex", "json", "type", "choice", "grammar"]`): The type of conversion to perform. Options are: - "regex": Match the content against a regex pattern. - "pydantic": Convert the content into a pydantic model. - "json": Convert the content into a JSON based on a schema. - "type": Convert the content into a specified type. - "choice": Match the content against a list of valid choices. - "grammar": Convert the content using a specified grammar.
* **content** (str): The content to be formatted. \*\*kwargs: Additional keyword arguments specific to the conversion type. - For "regex":
* **regex\_pattern** (str): The regex pattern to use for matching. - For "pydantic":
* **output\_schema** (Type\[BaseModel]): The schema to validate and format the pydantic model. - For "json":
* **output\_schema** (Union\[str, Callable]): The schema to validate and format the JSON object. - For "type":
* **type\_name** (str): The target type name for the conversion. - For "choice":
* **choices** (List\[str]): A list of valid choices to match against. - For "grammar":
* **grammar** (str): The grammar definition to use for content conversion.
