<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Eben</title>
    <description>The latest articles on DEV Community by Eben (@nezer).</description>
    <link>https://dev.to/nezer</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F93763%2F9eda4aa8-2f66-466f-bf6d-cf0a68673d6b.png</url>
      <title>DEV Community: Eben</title>
      <link>https://dev.to/nezer</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nezer"/>
    <language>en</language>
    <item>
      <title>Building an AI Recipe App with Django and GroqCloud:Llama 3.1: My Journey with myChefAssist</title>
      <dc:creator>Eben</dc:creator>
      <pubDate>Mon, 12 Aug 2024 01:32:15 +0000</pubDate>
      <link>https://dev.to/nezer/building-an-ai-recipe-app-with-django-and-groqcloudllama-31-my-journey-with-mychefassist-5b1m</link>
      <guid>https://dev.to/nezer/building-an-ai-recipe-app-with-django-and-groqcloudllama-31-my-journey-with-mychefassist-5b1m</guid>
      <description>&lt;p&gt;Creating an AI-powered recipe app like myChefAssist has been full of technical challenges and learning. myChefAssist is meant to help users create recipes based on the ingredients they have, with AI making the experience more personal and interactive. In this post, I’ll share the technical details, challenges, and what I’ve learned along the way.&lt;/p&gt;

&lt;h3&gt;
  
  
  How It Works
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Backend Setup:&lt;/strong&gt;&lt;br&gt;
myChefAssist is built using Django for the backend, with PostgreSQL as the database. The AI, powered by Llama 3.1 through GroqCloud, helps users by generating different recipe options based on their input.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Multiple Recipe Options:&lt;/strong&gt; Users get several recipe options from the AI, based on their ingredients or preferences.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ingredient Matching:&lt;/strong&gt; After a recipe is chosen, the system checks the user’s available ingredients and adjusts the recipe accordingly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flexible Recipe Suggestions:&lt;/strong&gt; If the user doesn’t have enough ingredients, the AI suggests a different recipe that fits what they have.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Challenges and Solutions
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Getting AI Responses in JSON:&lt;/strong&gt;&lt;br&gt;
The AI had to return recipe data in a JSON format that matched Django’s models. This was important because the recipe data needed to be saved in the database.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Solution:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Clear JSON Structure:&lt;/strong&gt; I defined a JSON structure that matched Django models, making sure all the necessary details like ingredients and steps were included.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validation:&lt;/strong&gt; I wrote Django commands to check the incoming JSON data to make sure it was correct before saving it to the database.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Handling Multiple Recipes:&lt;/strong&gt;&lt;br&gt;
The app needed to handle multiple recipes at once, which meant the API had to fetch and process several AI-generated recipes in one go.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Solution:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;API Extension:&lt;/strong&gt; I extended the API to handle multiple recipes, making sure each one was correctly formatted and saved to the database.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Optimized Database Transactions:&lt;/strong&gt; I batched the database transactions to reduce the load and improve performance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Managing User-Selected Recipes:&lt;/strong&gt;&lt;br&gt;
Once a user picks a recipe, the system needs to save it. This involved transforming the AI’s JSON response into a format that Django could use.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Solution:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Data Pipeline:&lt;/strong&gt; I created a pipeline to convert the AI’s JSON into Django objects, handling errors to manage incomplete or incorrect data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Persistent Storage:&lt;/strong&gt; The selected recipe, with any user changes, is stored in the database for future use.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Overcoming Technical Hurdles
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Limited System Resources:&lt;/strong&gt;&lt;br&gt;
My PC wasn’t powerful, so I had to work in safe mode, which made it hard to run PostgreSQL.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Solution:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Registry Tweaks:&lt;/strong&gt; I tweaked the system’s registry settings to allow PostgreSQL to work in safe mode.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Optimized Workflow:&lt;/strong&gt; I wrote scripts to make common tasks easier, reducing the system’s load and making work faster.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Lack of Documentation:&lt;/strong&gt;&lt;br&gt;
There weren’t many guides on integrating Django with GroqCloud for AI, so I had to figure out a lot on my own.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Solution:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Self-Documentation:&lt;/strong&gt; I documented my process to help myself and others in the future.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Community Help:&lt;/strong&gt; I reached out to the developer community for advice and shared what I learned.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What’s Next: Improving User Experience
&lt;/h3&gt;

&lt;p&gt;The next step is to make the user experience better by letting the AI suggest different recipes if the user doesn’t have enough ingredients for the first choice. This will require both backend and frontend updates.&lt;/p&gt;

&lt;h3&gt;
  
  
  Lessons Learned
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Break Tasks into Small Steps:&lt;/strong&gt; Breaking down complex tasks into smaller ones makes them easier to manage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Define Clear Data Structures:&lt;/strong&gt; Creating a clear data structure early on helps avoid issues later.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Manage Resources Wisely:&lt;/strong&gt; Optimizing your work environment, especially with limited resources, can improve productivity.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Building myChefAssist has been a tough but rewarding experience. I’ve learned a lot about AI integration, backend development, and solving problems with limited resources. I’m excited to keep working on the project.&lt;/p&gt;

&lt;p&gt;If you’ve faced similar challenges or have tips on AI integration with Django, let’s connect and share ideas!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>django</category>
      <category>llama</category>
      <category>backend</category>
    </item>
    <item>
      <title>Building myChefAssist with AI: Lessons Learned and How to Avoid Pitfalls</title>
      <dc:creator>Eben</dc:creator>
      <pubDate>Tue, 30 Jul 2024 06:54:43 +0000</pubDate>
      <link>https://dev.to/nezer/building-mychefassist-with-ai-lessons-learned-and-how-to-avoid-pitfalls-1p54</link>
      <guid>https://dev.to/nezer/building-mychefassist-with-ai-lessons-learned-and-how-to-avoid-pitfalls-1p54</guid>
      <description>&lt;p&gt;When I embarked on creating an AI-powered chef assistant, I wanted to solve a real need instead of building another generic chatbot. The idea was simple yet practical: a web app that helps users prepare meals based on the ingredients they have.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Concept&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Users enter the dish they want to prepare. The app, leveraging AI, asks follow-up questions to refine the dish type. It then lists all required ingredients, allowing users to select which ones they have. If the user doesn't have enough ingredients, the app either suggests a different dish or tells them the minimal additional ingredients needed to make the original dish.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Starting the Backend&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;I began by outlining the basic features and setting up the backend. Using Django and PostgreSQL, I created the project, set up the database, and defined the models. The setup process for PostgreSQL was straightforward:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install PostgreSQL&lt;/strong&gt;: Download and install the latest version from the official PostgreSQL website.&lt;br&gt;
Create a Database: Use the createdb command or pgAdmin to create a new database for the project.&lt;br&gt;
&lt;strong&gt;Connect Django to PostgreSQL&lt;/strong&gt;: Update Django's settings.py with the database credentials, ensuring the ENGINE is set to 'django.db.backends.postgresql'.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Choosing the Right AI Model&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The real challenge was selecting an AI model to run locally on my PC. I opted for Llama 3.1, the latest model available. I started with the 8B version, considering my PC's capabilities. After downloading the model (4.7GB), I tested it with a simple "hi" query. The response time was painfully slow, and my PC became unresponsive.&lt;/p&gt;

&lt;p&gt;After trying stablelm-zephyr, which promised to be lightweight, and facing similar issues, I moved on to other models like those available on Hugging Face. Still, the performance wasn't there. Finally, I switched to Llama 3.1 on GroqCloud, which provided fast responses in less than a second, saving the day.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons Learned
&lt;/h2&gt;

&lt;p&gt;Assess Hardware Capabilities: Ensure your hardware can handle the AI model you're planning to use. Overloading your system can lead to severe performance issues.&lt;br&gt;
Start Small: Begin with lighter models and scale up as needed. This helps prevent unnecessary strain on your system.&lt;br&gt;
Cloud Solutions: Sometimes, using cloud-based solutions like GroqCloud can save you time and resources.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;p&gt;The next step involves connecting user inputs to the AI model and storing the responses in the database. The data will be categorized and saved under columns like User Queries, Selected Ingredients, Suggested Recipes, and Missing Ingredients.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What AI challenges have you faced, and how did you overcome them? Share your experiences!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>django</category>
      <category>postgres</category>
      <category>llama</category>
    </item>
    <item>
      <title>🚀 Exploring Django with React 🚀</title>
      <dc:creator>Eben</dc:creator>
      <pubDate>Tue, 30 Jul 2024 05:26:03 +0000</pubDate>
      <link>https://dev.to/nezer/exploring-django-with-react-4g8f</link>
      <guid>https://dev.to/nezer/exploring-django-with-react-4g8f</guid>
      <description>&lt;p&gt;Kicking off my series with Django and React! Combining Django’s backend with React’s frontend... Thinking of an AI-based project. Follow along as I share what I learn from this project.&lt;/p&gt;

&lt;p&gt;What challenges have you faced using Django with React? Share your thoughts! 💬&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>django</category>
      <category>react</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
