<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0"><channel><title>Pulumi Blog: Localai</title><link>https://www.pulumi.com/blog/tag/localai/</link><description>Pulumi blog posts: Localai.</description><language>en-us</language><pubDate>Mon, 26 Feb 2024 06:00:00 -0800</pubDate><item><title>Deploy Low-Code LLM Apps on AWS with Flowise and LocalAI</title><link>https://www.pulumi.com/blog/low-code-llm-apps-with-local-ai-flowise-and-pulumi/</link><pubDate>Mon, 26 Feb 2024 06:00:00 -0800</pubDate><guid>https://www.pulumi.com/blog/low-code-llm-apps-with-local-ai-flowise-and-pulumi/</guid><description>
&lt;img src="https://www.pulumi.com/images/generated/blog/low-code-llm-apps-with-local-ai-flowise-and-pulumi/index.png" /&gt;
&lt;p&gt;Building low-code LLM applications just got easier! With &lt;a href="https://flowiseai.com/"&gt;Flowise&lt;/a&gt;, &lt;a href="https://localai.io/"&gt;LocalAI&lt;/a&gt;, and Pulumi, you can quickly create, deploy, and manage AI-powered workflows on AWS EKS—without writing complex code.&lt;/p&gt;
&lt;p&gt;In this guide, you’ll learn how to:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Set up a low-code LLM application using Flowise &amp;amp; LocalAI&lt;/li&gt;
&lt;li&gt;Deploy it on AWS EKS with Pulumi &amp;amp; TypeScript&lt;/li&gt;
&lt;li&gt;Create a chatbot workflow and expose it via API&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Flowise simplifies LLM orchestration with a drag-and-drop interface, while LocalAI enables local inference without requiring a GPU. Pulumi streamlines cloud infrastructure deployment with just a few lines of code.&lt;/p&gt;
&lt;p&gt;Whether you’re a developer looking to experiment with LLMs on AWS or an AI enthusiast exploring serverless AI applications, this step-by-step tutorial will guide you through the entire process. Let’s dive in!&lt;/p&gt;
&lt;h2 id="flowise-the-low-code-tool-for-llm-orchestration"&gt;Flowise: The Low-Code Tool for LLM Orchestration&lt;/h2&gt;
&lt;p&gt;&lt;img src="flowise.gif" alt="gift depicting Flowise in action"&gt;&lt;/p&gt;
&lt;p&gt;Flowise is an open-source low-code/node tool for developers to build customized LLM orchestration workflows and AI
agents. The low-code approach helps developers to cut down on the time and effort required to build LLM applications by
delivering quick iterations to from testing to production. In Flowise nodes are referred to as integrations, and you can
build a customized LLM orchestration flow, chatbot, or AI agent by dragging and dropping these integrations. There are
plenty of ready-to-use integrations available in Flowise, like LangChain or &lt;a href="https://www.llamaindex.ai/"&gt;LlamaIndex&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="localai-open-source-llm-inference-for-aws--on-prem"&gt;LocalAI: Open-Source LLM Inference for AWS &amp;amp; On-Prem&lt;/h2&gt;
&lt;p&gt;&lt;img src="localai.png" alt="LocalAI logo"&gt;&lt;/p&gt;
&lt;p&gt;LocalAI is a free and Open Source alternative to OpenAI. It acts as a drop-in replacement for OpenAI&amp;rsquo;s REST API that is
fully compatible with the OpenAI API specifications for local inference. It allows you to run LLMs, generate images, or
audio locally or on-prem with consumer grade hardware supporting multiple model families and architectures. And the
clue: It does not require a GPU, it runs on CPU only (optional GPU acceleration is still available).&lt;/p&gt;
&lt;p&gt;Once LocalAI loaded the model the first time, it keeps it in memory for faster inference. It does not shell-out, but use
bindings to the model for faster inference and better performance. It is a great way to test and benchmark different
models directly on your local machine or on-prem. Additionally, you are not sending your data to a third-party service,
which may contain sensitive information. This is a big advantage, especially in large enterprises or in the public
sector where data privacy is a big concern.&lt;/p&gt;
&lt;h2 id="deploying-flowise--localai-on-aws-with-pulumi"&gt;Deploying Flowise &amp;amp; LocalAI on AWS with Pulumi&lt;/h2&gt;
&lt;p&gt;Covered a lot of the basics, but let&amp;rsquo;s get started with the real thing. To quickly get started, you can use the example
project from the Pulumi examples repository.&lt;/p&gt;
&lt;p&gt;The AWS architecture of the example project is as follows:&lt;/p&gt;
&lt;p&gt;&lt;img src="architecture.png" alt="AWS Architecture diagram of a low-code LLM app using Pulumi, Flowise, LocalAI, and EKS"&gt;&lt;/p&gt;
&lt;p&gt;The Pulumi AWS architecture consists of the following resources:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;An EKS cluster with a managed node group.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volumes.html"&gt;EBS volume&lt;/a&gt; support for the &lt;a href="https://docs.aws.amazon.com/eks/latest/userguide/clusters.html"&gt;EKS cluster&lt;/a&gt; to store the downloaded LocalAI models.&lt;/li&gt;
&lt;li&gt;Deployment of the Helm chart for Flowise and LocalAI.&lt;/li&gt;
&lt;li&gt;A VPC, two subnets in different availability zones, and an internet gateway, and security groups for the EKS cluster.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As programming language, I will use TypeScript, but you can use any other language supported by Pulumi. Rewriting the
example code should be straightforward. Feel free to reach out to us if you need help.&lt;/p&gt;
&lt;h3 id="create-a-flowise-chatbot"&gt;Create a Flowise Chatbot&lt;/h3&gt;
&lt;p&gt;Our first Flowise workflow will be a simple chatbot. This simple LLM chain will be stateless (no memory) with a prompt
template and our LocalAI LLM model attached.&lt;/p&gt;
&lt;h4 id="deploy-the-infrastructure-with-pulumi"&gt;Deploy the Infrastructure with Pulumi&lt;/h4&gt;
&lt;p&gt;First clone the &lt;a href="https://github.com/pulumi/examples/"&gt;example repository&lt;/a&gt;, and head to the &lt;code&gt;aws-ts-localai-flowise&lt;/code&gt;
directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git clone https://github.com/pulumi/examples.git
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; examples/aws-ts-localai-flowise
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To deploy the infrastructure with Pulumi, you can use the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pulumi login &lt;span class="c1"&gt;# if you haven&amp;#39;t logged in yet&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pulumi up
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Next to the definition of the AWS EKS cluster, the Pulumi program uses the &lt;code&gt;pulumi-kubernetes&lt;/code&gt; provider to deploy the
Helms charts for Flowise and LocalAI.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-typescript" data-lang="typescript"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;// imports omitted for brevity
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kr"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="kr"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;k8s&lt;/span&gt; &lt;span class="kr"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;@pulumi/kubernetes&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;// code omitted for brevity
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;// Manually creation of the Kubernetes provider, with the kubeconfig from the EKS cluster and the enableServerSideApply set to true
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kr"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;provider&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;k8s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Provider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;k8s&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;kubeconfig&lt;/span&gt;: &lt;span class="kt"&gt;cluster.kubeconfigJson&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;enableServerSideApply&lt;/span&gt;: &lt;span class="kt"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;// Deploy the Helm charts for LocalAI
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kr"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;localai&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;k8s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;helm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;v3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Release&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;local-ai&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;chart&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;local-ai&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;version&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;3.2.0&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;repositoryOpts&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;repo&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;https://go-skynet.github.io/helm-charts&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;forceUpdate&lt;/span&gt;: &lt;span class="kt"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="kr"&gt;namespace&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;local-ai&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;createNamespace&lt;/span&gt;: &lt;span class="kt"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;values&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;deployment&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;image&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;repository&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;quay.io/go-skynet/local-ai&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;tag&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;latest&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;debug&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;true&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;context_size&lt;/span&gt;: &lt;span class="kt"&gt;512&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;modelsPath&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;/models&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;resources&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;requests&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;cpu&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;8&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;memory&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;32Gi&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;models&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;list&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;https://gpt4all.io/models/ggml-gpt4all-j.bin&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;ggml-gpt4all-j&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;],&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;persistence&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;models&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;50Gi&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;storageClass&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;gp2&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;accessModes&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;ReadWriteOnce&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;output&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;10Gi&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;storageClass&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;gp2&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;accessModes&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;ReadWriteOnce&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;provider&lt;/span&gt;: &lt;span class="kt"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;// Deploy the Helm charts for Flowise
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kr"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;flowise&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;k8s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;helm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;v3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Release&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;flowise&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;chart&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;flowise&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;version&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;2.5.0&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;repositoryOpts&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;repo&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;https://cowboysysop.github.io/charts/&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="kr"&gt;namespace&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;flowise&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;createNamespace&lt;/span&gt;: &lt;span class="kt"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;provider&lt;/span&gt;: &lt;span class="kt"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Depending on your AWS region, the deployment can take a few minutes. Once the deployment is complete, you will have
access to &lt;code&gt;kubeconfig&lt;/code&gt; file to access the EKS cluster for the next steps.&lt;/p&gt;
&lt;p&gt;To retrieve the kubeconfig file, you can use the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pulumi stack output kubeconfig --show-secrets &amp;gt; kubeconfig.yaml
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now you can use the &lt;code&gt;kubeconfig.yaml&lt;/code&gt; file either with &lt;code&gt;kubectl&lt;/code&gt; or with the &lt;code&gt;KUBECONFIG&lt;/code&gt; environment variable to access
the EKS cluster.&lt;/p&gt;
&lt;div class="note note-info"&gt;
&lt;div class="icon-and-line"&gt;
&lt;svg xmlns="http://www.w3.org/2000/svg" class="ph-icon ph-icon--fill" fill="currentColor" aria-hidden="true" focusable="false"&gt;&lt;use href="https://www.pulumi.com/icons/sprite.70121449e0dde6f8c01ff68423fffaa0336ecc73c7bbc87506404126694ca58c.svg#p-info-fill"/&gt;&lt;/svg&gt;
&lt;div class="line"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="content"&gt;&lt;p&gt;As we are not using a load balancer, we will use the &lt;code&gt;kubectl port-forward&lt;/code&gt; command to access the Flowise UI. The
command is:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kubectl port-forward svc/&lt;span class="k"&gt;$(&lt;/span&gt;kubectl get svc -n flowise &lt;span class="p"&gt;|&lt;/span&gt; grep flowise &lt;span class="p"&gt;|&lt;/span&gt; awk &lt;span class="s1"&gt;&amp;#39;{print $1}&amp;#39;&lt;/span&gt;&lt;span class="k"&gt;)&lt;/span&gt; 3000:3000 -n flowise
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;h4 id="start-modeling-the-chatbot-with-flowise"&gt;Start modeling the Chatbot with Flowise&lt;/h4&gt;
&lt;p&gt;Open the Flowise UI in your browser with the following URL: &lt;a href="http://localhost:3000"&gt;http://localhost:3000&lt;/a&gt; and click
the &lt;code&gt;Chartflows&lt;/code&gt; menu item in the left sidebar. And then click the blue button &lt;code&gt;+ Add New&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="flowise-charflow.png" alt="FlowiseAI dashboard depicting the Chatflows page where new chatflows can be added"&gt;&lt;/p&gt;
&lt;p&gt;This should open a new window where you can drag and drop the nodes to the main window. To display
the available nodes, click the &lt;code&gt;+&lt;/code&gt; button on the left.&lt;/p&gt;
&lt;img src="./nodes.png" width=70% style="margin-left: auto; margin-right: auto;"&gt;
&lt;p&gt;First we add our LocalAI node to the chartflow. Look under &lt;code&gt;Chat Models&lt;/code&gt; for the ChatLocalAI node and drag it to the
main canvas.&lt;/p&gt;
&lt;p&gt;Fill out the form with the following values:&lt;/p&gt;
&lt;img src="./chatlocalai.png" width=70% style="margin-left: auto; margin-right: auto;"&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Base Path: This should be name ouf your &lt;code&gt;LocalAI&lt;/code&gt; Kubernetes service. You can find it with the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kubectl get svc -n local-ai
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And should be in the form of &lt;code&gt;http://&amp;lt;svc-name&amp;gt;.local-ai.svc.cluster.local:80&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Model Name: The name of the model you want to use. You can find the available models with the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kubectl &lt;span class="nb"&gt;exec&lt;/span&gt; -it &lt;span class="k"&gt;$(&lt;/span&gt;kubectl get pods -n local-ai &lt;span class="p"&gt;|&lt;/span&gt; grep local-ai &lt;span class="p"&gt;|&lt;/span&gt; awk &lt;span class="s1"&gt;&amp;#39;{print $1}&amp;#39;&lt;/span&gt;&lt;span class="k"&gt;)&lt;/span&gt; -n local-ai -- curl http://localhost:8080/models &lt;span class="p"&gt;|&lt;/span&gt; jq &lt;span class="s1"&gt;&amp;#39;.data[0].id&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This will return the name of the model you can use. For example &lt;code&gt;ggml-gpt4all-j_f5d8f27287d3&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Temperature: The temperature of the model. This is a float value between 0 and 1. The higher the value, the more
creative the model will be. The lower the value, the more conservative the model will be. Keep the default value of
&lt;code&gt;0.9&lt;/code&gt; for now.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now we can add the next node to our workflow. Search for &lt;code&gt;Prompt Template&lt;/code&gt; and drag this node to the main canvas as
well. You can fill out the &lt;code&gt;Template&lt;/code&gt; field with the following value:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Question: {input}.
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;img src="./prompt-template.png" width=70% style="margin-left: auto; margin-right: auto;"&gt;
&lt;p&gt;As a last step we need to add the &lt;code&gt;LLM Chain&lt;/code&gt; node to the workflow. Head over to the &lt;code&gt;Chains&lt;/code&gt; section of our nodes
menu and drag the &lt;code&gt;LLM Chain&lt;/code&gt; node to the main canvas. Give the chain a name &lt;code&gt;chatbot&lt;/code&gt;.&lt;/p&gt;
&lt;img src="./chatbot.png" width=70% style="margin-left: auto; margin-right: auto;"&gt;
&lt;p&gt;This done, we can start to connect different nodes to each other. Start with the &lt;code&gt;Prompt&lt;/code&gt; and &lt;code&gt;Language Model&lt;/code&gt; nodes by
dragging the arrow from the &lt;code&gt;Language Model&lt;/code&gt; dot to the &lt;code&gt;ChatLocalAI&lt;/code&gt; node. Same for the &lt;code&gt;Prompt&lt;/code&gt; dot to
the &lt;code&gt;Prompt Template&lt;/code&gt; node.&lt;/p&gt;
&lt;img src="./connected-nodes.png" width=70% style="margin-left: auto; margin-right: auto;"&gt;
&lt;p&gt;Now we can save the chartflow and test it. Click the &lt;code&gt;Save&lt;/code&gt; icon in the top right corner and then click the &lt;code&gt;Dialog&lt;/code&gt;
button to display the chatbot. You can now test the chatbot by typing a question in the input field and see the
response. In my case, I asked the chatbot &lt;code&gt;How does an airplane fly in the air?&lt;/code&gt; and got the following response:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;There are several methods by which an airplane flies in the air, including:
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Lift and Weight: An airplane flies by exploiting its weight in the vertical direction. Therefore, it is necessary for an aircraft to have a strong and heavy enough structure that can hold its weight in the air. The more an airplane weighs, the greater is its lift and climb capability.
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Air Density: An airplane exploits the difference in air density below and above it. Airborne objects experience the same buoyant force that causes them to rise. By doing this, an aircraft can maintain a stable position and ascend or descend.
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Airfoil Design: The shape of an aircraft’s airfoil is designed such that it allows for the efficient and effective generation of lift force. The shape, thickness and angle control the air flow over the wings of an aircraft.
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Control Arm: The control bar controls the angle of attack, pitch and yaw control. By moving the bar, pilots can change and adjust these features of the aircraft.
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Propulsion Systems: An airplane requires propulsion systems to provide the thrust needed for takeoff, climb and movement through the air. Engines such as piston, turbojet, diesel engine or rocket engines are commonly used. The combustion process in these systems produces heat, which provides thrust.
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Radio Communication: Aircraft can communicate with air traffic control in real-time, allowing pilots and air traffic controllers to coordinate their actions. This communication is essential for safe and efficient air travel.
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;img src="./answer.png" width=70% style="margin-left: auto; margin-right: auto;"&gt;
&lt;p&gt;Go ahead and test your chatbot with different questions! It is a great way to test different LLM models and see how they
behave.&lt;/p&gt;
&lt;h4 id="expose-the-chatbot-via-api"&gt;Expose the Chatbot via API&lt;/h4&gt;
&lt;p&gt;If you want to expose the chatbot workflow via API or SDK, you can use Flowise for this as well. Flowise provides a REST
API for this purpose. Head in your workflow view to the top right corner and click the &lt;code&gt;&amp;lt;/&amp;gt;&lt;/code&gt; button. This will open a
new dialog with all the different methods you can use. This range from embedding the chatbot in your website to using to
directly call the REST API.&lt;/p&gt;
&lt;p&gt;&lt;img src="integration.png" alt="Flowise chatbot embed options showing JavaScript code snippet for integrating a chatbot into a website."&gt;&lt;/p&gt;
&lt;p&gt;There is even the option to enable authorization for the REST API. This is a great way to secure your chatbot and only
allow authorized users to access it.&lt;/p&gt;
&lt;h4 id="housekeeping"&gt;Housekeeping&lt;/h4&gt;
&lt;p&gt;If you want to destroy the stack, you can use the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pulumi destroy
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The Pulumi CLI will ask you to confirm the changes, and if you are happy with the changes, you can confirm them by
typing &lt;code&gt;yes&lt;/code&gt; and all the resources will be deleted.&lt;/p&gt;
&lt;h2 id="in-conclusion"&gt;In Conclusion&lt;/h2&gt;
&lt;p&gt;In this blog post, we have seen how easy it is to build a LLM application with Flowise and LocalAI without the need to
use any code. This is a great way to quickly prototype and test different LLM models and workflows. We have also seen
how easy it is to deploy the infrastructure with Pulumi and how easy it is to destroy the stack if we don&amp;rsquo;t need it
anymore.&lt;/p&gt;
&lt;div class="note note-info"&gt;
&lt;div class="icon-and-line"&gt;
&lt;svg xmlns="http://www.w3.org/2000/svg" class="ph-icon ph-icon--fill" fill="currentColor" aria-hidden="true" focusable="false"&gt;&lt;use href="https://www.pulumi.com/icons/sprite.70121449e0dde6f8c01ff68423fffaa0336ecc73c7bbc87506404126694ca58c.svg#p-info-fill"/&gt;&lt;/svg&gt;
&lt;div class="line"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="content"&gt;&lt;p&gt;Want to get hands on with LangServe and walk through it live? We have two upcoming dates for a workshop focused on
LangChain and LangServe!&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.pulumi.com/resources/deploying-langchain-applications-on-aws-with-pulumi"&gt;Deploying LangChain Applications on AWS with Pulumi&lt;/a&gt;
on March 14, 2024&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.pulumi.com/resources/deploying-langchain-apps-on-aws-with-pulumi"&gt;Deploying LangChain Applications on AWS with Pulumi&lt;/a&gt;
again on April 17, 2024&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;As always, we welcome your feedback and contributions in
the &lt;a href="https://slack.pulumi.com/"&gt;Pulumi Community Slack&lt;/a&gt;, &lt;a href="https://github.com/pulumi/pulumi"&gt;GitHub repository,&lt;/a&gt;
and &lt;a href="https://github.com/pulumi/pulumi/discussions"&gt;Pulumi Community Discussions&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;New to Pulumi? Signing up is easy and free. &lt;a href="https://www.pulumi.com/docs/get-started/"&gt;Get started today&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;Happy AI building!&lt;/p&gt;</description><author>Engin Diri</author><category>ai</category><category>localai</category><category>flowise</category><category>pinecone</category><category>aws</category><category>eks</category><category>langchain</category><category>llamaindex</category></item></channel></rss>