# Utilizing Model Examples to Convert Text to JSON

## Basic Model Block

The basic Model Block accepts a specified prompt string and returns a Language Model completion as the result.

<figure><img src="/files/9qnmqnNNUOVKKAjWYJ3R" alt=""><figcaption></figcaption></figure>

## Advanced Model Block

The advanced Model Block provides parameters for the Introduction and Examples

* **Introduction:** A paragraph that will appear at the beginning of your prompt once. Provides instruction to the model about how it should interpret your examples
* **Examples:** Provide examples of the type of response you want the model to output. This could be a list of examples that are organized as a template question and answer.
* **Prompt:** The final question that will appear at the end of the prompt that the user wants the model to complete.

<figure><img src="/files/lJD5Mwxka3caj8xofAfp" alt=""><figcaption></figcaption></figure>

## Converting Text to JSON

In order to create a callable that can change plain text into a JSON, we need to provide examples for our model to reference back to so that the model would know what kind of output we are looking for.

To do this, let's initialize our examples as an array of example objects with a question and an answer field. There are two ways to do this, the first way will use a code block.

<figure><img src="/files/EyAY1qzVHn65dDkUfHUw" alt=""><figcaption></figcaption></figure>

We can also load examples using the Data Block and inputting the examples in the dataset tab.&#x20;

<figure><img src="/files/kpaFdyUCMHbVGZGaSrah" alt=""><figcaption></figcaption></figure>

That uses the following example dataset.

<figure><img src="/files/AX0tJlztmlVw5lplAYGN" alt=""><figcaption></figcaption></figure>

After initializing the examples, we can now set up an advanced language model block that has an introduction that describes our desired task to our model and then enter in our examples as a question followed by an answer. Finally, we enter our original input question as our prompt.

<figure><img src="/files/wgSBUNuOiMfP1JdzAN9V" alt=""><figcaption></figcaption></figure>

We can now run some test cases to see if this works. When we try the input:

<figure><img src="/files/BWcoRAsIG681uIQCTTWX" alt=""><figcaption></figcaption></figure>

We can see that our callable successful returns the JSON object as:

<figure><img src="/files/haUBMn7Jy79VJrNhkzOG" alt=""><figcaption></figcaption></figure>

Once tested, deploy the callable to use in any application.


---

# Agent Instructions: 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://docs.trycortex.ai/callable/use-cases/utilizing-model-examples-to-convert-text-to-json.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.
