by Luhanm

Cooking Companion

Test this app for free
387
import os
from flask import Flask, request, render_template_string, session, jsonify
from flask_session import Session
from abilities import llm_prompt

app = Flask(__name__)
app.config["SESSION_PERMANENT"] = False
app.config["SESSION_TYPE"] = "filesystem"
Session(app)

TEMPLATE = """
<!doctype html>
<html>
<head>
    <title>AI Cooking Assistant</title>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            background-color: #f3f4f6;
            color: #333;
        }
        #chatBox {
            display: none;
            border: 2px solid #ffc107;
Get full code

Frequently Asked Questions

How can the Cooking Companion app benefit a food-related business?

The Cooking Companion app can significantly enhance a food-related business by providing an interactive and personalized cooking experience for customers. It can be integrated into a restaurant's website to offer recipe suggestions based on their menu items, or used by food bloggers to provide an AI-powered cooking assistant to their audience. This engagement can increase customer loyalty and time spent on the platform, potentially leading to increased sales or ad revenue.

What are some potential monetization strategies for the Cooking Companion app?

There are several ways to monetize the Cooking Companion app:

How can the Cooking Companion app be adapted for different cuisines or dietary requirements?

The Cooking Companion app is highly adaptable to various cuisines and dietary requirements. This can be achieved by modifying the initial prompt in the home() function to include specific dietary or cuisine preferences. For example, you could add a dropdown menu for users to select their dietary needs (vegan, gluten-free, etc.) or preferred cuisine type. The app would then pass this information to the AI model when generating recipes or answering questions, ensuring that all content is tailored to the user's specific needs.

How can I modify the Cooking Companion app to include images of the dishes?

To include images of the dishes, you can integrate an image generation AI or use a pre-existing image database. Here's an example of how you could modify the home() function to include an image URL in the session data:

```python @app.route('/', methods=['GET', 'POST']) def home(): if request.method == 'POST': dish = request.form['dish'] # ... existing code ...

       # Add this section to generate or fetch an image URL
       image_prompt = f"Generate an image URL for {dish}"
       image_url = llm_prompt(prompt=image_prompt, model=None, temperature=0.5)

       session['image_url'] = image_url
       return render_template_string(TEMPLATE, ingredients=session['ingredients'], steps=[session['steps'][session['current_step']]], image_url=session['image_url'])

```

Then, in your HTML template, you can add an <img> tag to display the image:

html {% if session.get('image_url') %} <img src="{{ session['image_url'] }}" alt="{{ dish }}" style="max-width: 300px;"> {% endif %}

How can I extend the Cooking Companion app to save user preferences and favorite recipes?

To save user preferences and favorite recipes, you'll need to implement user authentication and database storage. Here's a basic example of how you could modify the app to include this functionality:

```python from flask_sqlalchemy import SQLAlchemy from flask_login import LoginManager, UserMixin, login_user, login_required, current_user

app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///users.db' db = SQLAlchemy(app) login_manager = LoginManager(app)

class User(UserMixin, db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), unique=True, nullable=False) favorites = db.relationship('Favorite', backref='user', lazy=True)

class Favorite(db.Model): id = db.Column(db.Integer, primary_key=True) recipe_name = db.Column(db.String(120), nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)

@app.route('/favorite', methods=['POST']) @login_required def add_favorite(): recipe_name = request.form['recipe_name'] new_favorite = Favorite(recipe_name=recipe_name, user_id=current_user.id) db.session.add(new_favorite) db.session.commit() return jsonify({'status': 'success'}) ```

This code sets up a basic user model and a favorites system. You'd need to add more routes for user registration, login, and viewing favorites. Remember to update your HTML template to include buttons or links for these new features.

Created: | Last Updated:

AI powered cooking companion app. It provides recipes, answers cooking questions, and features a chat with AI chef.

Introduction to the Cooking Companion Template

Welcome to the Cooking Companion template guide! This template is designed to help you create an AI-powered cooking assistant app. The app provides recipes, answers cooking questions, and features a chat with an AI chef. It's a perfect solution for those looking to integrate a smart cooking guide into their software offerings.

Getting Started

To begin using this template, simply click on "Start with this Template" on the Lazy platform. This will set up the template in your Lazy Builder interface, ready for customization and deployment.

Test: Deploying the App

Once you have the template loaded, press the "Test" button to start the deployment process. The Lazy CLI will handle the deployment, and you won't need to worry about installing libraries or setting up the environment.

Entering Input

If the template requires user input, the Lazy App's CLI interface will prompt you to provide it after pressing the "Test" button. Follow the prompts to input the necessary information for your app to function correctly.

Using the App

After deployment, the app will provide a frontend experience where users can interact with the AI cooking assistant. Users can ask for recipes, get answers to cooking-related questions, and navigate through cooking steps. The interface includes buttons and forms to facilitate user interaction.

Integrating the App

If you need to integrate this app into an external service or frontend, you will be provided with a dedicated server link to use the API. This link can be added to your external tool to allow users to interact with the Cooking Companion app from within your existing software environment.

Here's a sample request you might send to the app's API:

`POST /ask HTTP/1.1
Host: [your-server-link]
Content-Type: application/x-www-form-urlencoded
X-Requested-With: XMLHttpRequest

question=How+long+should+I+bake+chicken?` And a sample response from the API might look like this:

{   "answer": "Bake the chicken for 25 minutes at 350 degrees Fahrenheit." } Remember, all the steps listed above are mandatory to run and integrate the template successfully. Follow them carefully to ensure your Cooking Companion app works flawlessly.

If you encounter any issues or need further assistance, refer to the documentation provided in the code or reach out to the Lazy platform support team.



Here are 5 key business benefits for this AI-powered cooking companion template:

Template Benefits

  1. Enhanced Customer Engagement: The interactive chat feature with an AI chef allows users to ask questions and receive personalized cooking advice, increasing user engagement and time spent on the platform.

  2. Scalable Culinary Education: By providing step-by-step recipes and answering cooking questions, this template offers a scalable solution for culinary education, potentially reducing the need for live customer support or cooking classes.

  3. Data Collection for Product Development: User interactions and recipe requests can provide valuable data on food trends and consumer preferences, informing product development for food-related businesses or recipe content creation.

  4. Upselling Opportunities: The template can be easily modified to recommend specific ingredients or kitchen tools, creating opportunities for affiliate marketing or direct product sales.

  5. Brand Building in Food Industry: For food brands, restaurants, or cooking equipment manufacturers, this template offers a branded, interactive cooking experience that can strengthen customer relationships and brand loyalty.

Technologies