Flowwiseは、ビジュアルなUIビルダーであり、ChatGPTを会社のデータと迅速に統合することができます。LangChainを活用して、大規模な言語モデルアプリを効率的に構築します。著者は、リポジトリのクローン、APIキーの設定、会話型AIモデルの構築など、セットアップに関する手順を提供しています。彼らは、チャットボットのプロトタイプを紹介し、Flowwiseの特徴を強調しています。また、Flowwiseの迅速なプロトタイピングやAI実験における潜在的な利用例と利点についても議論しています。
公開日:2023年5月26日
※動画を再生してから読むのがオススメです。
現在、すべての企業が抱える焦燥の問いは、「どのようにしてChatGPTを自社のデータと統合すればよいのか?」です。
そして、私はそれを文字通り10分で行う方法を見つけました。
それが今日のビデオでお見せするものです。
Flowwiseは、大規模な言語モデルアプリを文字通り数分で構築できるビジュアルUI Builderです。
どのようにセットアップすればいいのか、どのように始めればいいのか、そして、自分のデータに関する質問に答えることができる会話型AIを構築するところまでをお見せします。
では、さっそく始めてみましょう。
さてさて、今日はFlowwiseについて見ていきましょう: 大規模な言語モデルアプリを簡単に構築できます。
では、なぜこれがそんなにすごいのか?
まず、オープンソースであること。つまり、ダウンロードしてGitHubのリポジトリから直接読み込むだけで、使い始めることができる。
ローカルで起動すれば、ご覧のようなビジュアルな「Builder」が表示されます。
ビルディングブロックをつなげて、シンプルなアプリを作ることができるのです。
このアプリのクールなところ、そして私がこのアプリを気に入っている理由は、ボンネットの下がすべてLangChainであることです。
私はLangChainでかなり実験をしていて、私のGitHubのリポジトリはこちらで見ることができます(リンクは説明の中で提供されます)。しかし、本当にクールなのは、大規模な言語モデルアプリを立ち上げるのに非常に強力なLangChainを、ビジュアルなBuilderから使えるようになったことです。
これにより、大規模な言語モデル・アプリのプロトタイプを数分で作成し、その機能をテストし、そこから拡張することができるようになります。
このチュートリアルに従うには、OpenAI APIキーが必要です。これは無料で設定できますが、クエリを実行するたびにごく少額の課金が発生するため、クレジットカードを記入する必要があります。
また、Pinecone APIキーも必要です。これも現在無料で設定でき、このチュートリアルではクレジットカードは必要ありません。
では、まず始めるために、FlowwiseのGitHubリポジトリにアクセスし、このリポジトリ全体をクローンします。
Gitを使うのが初めてなら、まずその方法についてのチュートリアルを調べてください。
しかし、ここでリンクをコピーし、それからあなたのプロジェクトに移ります。私の場合、それは既にVSCode内で起動しているLangChain実験プロジェクトです。
その後、あなたがやることは、ターミナルを開くことです。だからここで新しいターミナルに移ることができます。そしてまず最初に、フォルダを保存する場所を確認します。
右上にある、私の場合はFlowwiseのフォルダーです。
このフォルダはすでにありますが、まず、「ここはどのプロジェクトディレクトリなのか」を確認します。
これは、VSCodeからでも、ターミナルやコマンドプロンプトからでも可能です。
そして、git cloneを実行し、ここにURLを入力し、コピーペーストします。こうすることで、基本的には、ここに表示されているフォルダ全体をリポジトリからクローンし、システム上にローカルに存在させることができます。
これがステップ1です。
さて、リポジトリに戻りますが、readmeを下にスクロールすると、これを起動する方法が2つあることがわかります。
クイックスタートに従ってnpmを使用するか、Dockerを使用するかです。
npmを使いたい場合は、説明の中でリンクしているnpmをシステムにインストールする必要があります。
しかし、私はDockerを使うつもりで、そのためにはDockerをインストールする必要があります。
繰り返しますが、これらのツールはどちらも無料で、インストールはとても簡単です。
npmについては、このチュートリアルに従います。
Dockerについては、docker.comにアクセスして(リンクは説明文にもあります)、Dockerをダウンロードしてインストールするだけです。
実行されていることを確認してください。
インストールしたらアプリを開いてください。
私がDockerを使う理由は、より柔軟性を持たせるためです。
ポート3000は私のシステムですでに使用されています。
Dockerを使えば、ポートを指定することができる。
そのために、Dockerに従います。
fias codeに戻り、クローンしたflowwiseフォルダの中を探します。
それを開いてみてください。
Dockerフォルダがあり、そこにDOT EMVというサンプルファイルがあります。
そのファイルを.envにリネームして、ポートを使いたいものに変更します。
デフォルトの3000のままでもOKです。
私はすでに使われているので別のポートを使っています。
リポジトリをクローンし、npmやDockerをインストールした状態で、アプリケーションを立ち上げてみます。
Dockerの例に従います。
プロジェクトのdockerフォルダ内で、Docker compose upを-Dフラグ付きで実行することにします。
そのためには、トップレベルのland chain experimentsフォルダのターミナルにいることを確認します。
そして、flowwiseに移動し、Dockerに移動します。
Dockerにいることを確認します。
LSを実行すると、docker-compose.yamlファイルが表示されるはずです。
ここで、Docker-compose up -Dを実行します。これでDockerコンテナがスピンアップされ、アプリケーションを実行するためのローカルサーバーが起動します。
Dockerがバックグラウンドで動作していることを確認してください。
まずアプリケーションをダウンロードし、それが起動していることを確認します。
起動したら、ブラウザで新しいタブを開き、localhostにアクセスし、先ほどのポートを指定します。
これで、アプリケーションの中、flowwise AIの中に入りました。
これは本当にエキサイティングです!
ここにはすでに2つの例がありますが、これらをゼロから構築する方法をお見せします。
まず、会話検索QAチェーンから始めましょう。
マーケットプレイスで、その例を探してください。
すでにいくつかのボイラープレートが用意されているので、それをスタートとして使うことができます。
好きなものを選んでください。
あとは、いくつかのパラメータとAPIキーを入力して、開始することになります。
テンプレートを保存し、名前を付けます。
次に、左から右へ進み、各ステップを設定します。
OpenAI API キーを入力します。
openai.comのポータルで探して、貼り付けます。
次に、Pineconeを設定します。
Pinecone APIキーをコピーして貼り付け、環境とインデックスを選択します。
Pineconeコンソールに移動し、create indexを選択し、名前を付けます。
正しい次元を指定する。これはOpenAIのエンベッディングで使われている数である。
名前空間は空白にしておきます。
設定を保存します。
これで、APIキーとPineconeの設定は完了です。
これでデータとのチャットを開始する準備ができました。
設定を保存します。
今度は、txtファイルなどのファイルをアップロードします。
もう一度保存してください。
チャットインターフェイスを開き、質問をしてみましょう。
では、別の例、会話型AIに移りましょう。
こちらもserp APIのAPIキーが必要です。
APIキーを記入し、ツールを設定します。
flowwiseのインターフェイスで、利用可能なビルディングブロックをすべて確認できます。
異なるファイルタイプを使用したい場合は、ファイルローダーを入れ替えましょう。
様々なツールや機能性を試すことができます。
HTMLやPythonのコードにflowwise AIアプリケーションを埋め込むこともできます。
npmについては、このチュートリアルに従います。
Dockerの場合は、docker.comにアクセスするだけです。
リンクは説明文にもあります。
そこでDockerをダウンロードしてインストールし、実行されていることを確認します。
で、インストールしたらアプリを開いてください。
Dockerを使う理由は、ポート3000が私のシステムですでに使用されているため、もう少し柔軟性を持たせるためです。
そして、これを使えば、ポートを指定することができます。
そのためには、Dockerについて行けば、Fiasのコードに戻ってこれるわけです。
先ほどリポジトリからクローンしたFlowwiseのフォルダの中を見て、開いてみてください。
Dockerフォルダがあり、最初はDOT EMVのサンプルファイルが入っています。
そのファイルを.EMVにリネームして、こっちのポートを使いたいポートに変更してください。
デフォルトの3000のままでもかまいません。
さっきも言ったように、すでに使われているポートだから別のポートを使うんだ、いいね?
リポジトリをクローンし、npmをインストールするかDockerをインストールすれば、アプリケーションを起動することができます。
ここではDockerの例に従って、プロジェクトのDockerフォルダ内でDocker composeをDフラグ付きで実行することにします。
では、どのように実行するのでしょうか?
まず最初に、ターミナルで自分がどこにいるのかを確認します。
Landchain Experimentsフォルダの最上位にいるので、まずFlowwiseにCDを入れ、次にDockerにCDを入れます。
そして、Dockerにいることを確認してください。
docker-composeファイルがここにあります。
私はこれをMacでやっています。
Windowsの場合は少し違うかもしれませんが、原理は同じです。
ターミナルをこのフォルダに設定し、LSを実行するとdocker-composeのYAMLファイルが表示されるはずです。
次にできることは、Docker Compose up -dを実行することです。
これでDockerコンテナが起動し、アプリケーションを実行するためのローカルサーバが基本的に起動します。
このように、コンテナをスピンアップすることができます。
また、Dockerが起動していることを確認してください。
まずアプリケーションをダウンロードし、バックグラウンドで実行されていることを確認します。
起動したら、ブラウザで新しいタブを開き、localhostにアクセスしてください。
そして、先ほどのポートを指定します。
これで、Flowwise AIの中にあるアプリケーションの中に入ったことになります。
これは本当にエキサイティングでしょう?
すでに2つの例がありますが、これからゼロから構築する方法を紹介しますよ。
まずは、会話検索のQAチェーンから始めましょう。
派手な言葉ですが、マーケットプレイスに行き、その例をこちらで見ることができます。
とても便利ですね。
すでにいくつかの定型文が用意されているので、まずはそれを使うことができます。
そこで、これを選択することにします。
すでに流れが見えているので、あとは基本的にいくつかのパラメータとAPIキーを入力すれば、すぐに始められます。
このテンプレートを使って、まずこれを保存し、このドキュメントをチャットボットと呼ぶことにします。
さて、左から右へ進み、基本的に「これはテキストの分割です」と言います。
前回のLangChainのチュートリアルを覚えている方は、このようにドキュメントをチャンクして、トークン制限を超えないようにAIに送り込むことができます。
ここではtxtファイルをアップロードすることができるので、これもすでに用意されている。
そして今、私たちはここに二つのOpenAIブロックを持っています:一つはチャット用、もう一つはデータ、テキストを私たちが類似性検索を行うために使用できるベクトルに変換するためのものです。
それでは、まずOpenAIのAPIキーを入力する必要があります。
OpenAI APIキーはopenai.comのポータルで見つけることができます。
次に、Pineconeを設定する必要があります。
まず、PineconeのAPIキーをコピーして貼り付けます。
これをここに貼り付けます。
そして、環境とインデックスを選択する必要があります。
そのためには、Pineconeのコンソールに戻ってください。
インデックスを作成し、好きな名前をつけることができます。
ご覧のように、すでにテスト用のインデックスがあるので、これを使用します。
そして、名前です。重要なのは、正しい寸法を指定することで、それはこちらの数字です。
これは、OpenAIのエンベッディングで使用する数値だからで、これから使用します。
この数字を指定して、インデックスを作成するを選択します。
ご覧のように、私たちはスターター・プランで、コストはかからず、7日間のストレージだけなので、必ず作成してください。
それから、環境をコピーする必要があります。
ご覧の通り、私はAsia South East GCPにいます。それをここにある環境に入れ、そしてテストケースのように、ここにあなたのインデックスを指定します。
Namespaceは必須ではありません、何のためにあるのかわかりませんが、空白のままでも構いません。
これでAPIキーの設定とPineconeの設定が完了し、データとのチャットを開始する準備ができました。
保存して、ドキュメントチャットボットを作成します。そして、最後にファイルをアップロードします。
Landchain実験ゲッターリポジトリのreadmeと呼ばれる簡単なtxtファイルを用意しましたので、これをインポートします。
txtファイルができたので、それを保存して、魔法が起こるのを見ましょう。
チャット・インターフェースを開き、「このドキュメントは何について書かれていますか?
このドキュメントはLandchainに関するもので、大規模な言語モデルによって駆動されるアプリケーションを開発するために設計された包括的なフレームワークです。
そして、10分以内に自分のデータに関する質問に答えることができるチャットボットを作成しました。
そして実は、その裏で起こっていることは、かなり興味深いものです。
Landchainを使っているのですが、ご覧の通り、非常にわかりやすい方法になっています。
しかし、この製品の素晴らしいところは、少なくとも私が本当に素晴らしいと思うところは、ご覧のように、これをラピッドプロトタイピングに使えるということなのです。
ですから、これで完全なアプリケーションを作る自信はありませんが、それはボンネットの中で何が起こっているのかよくわからないからです。
しかし、Landchainの中でアクセス可能なビルディングブロックを使い、OpenAIとエンベッディングやPineconeを結びつけていることは知っています。
これで実験ができたので、テストと検証を行い、前に進むことができます。
さて、この例では、テキストファイルを使用しています。
しかし、Flowwiseの素晴らしいところは、このプラスマークをクリックすると、使用可能なすべてのビルディングブロックを簡単に見ることができることです。
ドキュメントローダーでは、CSV、docx、Geto、Pages、Jsonのファイルを読み込むことができます。
例えば、これはテキストファイルではありませんから、これを削除して、「PDFにしたいんだけど」といって、ここにドラッグして、点と点を結ぶだけです。
これがテキストスプリッターで、そしてこっちのドキュメント、ドーン、これでPDFをアップロードすることができます。さて、これはすべてLangChainですでに可能な機能ですが、皆さんはすでにご存知なかったかもしれません。
LangChainのドキュメントを見ると、ドキュメントローダーが紹介されていますが、ここにはFlowwiseに統合されているドキュメントローダーがほとんど紹介されています。
もしこれがうまくいけば、LangChainにアクセスして、「PDFをどうやって読み込むか?
そして、カスタムコードを使ってそれを作成し、完全に理解することができます。
これが、今のFlowwiseのイメージです。
もう1つのクールな例をお見せしましょう。
これはマーケットプレイスから選ぶことができる別の例で、私は何も変えていません。
APIキーを組み込んだだけです。これにはSERP APIも必要で、これはインターネット検索に使えるツールなので、そのためのAPIキーが必要です。
また、これが無料だと思いますが、ここでは会話型エージェントがあります。そして私たちは言えます、「これが彼らが使えるツールです:計算機とインターネットのアクセス」。
そして、OpenAIというチャットモデルがあり、さらにメモリがあります。
この会話エージェントは、基本的に会話を覚えていなければなりません。
つまり、あなたが何かを言った後、2回プロンプトが出たとしても、最初にあなたが何を言ったかを覚えている必要があります。
そうでなければ、かなり愚かな会話AIになってしまいます。
これがバッファメモリの役割です。
ここで私たちができる面白いことは、別のチャットを開き、「ねえ、デイブ・エブラーって誰?彼の購読者数はどれくらい?」と聞くことができます。
というように、ChatGPTに質問しても出てこないようなことです。
今、舞台裏で起きていることは、このチャットエージェントがまずこの質問を分析し、「この情報を収集するために何かツールが必要か」と判断していることです。
そして、ご覧のように、これがその結果です。
Dave Eblarはフリーランスのデータサイエンティストで、13.4kのチャンネル登録者、42本の動画をYouTubeで公開しています。
では早速、その正確性を見てみましょう。
現在13.7人ですが、43本の動画は正しいです。
どこからこの数字を取得しているのかは全く分かりませんが、インターネットに接続されていることは間違いありません。
次に私たちができる面白いことについて説明します。これは会話型エージェントで、記憶機能を持ち、計算機能のようなツールも持っています。たとえば、「その購読者数を4倍したら何になるか?」と聞くことができます。
このように、数字を参照せず、ただ質問するだけなので、「これが購読者数です。
では、早速確認してみましょう。以前、あるビデオでこの計算機に騙されたことがあるからです。
では、13.4×4で計算してみましょう。
ドキッ、ぴったりだ。
よし、これで正解だ。
これで、あなたは基本的に、すべてのツールを使って遊ぶことができる、とてもクールなサンドボックスを手に入れたことになります。
この中に入れば、さらに多くのツールがあります。
ファイルのAPIリクエストの読み取り、ウェブブラウジング、ファイルの書き込みができます。
このビジュアル・ビルド・フォルダーで、いろいろなものをつなげて、遊んでみることができます。
さて、最後に紹介するのは、この埋め込みボタンをクリックすることで、かなりクールなものになります。
これはHTMLを使った簡単な埋め込みですが、私が今興味を持っているのはPythonです。
ここで、簡単なPythonファイルを作成することができるのですが、私はすでにここで作成しました。
Flowwiseフォルダの中に、シンプルなSourceフォルダを作成し、connect.piを置きました。そしてここにある全てをコピー&ペーストし、クエリで遊びました。
このインタラクティブ・セッションを立ち上げて、クエリーを実行します。
Dave Abelarとは誰で、購読者は何人いるのか?
では、これを実行してみましょう。
単純なprint文を追加して、結果も出力するようにしました。
フリーランスのデータサイエンティストであることがわかります。
私たちは今、同じ答えを持っています。そして注意すべき1つの良いこと、そして私が理解するのに時間がかかったのは、バッファメモリからのメモリキーと入力キーの扱い方です。
Flowwiseは非常に新しいもので、こっちのリポジトリに来れば、coming soonのようなドキュメントを見ることができるわけです。
ですから、それが現状では、Flowwise AIを使う、特にこのように自分のアプリケーションに組み込みたい場合の欠点と言えると思います。
それから、今はあまりドキュメントがありません。
そこで、この例をコピー&ペーストするだけでは、メモリが考慮されないと考えました。
しかし、メモリキーと入力キーを追加するだけで、LangChainでやっているのと同じように、このように動作します。
では、例えば同じように、「加入者数を4倍した値はいくらですか?
これは、前のメッセージにアクセスできることを確認するための良いテストです。
ご覧のように、ここでも同じ結果が得られます。
もちろん、これはローカル・サーバー上のものですが、これを実際のサーバーに配備して、実際のエンドポイントにすることも可能です(基本的には対話が可能です)。
これは、前回のビデオで、Azureを使ってAIアプリをクラウドに展開する方法を紹介したものです。
ご興味のある方は、前回のビデオをご覧ください。
以上、Flowwiseを簡単に説明しました。
本当に素晴らしいソフトウェアで、これを短期間で作成し、オープンソースにしたクリエイターに大きな賛辞を送ります。
そして、オープンソースにしたことで、私たちはこのソフトウェアで遊ぶことができます。
これはとてもエキサイティングだと思います。そして、私がこれまでに言ったように、これが私のスタックと私のワークフローにどのように適合するかは、アイデアを迅速にテストして評価し、迅速なプロトタイピングを行うためになります。
現在、私はクライアントのために多くのAIプロジェクトを行っていますが、このツールは間違いなくアイデアを素早くテストし評価するのに役立ちます。
ただ、このツールを使ってエンドツーエンドのアプリケーションを作るのではなく、個々のコンポーネントをテストし、レーンチェーンを使って自分自身で構築するつもりです。
これが、少なくとも私のワークフローの流れです。
そして、もしあなたがフリーランサーとしてAIサービスをクライアントに販売する方法に興味があるなら、説明文の最初のリンクをチェックしてみてください。
このビデオはこれでおしまいです。
このビデオに「いいね!」とチャンネル登録をお願いします。