<?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>Forem: Beaudry Jean Sauvenel</title>
    <description>The latest articles on Forem by Beaudry Jean Sauvenel (@jsbeaudry).</description>
    <link>https://forem.com/jsbeaudry</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%2F249271%2F6c5ced89-f192-469b-b66f-2ff3bc501348.jpg</url>
      <title>Forem: Beaudry Jean Sauvenel</title>
      <link>https://forem.com/jsbeaudry</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/jsbeaudry"/>
    <language>en</language>
    <item>
      <title>Introducing the Stream GPT Data Extraction NPM Package!</title>
      <dc:creator>Beaudry Jean Sauvenel</dc:creator>
      <pubDate>Wed, 09 Aug 2023 02:04:17 +0000</pubDate>
      <link>https://forem.com/jsbeaudry/introducing-the-stream-gpt-data-extraction-npm-package-1j5</link>
      <guid>https://forem.com/jsbeaudry/introducing-the-stream-gpt-data-extraction-npm-package-1j5</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Xd5o7Sh0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f0x4d1hpasiuy3hfx2cv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Xd5o7Sh0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f0x4d1hpasiuy3hfx2cv.png" alt="Stream GPT Data Extraction NPM Package" width="800" height="530"&gt;&lt;/a&gt;&lt;br&gt;
I am excited to announce the release of the Stream GPT Data Extraction NPM package, a powerful tool that brings a new level of interactivity and dynamism to your applications powered by OpenAI’s GPT-4 language model. With this package, developers can now interact with GPT-4 in real-time, stream partial prompts, receive intermediate responses, and even extract objects from the generated text before the full response is received. This opens up a world of possibilities for building dynamic and intelligent applications that leverage the capabilities of GPT-4.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Stream GPT Data Extraction?&lt;/strong&gt;&lt;br&gt;
Traditionally, when using language models, developers had to wait for the complete response after sending a prompt. However, this process can be limiting for certain use cases where real-time interaction and extraction of relevant information are crucial. The Stream GPT Data Extraction NPM package addresses this limitation by offering a more flexible and efficient way to work with GPT-4, allowing users to tailor their responses and extract valuable objects from the generated text on-the-fly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Getting Started&lt;/strong&gt;&lt;br&gt;
To get started with the Stream GPT Data Extraction NPM package, you’ll need to install it first. Open your terminal or command prompt and run one of the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install stream-gpt-data-extraction sse.js
OR
yarn add stream-gpt-data-extraction sse.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Import methods first&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import {
  StreamTextResponse,
  StreamObjectResponse,
} from "stream-gpt-data-extraction";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Initializing GPT-4 Text Streaming To begin using GPT-4 Text Streaming, you will need your OpenAI API key and the prompt. If you don’t have an API key yet, head over to the OpenAI website and sign up to obtain one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;StreamTextResponse(
    OPENAI_KEY,
    "Hello",
    (response) =&amp;gt; console.log("RESPONSE", response),
    (status)   =&amp;gt; console.log("STATUS", status)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Initializing GPT-4 Objects Streaming For GPT-4 Object Streaming, the process is similar. You’ll need your OpenAI API key and the prompt.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;StreamObjectResponse(
    OPENAI_KEY,
    "Two Chuck Norris Jokes to make you laugh",
    (response) =&amp;gt; console.log("RESPONSE", response),
    (status)   =&amp;gt; console.log("STATUS", status)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How it Works&lt;/strong&gt;&lt;br&gt;
The Stream GPT Data Extraction NPM package utilizes Server-Sent Events (SSE) to establish a continuous connection with the GPT-4 language model. This enables a seamless stream of partial responses that are received and processed in real-time. Additionally, the ability to extract objects from the generated text as it is being generated allows developers to fine-tune their applications and obtain relevant information without waiting for the entire response.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
The Stream GPT Data Extraction NPM package brings a new era of interactivity and dynamism to applications powered by OpenAI’s GPT-4 language model. With the ability to stream partial prompts, receive intermediate responses, and extract objects from the generated text, developers can create more interactive and intelligent applications than ever before. We can’t wait to see the innovative applications and experiences you will build with this powerful tool.&lt;/p&gt;

&lt;p&gt;Get started with Stream GPT Data Extraction today and unleash the full potential of GPT-4 in your projects! Happy coding!&lt;/p&gt;

&lt;p&gt;👇🏽👇🏽👇🏽👇🏽👇🏽👇🏽👇🏽👇🏽👇🏽👇🏽👇🏽👇🏽👇🏽👇🏽👇🏽👇🏽👇🏽👇🏽👇🏽&lt;br&gt;
&lt;a href="https://www.npmjs.com/package/stream-gpt-data-extraction"&gt;https://www.npmjs.com/package/stream-gpt-data-extraction&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🇭🇹🇭🇹🇭🇹 Made with love by &lt;a href="https://twitter.com/jsbeaudry"&gt;jsbeaudry&lt;/a&gt; from Haiti 🇭🇹 🇭🇹 🇭🇹&lt;/p&gt;

</description>
      <category>chatgpt</category>
      <category>gpt3</category>
      <category>ai</category>
      <category>react</category>
    </item>
    <item>
      <title>How create a USD Bank on Ethereum, BSC and Polygon blockchain?</title>
      <dc:creator>Beaudry Jean Sauvenel</dc:creator>
      <pubDate>Mon, 20 Dec 2021 03:00:27 +0000</pubDate>
      <link>https://forem.com/jsbeaudry/how-create-a-usd-bank-on-eth-bsc-polygon-27h9</link>
      <guid>https://forem.com/jsbeaudry/how-create-a-usd-bank-on-eth-bsc-polygon-27h9</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1cqx9ixokti6yvtbxb85.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1cqx9ixokti6yvtbxb85.png" alt="How create a USD Bank on ETH, BSC, Polygon"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The digital currency revolution is now spreading to the banking industry, as cryptocurrency begins to reshape the way people borrow and save.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Decentralized finance, or DeFi, describes an alternative financial ecosystem where consumers transfer, exchange, borrow, and lend cryptocurrency, independent of the traditional financial institutions and regulatory structures that have been built around banking services and the central bank.&lt;/p&gt;

&lt;p&gt;In this article, I will show you how to start your own bank without the approval of your country's central bank. I have always been fascinated by how to change the banking system in my country (Haiti) where almost all banking services are reserved and concentrated to a group of people and the majority of the population does not have a bank account and does not even access to basic credit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's started:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We're going to use the ERC20 standard from Ethereum. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ERC20?&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Ethereum request for comment&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;An ERC20 token is a standard used for creating and issuing smart contracts on the Ethereum (BSC, Polygon, Avalanche, etc..) blockchain. Smart contracts can then be used to create smart property or tokenized assets that people can invest in. ERC stands for "Ethereum request for comment," and the ERC20 standard was implemented in 2015.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;

interface IERC20 {

    function totalSupply() external view returns (uint);

    function balanceOf(address account) external view returns (uint);

    function transfer(address recipient, uint amount) external returns (bool);

    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint amount) external returns (bool);

    function transferFrom(
        address sender,
        address recipient,
        uint amount
    ) external returns (bool);

    event Transfer(address indexed from, address indexed to, uint value);

    event Approval(address indexed owner, address indexed spender, uint value);

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first part content the minimum you need as parent functions to create your bank smart contract. &lt;/p&gt;

&lt;p&gt;Understand these functions above: &lt;a href="https://ethereum.org/en/developers/tutorials/understand-the-erc-20-token-smart-contract/" rel="noopener noreferrer"&gt;https://ethereum.org/en/developers/tutorials/understand-the-erc-20-token-smart-contract/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now it's time to code our smart contract:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
contract DefiBank {

    // call it DefiBank
    string public name = "DefiBank";

    //Owner of the bank
    address public owner;

    // create 2 state variables
    address public usdc;      // The token you will accept
    address public bankToken; // The token that represents your bank that will be used to pay interest

    // create 1 array to add all your clients
    address[] public stakers;

    // create a 3 maps 
    mapping(address =&amp;gt; uint) public stakingBalance; //Clients balance
    mapping(address =&amp;gt; bool) public hasStaked; // Find out if this customer has created an account
    mapping(address =&amp;gt; bool) public isStaking; // Find out if this customer is using their account

    ......
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;New we will create the functions to interact with these variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;......

    // In constructor pass in the address for USDC token,  set your custom bank token and the owner will be who will deploy the contract
    constructor() public {
        usdc = INPUT-USDC-TOKEN-ADDRESS-RELATE-TO-THE-BLOACKCHAIN;
        bankToken = INPUT-YOUR-TOKEN-ADDRESS-HERE;
        owner = msg.sender;
    }

......
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;......

    // Change the ownership 
     function changeOwner(address newOwner) public {
    // require the permission of the current owner
        require(owner == msg.sender, “Y”our are not the current owner);
        owner = newOwner;
    }

......
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.......

 // allow user to deposit usdc tokens in your contract

    function deposit(uint _amount) public {

        // Transfer usdc tokens to contract
        IERC20(usdc).transferFrom(msg.sender, address(this), _amount);

        // Update the account balance in map
        stakingBalance[msg.sender] = stakingBalance[msg.sender] + _amount;

        // Add user to stakers array if they haven't staked already
        if(!hasStaked[msg.sender]) {
            stakers.push(msg.sender);
        }

        // Update staking status to track
        isStaking[msg.sender] = true;
        hasStaked[msg.sender] = true;
    }

......
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;......

    // allow user to withdraw total balance and withdraw USDC from the contract

     function withdrawTokens() public {

        // get the users staking balance in usdc
        uint balance = stakingBalance[msg.sender];

        // require the amount staked needs to be greater then 0
        require(balance &amp;gt; 0, "staking balance can not be 0");

        // transfer usdc tokens out of this contract to the msg.sender (client)
        IERC20(usdc).transfer(msg.sender, balance);

        // reset staking balance map to 0
        stakingBalance[msg.sender] = 0;

        // update the staking status
        isStaking[msg.sender] = false;

} 

......
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;......

    // Send bank tokens as a reward for staking. You can change the way you need to give interest if you want

    function sendInterestToken() public {
    // require the permission of the current owner
        require(owner == msg.sender, "Your are not the current owner");

        for (uint i=0; i&amp;lt;stakers.length; i++) {
            address recipient = stakers[i];
            uint balance = stakingBalance[recipient];

    // if there is a balance transfer the same amount of bank tokens to the account that is staking as interest

            if(balance &amp;gt;0 ) {
                IERC20(bankToken).transfer(recipient, balance);

            }

        }

    }
......


}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's all you need to disrupt your country's banking system.&lt;/p&gt;

&lt;p&gt;Remember to create the bank token separately before deploying the smart contract.&lt;/p&gt;

&lt;p&gt;Thanks, hope this minimal smart contract will help a lot of you.&lt;/p&gt;

&lt;p&gt;Complete code:  &lt;a href="https://gist.github.com/jsbeaudry/d61de7c738cc31018e210f3a96ba1508" rel="noopener noreferrer"&gt;https://gist.github.com/jsbeaudry/d61de7c738cc31018e210f3a96ba1508&lt;/a&gt;&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>smartcontract</category>
      <category>ethereum</category>
      <category>bank</category>
    </item>
    <item>
      <title>Build and publish an api quickly with express.</title>
      <dc:creator>Beaudry Jean Sauvenel</dc:creator>
      <pubDate>Mon, 14 Oct 2019 03:20:00 +0000</pubDate>
      <link>https://forem.com/jsbeaudry/build-and-publish-an-api-quickly-with-express-1pgn</link>
      <guid>https://forem.com/jsbeaudry/build-and-publish-an-api-quickly-with-express-1pgn</guid>
      <description>&lt;p&gt;Today when you plan to build an api many things come in your head like you say why not use a serverless platform like Firebase, AWS, Stich etc. Because build an api can take some time to:&lt;/p&gt;

&lt;p&gt;1- Identify the entities &lt;br&gt;
2- Manage the relationship between them&lt;br&gt;
3- Plan the routes&lt;br&gt;
4- Authentification&lt;br&gt;
5- Security&lt;br&gt;
6- Etc.&lt;/p&gt;

&lt;p&gt;In this article i am going to show you how you can build an Api easily. To start we will use node.js with express as the main tools.&lt;/p&gt;

&lt;p&gt;The first thing you need to do is identify our entities by example we will do a api for a blog.&lt;/p&gt;

&lt;p&gt;As entities we have : users, articles, comments&lt;/p&gt;

&lt;p&gt;Now let's start:&lt;/p&gt;

&lt;p&gt;1 - Download and install node if not yet done.&lt;br&gt;
    link: &lt;a href="https://nodejs.org/en/"&gt;https://nodejs.org/en/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2 - Install Yoeman,&lt;br&gt;
    Yeoman helps you to kickstart new projects, prescribing best &lt;br&gt;
    practices and tools to help you stay productive.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  $ npm install -g yo
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;3 - Install generator-api&lt;br&gt;
    Generator for creating RESTful NodeJS APIs, using ES6, &lt;br&gt;
    Mongoose and Express. The fastest way to get your project up and &lt;br&gt;
    running using an awesome stack.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  $ npm install -g generator-api
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;4 - Ok, once done type yo api and answer the questions&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  $ yo api
  ? Server name: blog-api
  ? Server description: Api to manage my blog
  ? Server version: 1.0.0
  ? Author name: Jean Sauvenel Beaudry
  ? Author email: sauvene2013@gmail.com
  ? Models: (singular and comma separated) users,articles,comments
  ? what should the database be named? mongo_string_db
  ? would you like to have Docker included in the app? No
  create package.json
  create config.js
  create index.js
  create routes.js
  create .gitignore
  create .eslintrc.json
  create .eslintignore
  create lib/controller.js
  create lib/facade.js
  create model/users/controller.js
  create model/users/facade.js
  create model/users/router.js
  create model/users/schema.js
  create model/articles/controller.js
  create model/articles/facade.js
  create model/articles/router.js
  create model/articles/schema.js
  create model/comments/controller.js
  create model/comments/facade.js
  create model/comments/router.js
  create model/comments/schema.js
  create README.md 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;5 - Alright our blog is created. To test it we need to connect the api with a database. To do that we are going to use MongoDB&lt;/p&gt;

&lt;p&gt;MongoDB is a cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with schema. It's a super database platform to start. Go on the link to create a mongo database instance like that:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mongodb+srv://user:passwordx@cluster.mongodb.net/database_name?retryWrites=true&amp;amp;w=majority
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Link: &lt;a href="https://www.mongodb.com"&gt;https://www.mongodb.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;6 - Go to config.js replace mongodb://localhost/mongo_string_db with your new mongodb string or use a .env file to affect MONGO_DB_URI (recommend for more secure).&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   const config = {
   environment: process.env.NODE_ENV || 'dev',
   server: {
   port: process.env.PORT || 8080
   },
   mongo: {
   url: process.env.MONGO_DB_URI || 
   'mongodb://localhost/mongo_string_db'
   }
  }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;7 - Now we are ready to go. Just type&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  $ npm start  or yarn start
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You can use postman test your CRUD. &lt;/p&gt;

&lt;p&gt;Next articles:&lt;br&gt;
1 - Secure this Api.&lt;br&gt;
2 - Authenticate your users&lt;br&gt;
3 - Grow it by adding new model&lt;br&gt;
6 - Deploy with a single command line using  Zeit (Now)&lt;/p&gt;

&lt;p&gt;Thank you for reading. My current project : &lt;a href="https://www.snipplabs.com/"&gt;https://www.snipplabs.com/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>express</category>
      <category>javascript</category>
      <category>api</category>
    </item>
  </channel>
</rss>
