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.2.tar.gz (10.7 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.2-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: meal_generator-0.0.2.tar.gz
  • Upload date:
  • Size: 10.7 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.2.tar.gz
Algorithm Hash digest
SHA256 24689ebdff6e082f718c2b2db594123c31e59a26d9f66f22cccb4489ed9ae23a
MD5 95b3f26f57bb89b788dbff8f6c78117a
BLAKE2b-256 5fed2dce30218bcd86ee67e5084372455dc06704a33774d414f3d9d0283fbad0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: meal_generator-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 10.0 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7891a03262c03a3c78de1a7d00fb7bdf1de3331ca0e2d4455c0e9089fffb977d
MD5 6bd01cccef3a22ee02929010490dcecc
BLAKE2b-256 407c10f4e426a84e84639c10c262b913a43198c78daf74983a50e63eb8e564b2

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