<?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: Chiheb Nabil</title>
    <description>The latest articles on DEV Community by Chiheb Nabil (@chihebnabil).</description>
    <link>https://dev.to/chihebnabil</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%2F460640%2F00cb7bf4-5eb1-46bf-8578-7845bcc7c720.jpeg</url>
      <title>DEV Community: Chiheb Nabil</title>
      <link>https://dev.to/chihebnabil</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chihebnabil"/>
    <language>en</language>
    <item>
      <title>Why I built Aipify. co - A Platform for building AI Powred Apis</title>
      <dc:creator>Chiheb Nabil</dc:creator>
      <pubDate>Fri, 01 Mar 2024 11:04:49 +0000</pubDate>
      <link>https://dev.to/chihebnabil/why-i-built-aipify-co-a-platform-for-building-ai-powred-apis-3iik</link>
      <guid>https://dev.to/chihebnabil/why-i-built-aipify-co-a-platform-for-building-ai-powred-apis-3iik</guid>
      <description>&lt;p&gt;One of the biggest challenges the developer may face is structuring ChatGPT responses when building production-ready apps. You want your responses to be consistent since the app's frontend is expecting a specific field. With OpenAI, you have two main ways to achieve that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Learning prompt engineering techniques to achieve the desired structure.&lt;/li&gt;
&lt;li&gt;Using the function calling feature.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The problem is that if you want to change anything, you have to alter that hardcoded prompt and push it again. Additionally, if you want to cache a specific response to avoid additional costs, you have to implement that on your backend.&lt;/p&gt;

&lt;p&gt;I learned this the hard way when building the first version of &lt;a href="https://trycompass.co"&gt;Compass&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Step by step, I found myself building a whole SaaS service that I'm currently using for all my ChatGPT projects and ideas.&lt;/p&gt;

&lt;p&gt;This is how the Aipify idea was born. After over one month of building and tweaking, this is the version of &lt;a href="https://aipify.co"&gt;Aipify&lt;/a&gt;, and guess what?  It has a monthly free quota. &lt;/p&gt;

&lt;p&gt;You can experiment with GPT-4 for free, and I'm eager to hear your feedback 😄&lt;/p&gt;

</description>
      <category>openai</category>
      <category>api</category>
      <category>ai</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Why I Built the SES Easy Mailer Node Module</title>
      <dc:creator>Chiheb Nabil</dc:creator>
      <pubDate>Thu, 01 Feb 2024 13:17:06 +0000</pubDate>
      <link>https://dev.to/chihebnabil/why-i-built-the-ses-easy-mailer-node-module-5eic</link>
      <guid>https://dev.to/chihebnabil/why-i-built-the-ses-easy-mailer-node-module-5eic</guid>
      <description>&lt;p&gt;As a software developer, I often find myself in situations where I need to send emails from my applications. &lt;/p&gt;

&lt;p&gt;Whether it's for sending notifications, password resets, or promotional content, email is a crucial part of many web applications.&lt;/p&gt;

&lt;p&gt;Amazon's Simple Email Service (SES) is a reliable and scalable solution for sending emails, but it can be a bit complex to use directly. That's why I decided to build the SES Easy Mailer Node module.&lt;/p&gt;

&lt;h2&gt;
  
  
  Making Email Sending Easier with SES
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/ses-easy-mailer"&gt;The SES Easy Mailer module&lt;/a&gt; simplifies the process of sending emails using Amazon SES. &lt;/p&gt;

&lt;p&gt;It provides a simple and easy-to-use interface for sending emails, abstracting away the complexities of the underlying SES APIs. &lt;/p&gt;

&lt;p&gt;This makes it a great choice for developers who want to leverage the power of Amazon SES without having to deal with its intricacies.&lt;/p&gt;

&lt;p&gt;Here's a simple example of how to send an email with SES Easy&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createTransporter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;sendMail&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ses-easy-mailer&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;SESClient&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@aws-sdk/client-ses&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SESClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;region&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;us-east-1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;credentials&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;accessKeyId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;secretAccessKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;transporter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createTransporter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using Local Html Template
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sender@example.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;recipient@example.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;subject&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello, world!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;templateType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;file&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;templatePath&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./template.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;templateData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John Doe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;attachments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;sendMail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;transporter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;subject&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;templateType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;templatePath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;templateData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;attachments&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;to&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using SES Template
&lt;/h3&gt;

&lt;p&gt;On the other hand, if you prefer to use SES's built-in template system, SES Easy Mailer has got you covered. &lt;br&gt;
You can create and manage your templates directly in SES and simply reference them by name when sending emails. This is a great option for developers who want to manage their templates separately from their code.&lt;/p&gt;

&lt;p&gt;Here's an example of how to send an email using an SES template:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;templateType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ses&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;templateName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;se-template-name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// The name of the template you created in SES&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;sendMail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;transporter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;subject&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;templateType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;templateName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;templateData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;attachments&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;to&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Simplifying Attachments and Templating
&lt;/h2&gt;

&lt;p&gt;Adding attachments to your emails is as simple as passing an array of objects, each representing an attachment. &lt;br&gt;
The module takes care of the rest, ensuring that your attachments are correctly included in the sent email.&lt;/p&gt;

&lt;p&gt;Here's an example of how to send an email with attachments :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;buffer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Buffer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hello world!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;utf-8&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;attachments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;test.txt&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;buffer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;encoding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;base64&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Building the &lt;a href="https://www.npmjs.com/package/ses-easy-mailer"&gt;SES Easy Mailer Node module&lt;/a&gt; has been a fun and rewarding experience. It's always great to build something that not only solves your own problems but can also be useful to other developers. If you're looking for a simple and easy-to-use solution for sending emails with Amazon SES, I encourage you to give SES Easy Mailer a try !&lt;/p&gt;

</description>
      <category>node</category>
      <category>ses</category>
      <category>mail</category>
      <category>javascript</category>
    </item>
    <item>
      <title>OpenAI API Mock for Devs on a Budget</title>
      <dc:creator>Chiheb Nabil</dc:creator>
      <pubDate>Mon, 29 Jan 2024 15:27:54 +0000</pubDate>
      <link>https://dev.to/chihebnabil/openai-api-mock-for-devs-on-a-budget-2785</link>
      <guid>https://dev.to/chihebnabil/openai-api-mock-for-devs-on-a-budget-2785</guid>
      <description>&lt;p&gt;Hey, fellow devs! Ever been working on a project, eager to test your OpenAI integration, only to be held back by the dreaded API call limits? Well, fear not! I've got a nifty solution for you, and it involves a touch of magic and a dash of mock-tastic sorcery.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧙‍♂️ Introducing OpenAI API Mock
&lt;/h2&gt;

&lt;p&gt;Say hello to openai-api-mock, a Node.js module that's here to turn your development environment into a playground for all your OpenAI API dreams. No more worrying about unnecessary API charges during testing – it's time to unleash the power of mock responses!&lt;/p&gt;

&lt;h2&gt;
  
  
  🌟 Why Did I Create This Module?
&lt;/h2&gt;

&lt;p&gt;Picture this: you're knee-deep in developing a project, excited to test your OpenAI integration. However, you hit a roadblock – the dreaded API call limits. &lt;/p&gt;

&lt;p&gt;Here's the twist – I needed a way to mock API responses, especially when dealing with &lt;strong&gt;function-calling&lt;/strong&gt; structured responses &amp;amp; API costs can spiral during development and testing phases, and I yearned for a tool that could empower developers to experiment freely with OpenAI without the fear of skyrocketing bills. Thus, &lt;code&gt;openai-api-mock&lt;/code&gt; was born,&lt;/p&gt;

&lt;h2&gt;
  
  
  🎩 How to Work Your Mock Magic
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Install the Wizardry
&lt;/h3&gt;

&lt;p&gt;Start by installing this enchanting module using npm. Open your terminal and type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-D&lt;/span&gt; openai-api-mock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Summon the Mock Response
&lt;/h3&gt;

&lt;p&gt;In your JavaScript file, conjure the mock response with a simple incantation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;mockOpenAIResponse&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;openai-api-mock&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;mockOpenAIResponse&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, every time your code attempts to make an OpenAI API call, it will receive a magical mock response. No API call limits, no charges – just pure wizardry at play!&lt;/p&gt;

&lt;h2&gt;
  
  
  🧐 What's Under the Hood?
&lt;/h2&gt;

&lt;p&gt;This magical module depends on the powers of nock for intercepting HTTP calls and @faker-js/faker for generating fake data. It's a dynamic duo ensuring your OpenAI API calls are met with whimsical responses.&lt;/p&gt;

&lt;p&gt;🚀 Conclusion&lt;br&gt;
With the power of mock responses in your hands, you're ready to take your OpenAI journey to new heights without worrying about the cost. openai-api-mock is here to make your development experience enchanting and budget-friendly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/chihebnabil/openai-api-mock"&gt;Github Repo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>openai</category>
      <category>node</category>
      <category>mock</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
