<?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: Hugo Romano</title>
    <description>The latest articles on DEV Community by Hugo Romano (@adaptive).</description>
    <link>https://dev.to/adaptive</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%2F149987%2F31d7ee65-1c34-49b6-9ff0-018ddbdbf0cd.jpg</url>
      <title>DEV Community: Hugo Romano</title>
      <link>https://dev.to/adaptive</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adaptive"/>
    <language>en</language>
    <item>
      <title>Maximizing Efficiency with Cloudflare's AI Gateway</title>
      <dc:creator>Hugo Romano</dc:creator>
      <pubDate>Tue, 31 Oct 2023 16:33:01 +0000</pubDate>
      <link>https://dev.to/adaptive/maximizing-efficiency-with-cloudflares-ai-gateway-4njn</link>
      <guid>https://dev.to/adaptive/maximizing-efficiency-with-cloudflares-ai-gateway-4njn</guid>
      <description>&lt;p&gt;In the contemporary realm of AI applications, efficiency and control are paramount. &lt;a href="https://developers.cloudflare.com/ai-gateway/"&gt;Cloudflare's AI Gateway&lt;/a&gt; emerges as a game-changer, offering remarkable advantages: observability, caching and rate-limiting.&lt;/p&gt;

&lt;p&gt;The cost-saving aspect is excellent, serving requests directly from Cloudflare's cache rather than the original model provider (if cached). Additionally, the in-built rate limiting feature is a robust measure against potential abuse, ensuring your application scales gracefully without being overwhelmed by excessive requests ​and burning your wallet.&lt;/p&gt;

&lt;p&gt;I use it to interact with OpenAI API, but this Gateway also supports &lt;a href="https://ai.cloudflare.com/"&gt;Cloudflare Workers AI&lt;/a&gt;, Azure OpenAI, HuggingFace and &lt;a href="https://replicate.com/"&gt;Replicate&lt;/a&gt;. In addition, there is a &lt;a href="https://developers.cloudflare.com/ai-gateway/providers/universal/"&gt;Universal Endpoint&lt;/a&gt; that helps you set up a fallback provider when a request fails.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Power of Caching
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MsRTbaj8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/07g281z1qcl7waynnlf1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MsRTbaj8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/07g281z1qcl7waynnlf1.jpg" alt="Dashboard of cost and caching" width="800" height="391"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Caching can be set from one minute to one year, and in my case, it caches from &lt;code&gt;text-embeddings&lt;/code&gt; to &lt;code&gt;gpt-3.5&lt;/code&gt;. In the above screenshot of a non-production app, the savings were 50% instead of calling OpenAI directly, plus faster response speeds.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rate-limit your Wallet
&lt;/h2&gt;

&lt;p&gt;Every time you release your App into production, you question if some bad actor will run you to the ground. The Rate-limit feature will enable you to control the frequency and volume of requests made to your app, thereby avoiding any unnecessary charges or misuse of resources. Rate-limit from 1 minute to 1 hour period, fixed or sliding.&lt;/p&gt;

&lt;h2&gt;
  
  
  Observability
&lt;/h2&gt;

&lt;p&gt;In the case of OpenAI API, observability is very limited. The Real-time logs feature on the Gateway is bliss. You can turn it on or off as you like.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;Visit &lt;a href="https://developers.cloudflare.com/ai-gateway/"&gt;Cloudflare's AI Gateway Docs&lt;/a&gt; and if you use &lt;a href="https://www.npmjs.com/package/openai"&gt;OpenAI NPM Package&lt;/a&gt; is a easy as setting up &lt;code&gt;baseURL&lt;/code&gt;.&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;OpenAI&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;openai&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;openai&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;my api key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// defaults to process.env["OPENAI_API_KEY"]&lt;/span&gt;
    &lt;span class="na"&gt;baseURL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://gateway.ai.cloudflare.com/v1/ACCOUNT_TAG/GATEWAY/openai&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;



</description>
      <category>ai</category>
      <category>workers</category>
      <category>cloudflare</category>
    </item>
    <item>
      <title>IPFS:🦠Pandemic resilient infrastructure</title>
      <dc:creator>Hugo Romano</dc:creator>
      <pubDate>Thu, 19 Mar 2020 18:30:47 +0000</pubDate>
      <link>https://dev.to/adaptive/ipfs-pandemic-resilient-infrastructure-5aap</link>
      <guid>https://dev.to/adaptive/ipfs-pandemic-resilient-infrastructure-5aap</guid>
      <description>&lt;p&gt;This is a unique moment for Humanity, that will touch everyone. "Shoulder to shoulder" (social distanced) we will support each other.&lt;/p&gt;

&lt;p&gt;Remote working is now mandatory for many nations and #StayAtHome 🏠 is the most important strategy against &lt;a href="https://www.who.int/emergencies/diseases/novel-coronavirus-2019/advice-for-public"&gt;SARS-CoV-2&lt;/a&gt;, flattening the curve of CoViD-19 cases, but this move will stress the Internet infrastructure.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2lTuq-6L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b0jgha09e5nkf71m4j02.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2lTuq-6L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b0jgha09e5nkf71m4j02.jpg" alt="IPFS Logo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One thing we can do about this is to use &lt;a href="https://ipfs.io/"&gt;IPFS&lt;/a&gt; (The InterPlanetary File System) and other distributed filesystems to store and safeguard relevant public health literature, e.g. situation reports, guidelines, scientific papers. In the case of network intermittence, we will all have this data available.&lt;/p&gt;

&lt;p&gt;Here are some examples:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;World Health Organization CoViD-19 Situation Reports&lt;/em&gt;&lt;br&gt;
&lt;a href="https://ipfs.io/ipfs/QmPaidwPiMKfqgdz9f39hKdM4rcgJBymRYTHtxgKG1tR2A"&gt;QmPaidwPiMKfqgdz9f39hKdM4rcgJBymRYTHtxgKG1tR2A&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;WHO Coping with stress during the 2019-nCoV outbreak&lt;/em&gt;&lt;br&gt;
&lt;a href="https://ipfs.io/ipfs/QmTWsDwfRvmLbG1vs2c3UncZXCGFBNTv1jcPvTNaZaNxZ5"&gt;QmTWsDwfRvmLbG1vs2c3UncZXCGFBNTv1jcPvTNaZaNxZ5&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Portugal CoViD-19 Situation Reports&lt;/em&gt;&lt;br&gt;
&lt;a href="https://ipfs.io/ipfs/QmYCoAKArCKLQAwzYQ2VdYnL4dP9tCrhD97JQuqUQCBqAb"&gt;QmYCoAKArCKLQAwzYQ2VdYnL4dP9tCrhD97JQuqUQCBqAb&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It doesn't stop here, your creativity will find more use cases.&lt;/p&gt;

&lt;p&gt;Set up your node, &lt;a href="https://ipfs.io/#get-started"&gt;get started today&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ipfs</category>
      <category>decentralized</category>
      <category>covid19</category>
    </item>
  </channel>
</rss>
