Cortex
TwitterDiscord
  • 👋Welcome to Cortex
  • Overview
    • 💡Understanding Cortex Architecture
  • Product Guides
    • 🛫Making your first Copilot
    • ⚡Making your first Callable
  • Fundamentals
    • ✈️Copilot
    • 🧠Knowledge
    • ⚡Callable
    • 🛠️Getting set up
      • 📝Setting permissions
  • Callable
    • Blocks
      • Models
        • Language Model
        • Language Model With Code
      • Data
        • Dataset Loader
      • Tools
        • Knowledge Search
        • Google Search
        • Curl Request
        • Web Page Crawler
      • Control
        • Code
        • Loop Until
        • Map Reduce
    • Use Cases
      • Building a Company Help Desk
      • Creating a Social Media Manager Chatbot
      • Utilizing Model Examples to Convert Text to JSON
      • Retrievals from Knowledge Search Blocks
      • Chatbot with Google Search Assistance
  • Guides
    • Getting Started with the SDK
    • Documents
  • API References
    • Introduction
    • Authentication
    • Making Curl Requests
    • Node.js Library
    • Python Library
Powered by GitBook
On this page
  • Basic Model Block
  • Advanced Model Block
  • Converting Text to JSON
  1. Callable
  2. Use Cases

Utilizing Model Examples to Convert Text to JSON

PreviousCreating a Social Media Manager ChatbotNextRetrievals from Knowledge Search Blocks

Last updated 1 year ago

Basic Model Block

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

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.

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.

We can also load examples using the Data Block and inputting the examples in the dataset tab.

That uses the following example dataset.

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.

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

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

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