Prompt

Send instructions to LLMs with variable tagging, tool usage, and structured responses

Prompt Cell

Prompt cells let you send instructions to an LLM of your choice and get a structured response back. They’re perfect for natural language queries, text generation, or structured outputs like JSON.


How It Works

  1. Write Your Prompt – Enter your instructions in the User Prompt field.
  2. Choose a Model – Select any available LLM from the Model dropdown.
  3. Configure Advanced Options:
    • Temperature – Controls randomness. Lower values (e.g., 0.1) make the output more deterministic; higher values (e.g., 1.0) make it more creative.
    • Max Tokens – The maximum number of tokens (words/subwords) the model can generate in its response.
    • Top P – Controls nucleus sampling. The model considers the smallest set of words whose cumulative probability exceeds p.
  4. Select Response Format:
    • Text – Returns a plain text result.
    • JSON – Returns a JSON-formatted string. You must describe the expected JSON structure in your prompt.
  5. Optional Fields:
    • System Prompt – Context or behavior guidelines for the model.
    • Tool Usage – Link Python functions (see below) for the model to call.
    • Variable Tagging – Use {{variable_name}} to insert values from other variables in your notebook directly into the prompt.

Variable Tagging Examples

  • Personalizing output:
    User Prompt: Write a welcome email to {{customer_name}} introducing our new product.
  • Data-driven questions:
    User Prompt: Analyze the dataframe {{sales_df}} and summarize the top 3 regions by revenue.
  • Dynamic AI chaining:
    System Prompt: You are an expert analyst.
    User Prompt: Using the summary from {{previous_ai_output}}, suggest three follow-up analyses.

Using Tools

You can define a Python function in another Python cell and describe it as a tool:

  • Paste the function in a Python cell — Livedocs will auto-generate the tool call definition in JSON.
  • Or, manually describe the tool’s input/output format in the Tool Usage field.

This lets the LLM call your function to retrieve data or perform computations.


Output Format

  • Text Output Example:

    {
        'result': "The letter 'r' appears 2 times in the word 'strawberry'."
    }
  • JSON Output Example:

    {
        'result': '{"count": 2}'
    }

    Note: For JSON, the result is stringified.


Next Steps: