> For the complete documentation index, see [llms.txt](https://zjunlp.gitbook.io/easyinstruct/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zjunlp.gitbook.io/easyinstruct/documentations/prompts/mmprompt.md).

# MMPrompt

> `MMPrompt` is the class for multimodal prompt, supporting input an image and question LLMs. We are now supporting two types of image encoding methods which are ASCII and caption.

#### **Constructor**

```python
__init__(self, resize=224)
```

**Parameters**

* `resize`(str): The size of the transformed image.

**Example**

```python
from easyinstruct import MMPrompt
mm_prompts = MMPrompt(resize=32)
```

#### **build\_prompt**

```python
build_prompt(self, 
    prompt: str,
    img_path: str,
    encode_format: str='ASCII',
    scale: float=10,
)
```

**Description**

Build a prompt from a given Image path and a question prompt.

**Parameters**

* `prompt` (str): The prompt string.
* `img_path` (str): The path of the input image.
* `encode_format` (str): The format to encode the input image. `ASCII` or `caption`.
* `scale` (float): Control the encoding granularity in `ASCII` encoding format.

**Example**

```python
# ASCII
mm_prompts = MMPrompt(resize=24)
mm_prompts.build_prompt(prompt='What is the image about?',
                        img_path='',    # the image path
                        encode_format='ASCII',
                        scale=10
                    )
print(mm_prompts.get_openai_result(engine="text-davinci-003"))

# Caption
mm_prompts.build_prompt(prompt='What is the image about?',
                        img_path='',    # the image path
                        encode_format='caption'
                    )

print(mm_prompts.get_openai_result(engine="text-davinci-003"))
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://zjunlp.gitbook.io/easyinstruct/documentations/prompts/mmprompt.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
