Prompt-based interaction represents a fundamental shift in how we build software. Instead of hardcoding every operation, we express intent in natural language and let large language models translate that into executable actions. This article guides you through building an interactive data analysis tool using prompt-based interaction.

<aside> 🛠

What we will build: A web application where users can view CSV data, filter it visually, ask analytical questions in natural language, and receive answers computed reliably through LLM-generated code. This moves beyond the chatbot paradigm by combining structured UI controls with the flexibility of prompting, reducing the burden of articulating complex analytical tasks entirely in text.

</aside>

<aside> 💡

What you will learn:

Prerequisites: This is a hands-on tutorial. We assume you have a working Python development environment and basic familiarity with:

If you need help setting up your development environment, API keys, or Python dependencies, refer to these resources:

Part 1: API Fundamentals

Your First API Call

At its core, interacting with an LLM via the OpenAI API is straightforward. You send a message and receive a response. The system message defines the AI's role and behavior, while the user message is your actual query. The response is natural language text—flexible, but unpredictable.

Code:

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is a Large Language Model?"}
    ]
)

print(response.choices[0].message.content)

Expected Output:

A Large Language Model (LLM) is a type of artificial intelligence model designed
to understand and generate human language. These models are trained on massive
datasets...

Experimenting with Parameters: Temperature