# OpenAIMetadataTagger

> **Class** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/document_transformers/openai_functions/OpenAIMetadataTagger)

Extract metadata tags from document contents using OpenAI functions.

    Example:
        .. code-block:: python

                from langchain_openai import ChatOpenAI
                from langchain_community.document_transformers import OpenAIMetadataTagger
                from langchain_core.documents import Document

                schema = {
                    "properties": {
                        "movie_title": { "type": "string" },
                        "critic": { "type": "string" },
                        "tone": {
                            "type": "string",
                            "enum": ["positive", "negative"]
                        },
                        "rating": {
                            "type": "integer",
                            "description": "The number of stars the critic rated the movie"
                        }
                    },
                    "required": ["movie_title", "critic", "tone"]
                }

                # Must be an OpenAI model that supports functions
                llm = ChatOpenAI(temperature=0, model="gpt-3.5-turbo-0613")
                tagging_chain = create_tagging_chain(schema, llm)
                document_transformer = OpenAIMetadataTagger(tagging_chain=tagging_chain)
                original_documents = [
                    Document(page_content="Review of The Bee Movie
By Roger Ebert

This is the greatest movie ever made. 4 out of 5 stars."),
                    Document(page_content="Review of The Godfather
By Anonymous

This movie was super boring. 1 out of 5 stars.", metadata={"reliable": False}),
                ]

                enhanced_documents = document_transformer.transform_documents(original_documents)

## Signature

```python
OpenAIMetadataTagger()
```

## Extends

- `BaseDocumentTransformer`
- `BaseModel`

## Properties

- `tagging_chain`

## Methods

- [`transform_documents()`](https://reference.langchain.com/python/langchain-community/document_transformers/openai_functions/OpenAIMetadataTagger/transform_documents)
- [`atransform_documents()`](https://reference.langchain.com/python/langchain-community/document_transformers/openai_functions/OpenAIMetadataTagger/atransform_documents)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/4b280287bd55b99b44db2dd849f02d66c89534d5/libs/community/langchain_community/document_transformers/openai_functions.py#L11)