253 reads

I Built an Agentic AI That Takes the Struggle Out of Cooking

by Shilpi BhattacharyyaMay 12th, 2025
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Struggling with cooking? I built an interactive AI assistant that guides you step-by-step. No more endless YouTube searches - just clear and simple instructions. It's a game changer for anyone overwhelmed by cooking, and it's powered by advanced instruction-tuned AI models.

People Mentioned

Mention Thumbnail

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - I Built an Agentic AI That Takes the Struggle Out of Cooking
Shilpi Bhattacharyya HackerNoon profile picture
0-item

Knowing how to cook today is a blessing but so underrated. It gives you control over what goes into your food— how much salt or sugar lands on your plate, how fresh the ingredients are and how well your meals align with your health goals. It’s the key to feeling better, living longer, and yes even looking your best.


Personally, my biggest frustration when I started cooking was forgetting the steps or ingredients mid-way only to scroll endlessly through YouTube tutorials. Each one had a different version - boil first, fry first, add this, skip that—it was like playing culinary game of chance. All the pausing, rewinding, and second-guessing made it exhausting to the point where I dreaded doing it.


Now that I am past that stage, I have started building an interactive, agentic AI cooking assistant to help others who are still overwhelmed by cooking. Instead of dumping a list of steps, it guides you like a calm, encouraging sous-chef. It adapts to what you have, making the process more intuitive, and less stressful.


I initially started working on this project in Google Colab but transitioned to Kaggle notebook due to GPU restrictions. I am sharing my notebook code below in the proper sequence.

from huggingface_hub import login

# Login using your Hugging Face token
login(token='your_actual_token_here')


In the above code, I log into the Hugging Face hub using my personal access token. You can find instructions on how to generate a token here. I am using Hugging Face to leverage state-of-the-art, pre-trained models and seamlessly integrate them into my cooking assistant without worrying about managing the underlying infrastructure. By logging in with a token, I can securely access and use these large pre-trained models, including any gated or private ones.


!pip install transformers --quiet
from transformers import pipeline

# Load the Mistral 7B Instruct model 
generator = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.1", device_map="auto", trust_remote_code=True)

Here, I install the transformers library and initialize the Mistral-7B instruct model via pipeline API to perform instruction-tuned text generation. This lets my assistant generate cooking steps on the fly, leveraging a pre-trained LLM without the need to train or host the model from scratch.


I am using Mistral-7B instruct because it’s an open-weight language model fine-tuned to follow instructions and generate coherent responses. It’s well-suited for tasks like step-by-step guidance, which makes it apt for my cooking assistant. That said, it’s just one option; we can easily swap it out with other instruction-tuned models like Meta’ Llama-2, Google’s Gemma, OpenChat, and others.


When I run this, my output looks like below.

Fig 2. Output of loading the Mistral-7B Instruct model using Hugging Face's transformers library


def get_step(dish, step_num):
    prompt = (
        f"You are an expert chef teaching someone to cook {dish}.\n"
        f"Give step-by-step cooking instructions.\n"
        f"What is step {step_num}?"
    )
    output = generator(prompt, max_new_tokens=100, do_sample=True, temperature=0.7)[0]['generated_text']
    
    # Clean output (remove prompt echoing if needed)
    cleaned = output.strip().split(f"What is step {step_num}?")[-1].strip()
    return "\n".join(cleaned.split("\n"))  # Return all lines

The function get_step(dish, step_num) generates a specific cooking step for a given dish based on the step number. It takes two inputs: dish - which is the name of the dish the user wants to cook and step_num - which corresponds to the step in the recipe. The function creates a prompt asking for step-by-step instructions for the dish and passes this prompt to the language model (via the generator). The model generates the requested cooking step, and the output is cleaned to remove any repetitive text or echoing of the prompt. Finally, the function returns the step as a formatted string, separating each line with a newline character for clarity.


def clarify_step(step):
    prompt = f"Explain this cooking step in detail: {step}"
    return generator(prompt, max_new_tokens=150, do_sample=True, temperature=0.7)[0]['generated_text'].strip()

The clarify_step(step) function provides a detailed explanation of a given cooking instruction. It takes a single input, step**,** which is a short cooking step generated earlier. The function creates a prompt that asks the language model to explain this step in more detail—ideal for beginners who want to understand the “why” behind the action. This prompt is passed to the generator, which returns a more comprehensive description of the step. The output is then stripped of leading and trailing whitespace and returned as a clean, detailed explanation string.


def agentic_cooking_guide():
    print("👩‍🍳 Welcome to your AI Sous-Chef!")
    dish = input("🍽️ What would you like to cook today? ").strip()

    step_num = 1
    while True:
        step = get_step(dish, step_num)
        print(f"\n🪜 Step {step_num}: {step}")
        user_input = input("👉 Type 'next', 'repeat', 'explain', or 'stop': ").strip().lower()

        if user_input == "next":
            step_num += 1
        elif user_input == "repeat":
            continue
        elif user_input == "explain":
            print("🧠 Explanation:", clarify_step(step))
        elif user_input == "stop":
            print("✅ Cooking session ended. Enjoy your meal!")
            break
        else:
            print("⚠️ Please type 'next', 'repeat', 'explain', or 'stop'.")

The agentic_cooking_guide() function drives the interactive experience of the AI cooking assistant. It starts by greeting the user and asking what dish they want to cook. Then, it enters a loop where it walks the user through each step of the cooking process. For every step, it calls the get_step() function to generate the corresponding instruction and displays it. The user can choose from four options to continue:


  • “next” moves to next step
  • “repeat” replays the current step ( especially relevant in a voice assistant setting if we missed what was said)
  • “explain” triggers the clarify_step() function for a more detailed explanation of the step.
  • “stop” ends the session.


If the user enters anything other than these options, the assistant prompts to try again. This process makes the assistant an adaptive, responsive cooking guide adjusting to user’s needs.


agentic_cooking_guide()


The agentic_cooking_guide() function serves as the entry point that launches the interactive AI cooking assistant. It starts a step-by-step, conversational session with the user, guiding them through the recipe like a supportive sous-chef. When I run this, my output looks like below.


Fig 3. Output of agentic AI cooking assistant for fried chicken recipe


This is just a starting point as I still need to expand the assistant’s flexibility beyond basic commands like next, repeat, explain and stop. But it lays a solid foundation and offers a clear glimpse into the potential of agentic AI. While I have applied it to a cooking assistant, the underlying concept can be extended to countless other problems across various domains.

Trending Topics

blockchaincryptocurrencyhackernoon-top-storyprogrammingsoftware-developmenttechnologystartuphackernoon-booksBitcoinbooks