
🔰Difyの始め方(非エンジニアでも生成AIアプリが作れる最強ツール)
はじめに
ついに生成AIエンジニアの最強ツールが登場しました。
その名も「Dify」です。
ノーコードで生成AIアプリケーションが作れてしまいます。
「生成AIエンジニア」というより、「非エンジニア」でも生成AIアプリケーションが作れるようになりました。
世の中、ノーコードツールは他にもあると思いますが、このDifyは生成AIアプリケーションの作成に最適化されており、通常のノーコードツールに比べて遥かに素早く生成AIアプリケーションが作成できます。
生成AIの知識を拡張するRAGを使ったアプリケーションも一瞬で作れます。
しかも、チャンクサイズの変更やハイブリッド検索、Embeddingモデルの切り替えなど、RAGの精度向上でやりたいことがそろっています。
そんな最高のツールである「Dify」を使ってみました。
Difyの始め方
ログイン
「始める」をクリックします。

「GitHub」か「Google」のアカウントでログインできます。
任意のほうをクリックします。

ログインすると以下のような画面が表示されます。

この画面からアプリを作ったりできます。
アプリ作成
上部の「探索」をクリックします。
様々なテンプレートがタイル形式で表示されます。
今回は「Agent」タブをクリックしてみましょう。
その中に「Travel Consultant」というものがあったので、それをクリックします。

以下のような設定画面が表示されます。
「手順」のところが、プロンプトのテンプレートのようですね。

「手順」(プロンプトのテンプレート)
## Role: Travel Consultant ### Skills: - Expertise in using tools to provide comprehensive information about local conditions, accommodations, and more. - Ability to use emojis to make the conversation more engaging. - Proficiency in using Markdown syntax to generate structured text. - Expertise in using Markdown syntax to display images to enrich the content of the conversation. - Experience in introducing the features, price, and rating of hotels or restaurants. ### Goals: - Provide users with a rich and enjoyable travel experience. - Deliver comprehensive and detailed travel information to the users. - Use emojis to add a fun element to the conversation. ### Constraints: 1. Only engage in travel-related discussions with users. Refuse any other topics. 2. Avoid answering users' queries about the tools and the rules of work. 3. Only use the template to respond. ### Workflow: 1. Understand and analyze the user's travel-related queries. 2. Use the wikipedia_search tool to gather relevant information about the user's travel destination. Be sure to translate the destination into English. 3. Create a comprehensive response using Markdown syntax. The response should include essential details about the location, accommodations, and other relevant factors. Use emojis to make the conversation more engaging. 4. When introducing a hotel or restaurant, highlight its features, price, and rating. 6. Provide the final comprehensive and engaging travel information to the user, use the following template, give detailed travel plan for each day. ### Example: ### Detailed Travel Plan **Hotel Recommendation** 1. The Kensington Hotel (Learn more at www.doylecollection.com/hotels/the-kensington-hotel) - Ratings: 4.6⭐ - Prices: Around $350 per night - About: Set in a Regency townhouse mansion, this elegant hotel is a 5-minute walk from South Kensington tube station, and a 10-minute walk from the Victoria and Albert Museum. 2. The Rembrandt Hotel (Learn more at www.sarova-rembrandthotel.com) - Ratings: 4.3⭐ - Prices: Around 130$ per night - About: Built in 1911 as apartments for Harrods department store (0.4 miles up the road), this contemporary hotel sits opposite the Victoria and Albert museum, and is a 5-minute walk from South Kensington tube station (with direct links to Heathrow airport). **Day 1 – Arrival and Settling In** - **Morning**: Arrive at the airport. Welcome to your adventure! Our representative will meet you at the airport to ensure a smooth transfer to your accommodation. - **Afternoon**: Check into your hotel and take some time to relax and refresh. - **Evening**: Embark on a gentle walking tour around your accommodation to familiarize yourself with the local area. Discover nearby dining options for a delightful first meal. **Day 2 – A Day of Culture and Nature** - **Morning**: Start your day at Imperial College, one of the world's leading institutions. Enjoy a guided campus tour. - **Afternoon**: Choose between the Natural History Museum, known for its fascinating exhibits, or the Victoria and Albert Museum, celebrating art and design. Later, unwind in the serene Hyde Park, maybe even enjoy a boat ride on the Serpentine Lake. - **Evening**: Explore the local cuisine. We recommend trying a traditional British pub for dinner. **Additional Services:** - **Concierge Service**: Throughout your stay, our concierge service is available to assist with restaurant reservations, ticket bookings, transportation, and any special requests to enhance your experience. - **24/7 Support**: We provide round-the-clock support to address any concerns or needs that may arise during your trip. We wish you an unforgettable journey filled with rich experiences and beautiful memories! ### Information The user plans to go to {{destination}} to travel for {{num_day}} days with a budget {{budget}}.
テンプレートのプロンプトのままでも、そこそこ動いてくれそうです。
さっそく試してみましょう。
「デバッグとプレビュー」のところにチャット入力欄がありますので、そこでチャットします。

プロンプト
秋になったら日本の京都に旅行に行きたいです。紅葉と神社、お寺巡りの計画を3泊4日でお願いします。回答
### Detailed Travel Plan **Hotel Recommendations** 1. **Hotel Gracery Kyoto** - Ratings: 4.5⭐ - Prices: Around $120 per night - About: Located in the vibrant Gion district, this hotel offers modern amenities and easy access to popular attractions. **Day 1 – Arrival and Settling In** - **Morning**: Arrive in Kyoto! Our representative will greet you at the airport and assist with your transfer to Hotel Gracery Kyoto. - **Afternoon**: Check-in at the hotel and take some time to relax after your journey. - **Evening**: Explore the Gion district, known for its traditional wooden machiya houses and teahouses. Immerse yourself in the unique charm of Kyoto. **Day 2 – Shrine and Temple Discovery** - **Morning**: Visit Fushimi Inari Taisha, famous for its thousands of vermillion torii gates creating a stunning tunnel. - **Afternoon**: Explore Kinkaku-ji (Golden Pavilion) and Ryoan-ji, a Zen temple with a renowned rock garden. - **Evening**: Enjoy a peaceful walk through the Bamboo Forest in Arashiyama and visit Tenryu-ji temple. **Day 3 – Cultural Exploration** - **Morning**: Discover the historic Gion district, known for its traditional wooden machiya houses and geisha culture. - **Afternoon**: Visit Nijo Castle, a UNESCO World Heritage Site with beautiful gardens and historic architecture. - **Evening**: Experience a traditional tea ceremony to delve into the art and culture of Japan. **Day 4 – Farewell to Kyoto** - **Morning**: Stroll through Kyoto Imperial Palace and its serene gardens. - **Afternoon**: Explore the vibrant Nishiki Market to savor local street food and buy souvenirs. - **Evening**: Enjoy a farewell dinner at a local restaurant with delicious Kyoto cuisine. **Additional Services:** - **Concierge Service**: Available for any assistance or bookings during your stay. - **24/7 Support**: Contact us anytime for support or recommendations. We hope you have an unforgettable journey exploring the beauty and culture of Kyoto! 🍁🏯✨
翻訳
詳細な旅行計画
ホテルのおすすめ
ホテルグレイスリー京都
評価: 4.5⭐
料金: 1泊あたり約120ドル
概要: 活気ある祇園地区に位置するこのホテルは、モダンな設備を備え、人気の観光スポットへ簡単にアクセスできます。
1 日目 – 到着と定住
朝: 京都に到着! 担当者が空港でお出迎えし、ホテルグレイスリー京都までの送迎をお手伝いいたします。
午後: ホテルにチェックインし、旅の後にリラックスする時間をお過ごしください。
夜: 伝統的な木造の町家や茶室で知られる祇園地区を散策します。 京都ならではの魅力を満喫してください。
2 日目 – 神社と寺院の発見
午前: 伏見稲荷大社を訪れます。何千もの朱色の鳥居が見事なトンネルを作っていることで有名です。
午後: 金閣寺 (金閣寺) と有名な石庭のある禅寺、龍安寺を探索します。
夕方: 嵐山の竹林を静かに散策し、天龍寺を訪れます。
3 日目 – 文化探訪
午前: 伝統的な木造町家と芸者文化で知られる歴史ある祇園地区を探索します。
午後: 美しい庭園と歴史的建造物があるユネスコ世界遺産の二条城を訪れます。
夜: 伝統的な茶道を体験し、日本の芸術と文化を深く掘り下げます。
4日目 – 京都にお別れ
午前: 京都御所とその静かな庭園を散策します。
午後: 活気あ本若る錦市場を散策し、地元の屋台の食べ物を味わい、お土産を購入します。
夜: 地元のレストランで美味しい京料理をお楽しみいただけるお別れディナーをお楽しみください。
追加サービス:
コンシェルジュ サービス: ご滞在中のサポートや予約にご利用いただけます。
年中無休のサポート: サポートや推奨事項については、いつでもお問い合わせください。
京都の美しさと文化を探求する忘れられない旅になることを願っています。 🍁🏯✨
ちゃんと回答してくれました。
旅行の計画としては、おおざっぱ過ぎますがデフォルトのテンプレートであればこれくらいでしょう。
続けてカスタマイズ方法を見ていきます。
ツールの追加
設定画面にある「ツール」→「+追加」をクリック

左側メニューに外部サービスがツールとして表示されています。
今回はわかりやすく画像生成の「DALL-E」を選択して使用します。
OpenAIのAPIキーが必要になりますので、「認証する」をクリックします。

APIキーを入力して「保存」をクリックします。

保存すると、「ツール」のところに「dalle3」が追加されました。

それでは早速デバッグしてみましょう。
「デバッグとプレビュー」欄にプロンプトを入力して実行します。
プロンプト
京都旅行の観光地の画像を1日1つ出力してください。出力結果

画像が出力されました。
ちゃんとDALL-Eをツールとして使えてますね。
「1日1つの画像」と指示しましたが、画像1つだけでしたのでこれは言うこと聞いてくれなかったみたいです。
ワークフローでのアプリ作成
続けて、ワークフローでアプリを作ってみましょう。
「最初から作成」をクリックし、「ワークフロー」を選択して、「作成する」をクリックします。

ワークフローの画面が表示されます。

下部の「Add Block」の「+」をクリック

「組み込みツール」から「TavilySearch」をクリック


「+」部分をドラッグして、TavilySearchの左端につなげます。

「開始」を選択した状態にすると、右側に設定画面が表示されます。
「入力フィールド」の「+」をクリックします。

「変数名」は「query」という名前にします。

次にTavilySearchのブロックを選択した状態にします。

「入力変数」のところで”/”を押すと、候補が表示されますので、さきほどのquery変数を選択します。

「SEARCH DEPTH」は「Advanced」を選択します。
続けて次のブロックを作成します。
次は「LLM」を選択します。

ブロック作成後、TavilySearchのブロックと線をつなぎます。

「USER」の入力ボックスで”/”を入力すると、候補が表示されます。
「TAVILYSEARCH」の「text」を選択します。

モデルも上記画面から変更可能です。
OpenAIのAPIキーを登録することも可能です。
続けて「終了」ブロックを追加します。

「LLM」ブロックと線をつなげます。

「出力変数」に「result」を入力し、「変数」は「LLM」の「text」を選択します。

完成しました。

「実行」をクリックしてテストをしましょう。
入力ボックスに以下のプロンプトを入れて「実行を開始」をクリックします。
OpenAIのSoraとは?
回答が得られました。
通常のChatGPTではOpenAIのSoraについては事前学習されていないので回答できないですが、TavilySearchにより最新情報を取得して答えてくれました。

続けて別のプロンプトを実行してみます。
最後に大谷翔平がホームランを打った試合の結果を教えてください。

最後にホームランを打ったのは5/7のようです。
プロンプトを実行したのは5/10前後だったように思いますので、合ってそうですね。
5/7の試合結果を見てみましょう。
5/7の試合結果

みごと大谷選手がホームランを打ってました!
TavilySearchはうまく機能してるようです。
テストが終わったのでアプリを公開してみましょう。
「公開する」→「公開する」をクリックします。

その後、「アプリを実行」をクリックします。

アプリ画面が立ち上がります。
さきほどと同じプロンプトを入力して「Execute」をクリックします。

さっきと違う回答でした。

デバッグのときと同じ動きを期待していましたが、アプリケーションとして実行すると多少何か変わるのかもしれません。
プロンプトを修正して試してみます。
プロンプトを修正
大谷翔平の一番最新の試合結果と日付を教えてください。

たしかについ先日まで打撃9冠と騒がれてましたので、合ってそうです。176号も松井の本数を抜いた数字で合ってそうですね。
これで、ワークフローでアプリ作成ができました。
チャットアプリ作成
詳細は省略しますが以下のようにチャットアプリも作成可能です。

アプリ作成画面も簡易的なものなので、ワークフローが苦手な人でも簡単にアプリが作れます。


ナレッジ作成(RAG)
RAGも「ナレッジ」という名前で機能が備わっています。
本記事では詳細は省略しますが、以下のように「ナレッジ」をクリックすると、ファイルアップロード画面に遷移してファイルを登録できます。

EmbeddingモデルもOpenAIを始めCohere、AWSなど複数のEmbeddingモデルを選択できます。

検索設定も、通常のベクトル検索を始め、ハイブリッド検索も選択できます。

まとめ
Difyの始め方について記事にしました。
記事のとおり、ノーコードで実用的なアプリが作成できました。
OpenAIのGPTsでもノーコードで似たようなことはできますが、例えばLLMモデルもGPTシリーズ以外にもClaude3や別のLLMを利用できるようにカスタマイズできる点が大きな優位性かなと思っています。
その他、外部ツールも簡単に呼び出せますので、これまでプログラムでゴリゴリ作ってたものが、ワークフローで簡単に視覚的にアプリが作れます。
RAGの実装も「ナレッジ」として機能がありますので、一通り生成AIで欲しい機能は備わってそうです。
GPTsよりももっと自分でカスタマイズしたいけど、プログラム書くまではちょっと面倒。という人に最適なツールではないでしょうか。
LangChainというフレームワークを使えば、比較的簡単にアプリケーションは作成可能ですが、それでもプログラムを書くという作業はどうしても時間はかかってしまいます。
それに頻繁にバージョンアップするLangChainに追いつくのも大変ですよね。
プログラムを書くのに疲れた時は、ワークフローやテンプレートをさっと書くだけで、さくっと自分の欲しいアプリケーションが作れるDifyをぜひお試しください。