Skip to main content

A Python package to generate detailed meal information from natural language descriptions using Generative AI

Project description

Meal Generator

PyPI version License: MIT

A Python package that uses a Generative AI model to parse natural language descriptions of meals and returns a detailed breakdown, including components, estimated weights, and a comprehensive nutrient profile.

Features

  • Natural Language Processing: Understands descriptions of meals like "a bowl of oatmeal with a sliced banana and a drizzle of honey."
  • Component Breakdown: Identifies individual ingredients within the meal.
  • Nutrient Analysis: Provides estimated nutritional information for each component, including calories, macronutrients, and common allergens.
  • Structured Output: Returns data as organized Python objects for easy integration into your applications.

Installation

Install the package using pip:

pip install meal-generator

You will also need to have a Google Gemini API key. You can set this as an environment variable:

export GEMINI_API_KEY="your-api-key"

Usage

Here is a quick example of how to use the MealGenerator:

from meal_generator import MealGenerator, MealGenerationError

# Initialize the generator (it will use the GEMINI_API_KEY environment variable)
generator = MealGenerator()

meal_description = "A grilled chicken salad with lettuce, tomatoes, cucumbers, and a light vinaigrette dressing."

try:
    # Generate the meal object
    meal = generator.generate_meal(meal_description)

    # Print the meal's aggregated nutrient profile
    print(f"Meal: {meal.name}")
    print(f"Description: {meal.description}")
    print("\n--- Aggregated Nutrients ---")
    print(meal.nutrient_profile)

    # Print details for each component
    print("\n--- Meal Components ---")
    for component in meal.component_list:
        print(f"- {component.name} ({component.quantity}): {component.total_weight}g")
        print(f"  {component.nutrient_profile}")

except MealGenerationError as e:
    print(f"Error generating meal: {e}")
except ValueError as e:
    print(f"Input error: {e}")

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue on the GitHub repository.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

meal_generator-0.0.1.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

meal_generator-0.0.1-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file meal_generator-0.0.1.tar.gz.

File metadata

  • Download URL: meal_generator-0.0.1.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for meal_generator-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b53ec4a6bdcef8a61dd2b9724a1bf45f15dee3c43266db993ef62d8d186e7cf1
MD5 7ba889d012acdd56269a8e6b191c2ab4
BLAKE2b-256 24fe780ff752ae3c1b41827d5d1dd7cbf55e04593d7e48c29f2b06c525cd9f71

See more details on using hashes here.

File details

Details for the file meal_generator-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: meal_generator-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for meal_generator-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 80e20ace006952dcde3b949e436250c8fbd60194d6f84e57cf72d7647b9315d0
MD5 08a048e686ae55e5c9b0040e70f3b567
BLAKE2b-256 f22327249e0e1443c82e4e9df7b9b1266823a19eba2ee2533c9a9cdab0175548

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page