ãDifyãð°åå¿è å¿ èŠïŒDifyãããŒã«ã«PCã§åããã¡ãªãããšç°¡åãªã»ããã¢ããæ¹æ³
ã¯ããã«
çæAIã掻çšããã¢ããªã±ãŒã·ã§ã³éçºã泚ç®ãéããŠããŸããããã®äžã§ãDifyã¯ãåå¿è ã§ãæ軜ã«å§ãããããªãŒãã³ãœãŒã¹ã®å€§èŠæš¡èšèªã¢ãã«ïŒLLMïŒã¢ããªã±ãŒã·ã§ã³éçºãã©ãããã©ãŒã ãšããŠäººæ°ã§ãã
ãã®èšäºã§ã¯ãDifyãããŒã«ã«PCã§åããã¡ãªãããšããã®é
åã解説ããŸãã
ãŸããããŒã«ã«PCã§åãããå Žåã§ããéåžžã®ãµãŒãã¹ãšæ©èœçã«éããç¡ããç°¡åã«è©ŠããŠã¿ãŸããã
Difyãšã¯ïŒ
Difyã¯ãAIã¯ãŒã¯ãããŒã®æ§ç¯ãRAGïŒRetrieval-Augmented GenerationïŒãã€ãã©ã€ã³ã®èšå®ãã¢ãã«ç®¡çãªã©ãAIã¢ããªã±ãŒã·ã§ã³éçºããµããŒããããªãŒã«ã€ã³ã¯ã³ãã©ãããã©ãŒã ã§ããç¹ã«ãåå¿è ã§ãçŽæçã«äœ¿ãããŠãŒã¶ãŒã€ã³ã¿ãŒãã§ãŒã¹ãåããŠãããçæéã§ãããã¿ã€ãããæ¬çªç°å¢ãžã®ç§»è¡ãå¯èœã§ãã
ããã°ã©ã ãæžãããšãªããããŒã³ãŒãã§çæAIãLLMã掻çšããã¢ããªã±ãŒã·ã§ã³ãäœããã®ã§ãã
ã€ãŸãéãšã³ãžãã¢ã®äººã§ãAIã¢ããªéçºãã§ããŸãã
ããŒã«ã«PCã§Difyãåãã3ã€ã®ã¡ãªãã
1. ããŒã¿ã®å®å šãªã³ã³ãããŒã«
ããŒã«ã«ç°å¢ã§Difyãåããããšã§ãããŒã¿ã®ç®¡çãå®å šã«èªåã®æå ã§è¡ããŸããã»ãã¥ãªãã£ãªã¹ã¯ãæå°éã«æãã€ã€ãèªåã®PCå ã§å®å šã«éçºã»ãã¹ããé²ããããã®ã¯å€§ããªå©ç¹ã§ããç¹ã«ãã»ã³ã·ãã£ããªããŒã¿ããã©ã€ããŒããªãããžã§ã¯ãã«é¢ããŠã¯ããã®ã¡ãªããã倧ããã§ãããã
Dockerãåãç°å¢ã§ããã°ã©ãã§ãåããŸãã®ã§ãããŒã«ã«PCã§ãªããŠãAWSãAzureãšãã£ãã¯ã©ãŠããµãŒãã¹ã®ãµãŒãäžã§ãåããããšãã§ããŸãã
2. ã³ã¹ãã®åæž
äžè¬çãªAIãµãŒãã¹ã¯ããè©ŠãçšåºŠã ãšç¡æã§äœ¿ããŸããæ¬æ Œçã«äœ¿ãããå Žåã¯æ¯æãéããããã®ãäžè¬çã§ãã
ããããããŒã«ã«PCã§Difyãåããã°ããã®ãããªã©ã³ãã³ã°ã³ã¹ããæããããšãã§ããŸããDifyã¯æ¯èŒç軜éãªãœãããŠã§ã¢ã§ãããããæšæºçãªPCã¹ããã¯ã§ãååã«åäœããŸããããã«ãããäœã³ã¹ãã§é«æ§èœãªAIã¢ããªã±ãŒã·ã§ã³ã®éçºãå¯èœã«ãªããŸãã
ãã¡ããã³ã³ãã¥ãŒãã£ã³ã°ãªãœãŒã¹ä»£ã®ã³ã¹ãã¯å¿
èŠã§ãããã¡ãã£ãšã ãè©ŠããŠã¿ããå Žåãåæ¢ããŠãããšãã¯ã³ã¹ããããããªãAWSãªã©ã®ã¯ã©ãŠãã®ãµãŒãã䜿ãããšã§ã³ã¹ããæããããŸãã
Difyã®å©çš(ããŒã«ã«PC)
Difyã®ããŠã³ããŒããèµ·å
dockerãdocker-composeãå ¥ã£ãŠããç°å¢ã§ä»¥äžã®ã³ãã³ããå®è¡ããã ãã§ãã
ãšãŠãç°¡åã§ããïŒ
# git clone https://github.com/langgenius/dify.git
# cd dify/docker/
# docker-compose up -d
ãšã©ãŒç¡ãå®è¡ã§ããã docker-compose ps ã§èµ·åç¶æ³ãèŠãŠã¿ãŸãã
# docker-compose ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
docker-api-1 docker.io/langgenius/dify-api:0.6.16 "" api About a minute ago Up About a minute
docker-sandbox-1 docker.io/langgenius/dify-sandbox:0.2.1 "" sandbox About a minute ago Up About a minute
docker-web-1 docker.io/langgenius/dify-web:0.6.16 "" web About a minute ago Up About a minute
docker-worker-1 docker.io/langgenius/dify-api:0.6.16 "" worker About a minute ago Up About a minute
ãã©ãŠã¶ãèµ·åããŠã¢ã¯ã»ã¹ããŸãã
http://localhost
ãããã¯
http://IPã¢ãã¬ã¹ã§ã¢ã¯ã»ã¹ããŸãã
ã¢ã¯ã»ã¹ã§ããŸããïŒ
äžã®ã»ãã«ã管çè ã¢ã«ãŠã³ãã®èšå®ãã®ãªã³ã¯ãããã®ã§ã¯ãªãã¯ããŸãã
管çè
ã¢ã«ãŠã³ãã®èšå®ãããŸãã
å¿
èŠãªæ
å ±ãå
¥åããŠãã»ããã¢ããããã¯ãªãã¯ããŸãã
ä»åã¯é©åœã«test@test.comãšããã¡ãŒã«ã¢ãã¬ã¹ãå
¥åããŸããã
ããŒã«ã«PCã§ã»ããã¢ããããŠãã®ã§ãã¡ãŒã«èªèšŒãšãé¢åãªããšã¯å¿
èŠãããŸããã§ããã
ãµã€ã³ã€ã³ãããšä»¥äžã®ãããç»é¢ã衚瀺ãããŸãã
ãšãŠãã·ã³ãã«ã§ããã
èŠãæãéåžžã®ãµãŒãã¹çã®Difyãšéãã¯ç¡ãããã§ãã
ãã£ããåãããŠã¿ãŸãããã
ãæåããäœæããã¯ãªãã¯ããŸãã
ã¢ããªã®ã¿ã€ããéžã¹ãŸãã
ãã£ããããã
ããã¹ããžã§ãã¬ãŒã¿ãŒ
ãšãŒãžã§ã³ã
ã¯ãŒã¯ãããŒ
ä»åã¯ç°¡åãããªããã£ãããããããéžæããŸãã
å³åŽã«ãLLMãããã€ããŒããŒãèšå®ãããŠããŸããããšè¡šç€ºãããŠããŸããã
ãèšå®ã«ç§»åããã¯ãªãã¯ããŸãã
ãOpenAIãã®ãã»ããã¢ããããã¯ãªãã¯
APIããŒã ããå ¥åããŠãä¿åããã¯ãªãã¯
ã¢ãã«ãéžæã§ããã
ããããã°ãšãã¬ãã¥ãŒããããã£ããã®ãã¹ãããã
ãããã«ã¡ã¯ããšããã³ãããå ¥åããŠå®è¡ããŸãã
ãããã«ã¡ã¯ïŒãããã§ããïŒäœããæäŒãã§ããããšãããã°æããŠãã ããã
ãšåçããããŸããã
ãã¹ãã¯OKããã§ãã
次ã«ãå
¬éããããã¯ãªãã¯ããŸãã
ãæŽæ°ããã¯ãªãã¯ããŸãã
å€åãªãã®ã§ããå ¬éããããŒãã¢ããªãå®è¡ããã¯ãªãã¯ããŸãã
ãããã«ã¡ã¯ããšããã³ãããå ¥åããŸãã
ãããã«ã¡ã¯ïŒä»æ¥ã¯ã©ããªããšãã話ãããŸããããïŒã
ãšåçããŠãããŸããïŒ
次ã«ãå ¬éããããŒããµã€ãã«åã蟌ãããã¯ãªãã¯ããŸãã
以äžïŒãã¿ãŒã³ã®äžããéžæã§ããŸãã
次ã«ãå ¬éããããŒãAPIãªãã¡ã¬ã³ã¹ã«ã¢ã¯ã»ã¹ããã¯ãªãã¯ããŸãã
APIã®èª¬æããŒãžã«ç§»åããŸãã
ãããŠå³äžã®ãAPIããŒããã¯ãªãã¯ããŸãã
ãæ°ããã·ãŒã¯ã¬ããããŒãäœæããã¯ãªãã¯
curlã³ãã³ãã§APIå®è¡ãã¹ã
curl -X POST 'http://192.168.1.9/v1/chat-messages' \
--header 'Authorization: ïŒâ
APIããŒãå
¥åïŒ' \
--header 'Content-Type: application/json' \
--data-raw '{
"inputs": {},
"query": "What are the specs of the iPhone 13 Pro Max?",
"conversation_id": "",
"user": "abc-123",
"files": [
{
"type": "image",
"transfer_method": "remote_url",
"url": "https://cloud.dify.ai/logo/logo-site.png"
}
]
}'
ã¬ã¹ãã³ã¹
{"event": "message", "task_id": "59da21b7-1b53-401c-b958-0b7a4c1b4479", "id": "529d6825-1e94-4803-ac1c-c79aa34aef67", "message_id": "529d6825-1e94-4803-ac1c-c79aa34aef67", "conversation_id": "473e04bc-f9d6-4d24-b942-85668f87c34a", "mode": "chat", "answer": "The iPhone 13 Pro Max has the following specifications:\n\n### Display\n- **Size**: 6.7 inches\n- **Type**: Super Retina XDR display\n- **Resolution**: 2778 x 1284 pixels\n- **Brightness**: Up to 1000 nits (typical); 1200 nits (HDR)\n\n### Processor\n- **Chip**: A15 Bionic chip\n- **Neural Engine**: 16-core neural engine\n\n### Camera System\n- **Rear Cameras**: Triple 12 MP system (Ultra Wide, Wide, Telephoto)\n - Ultra Wide: f/1.8 aperture\n - Wide: f/1.5 aperture\n - Telephoto: f/2.8 aperture\n- **Night Mode, Deep Fusion, Smart HDR 4**\n- **Video Recording**: 4K Dolby Vision HDR recording\n\n### Front Camera\n- **Camera**: 12 MP with Night Mode and Deep Fusion\n- **Video Recording**: 4K video recording up to 60 fps\n\n### Storage Options\n- **Capacity**: 128GB, 256GB, 512GB, 1TB\n\n### Battery Life\n- **Video Playback**: Up to 28 hours\n- **Fast Charging**: Supports MagSafe and Qi wireless charging\n\n### Operating System\n- **Initial OS**: iOS 15 (upgradable)\n\n### Other Features\n- **5G Capable**\n- **Face ID**\n- **Ceramic Shield front cover**\n- **Water and Dust Resistance**: Rated IP68\n\nThese specifications provide a comprehensive view of the iPhone 13 Pro Max capabilities.", "metadata": {"usage": {"prompt_tokens": 8520, "prompt_unit_price": "0.15", "prompt_price_unit": "0.000001", "prompt_price": "0.0012780", "completion_tokens": 349, "completion_unit_price": "0.60", "completion_price_unit": "0.000001", "completion_price": "0.0002094", "total_tokens": 8869, "total_price": "0.0014874", "currency": "USD", "latency": 6.144609890000083}}, "created_at":
APIã§ãå©çšã§ããŸããïŒ
ãã£ãããããã®ã«ã¹ã¿ãã€ãº
ããªãŒã±ã¹ãã¬ãŒã·ã§ã³ããŒãæé ãã®ãšããã®ãèªåããã¯ãªãã¯ããŸãã
ãè©ŠããŠã¿ãããããå°éã¢ããªã¹ãããã¯ãªãã¯ããŸãã
æ瀺ã衚瀺ãããŸãã
ç¶ããŠãçæããã¯ãªãã¯ããŸãã
å³åŽã«èªåçã«ããã³ãããçæãããŸãã
ãé©çšããã¯ãªãã¯ããŸãã
ã確èªããã¯ãªãã¯ããŸãã
èªåçã«ãæé ãããå ¥åãã£ãŒã«ãããèšå®ãããŸãã
ãå ¥åãã£ãŒã«ãããã¢ããªç»é¢ã§æåã«å ¥åããé ç®ãšããŠè¡šç€ºãããããã§ãã
ãæé ãã¯ããã³ããã®ããã§ããã
管çé¢é£
å·Šã¡ãã¥ãŒã®ããã°ïŒã¢ããŠã³ã¹ããã¯ãªãã¯ããŸãã
ãã°ã確èªã§ããŸãã
次ã«å·Šã¡ãã¥ãããæŠèŠããã¯ãªãã¯ããŸãã
ã¢ããªã®å©çšç¶æ³ãå¯èŠåã§ããŸãã
å³äžã®ãã¢ããªã®ããã©ãŒãã³ã¹ã®è¿œè·¡ããã¯ãªãã¯ããŸãã
LangSmithãšLangfuseãšé£æºã§ããŸãã
äžéšã¡ãã¥ãŒ
ããŒã«
äžéšã¡ãã¥ãŒã®ãããŒã«ããã¯ãªãã¯ããŸãã
ããããªããŒã«ãéžæã§ããŸãã
ãYahooFinanceããã¯ãªãã¯ããŠã¿ãŸãã
å³åŽã«èª¬æã衚瀺ãããŸãã
次ã«ãGoogleããã¯ãªãã¯ããŸãã
ãèªèšŒããããšãããã¿ã³ããããŸããã
èªèšŒããããšã§Googleã®ãµãŒãã¹ãšé£æºã§ãããã§ãã
ãèªèšŒããããã¯ãªãã¯ããŸãã
ãSerpAPI API Keyãã®å ¥åé ç®ããããŸããã
Googleãšãã£ãŠãSerpAPIã ãã§ãããããã
ã«ã¹ã¿ã ããŒã«
次ã¯ãã«ã¹ã¿ã ããã¯ãªãã¯ããŸãã
æåã¯äœããªãã®ã§ãã«ã¹ã¿ã ããŒã«ãäœæããããã¯ãªãã¯ããŸãã
è©Šãã«ãäŸããŒã倩æ°(JSON)ããã¯ãªãã¯ããŸãã
ã¹ããŒãã«åæ ãããŸããã
å®éè©ŠããŠã¯ç¡ãã§ãããããã§ããã©ã«ãã®ããŒã«ã«ãªãAPIãªã©ãããŒã«ãšããŠäœ¿ãããã§ãã
ã¯ãŒã¯ãããŒ
次ã«ãã¯ãŒã¯ãããŒããã¯ãªãã¯ããŸãã
ä»ã¯äœããããŸããã§ããã
ãè¿œå ããã«ã¯ãã¯ãŒã¯ãããŒâããŒã«ãšããŠå
¬éãã«ç§»åããããšè¡šç€ºãããŠããŸãã®ã§ãäœãæé ãå¿
èŠãªã®ãããããŸããã
ãã¬ããž
äžéšã¡ãã¥ãŒããããã¬ããžããã¯ãªãã¯ããŸãã
ç¶ããŠããã¬ããžãäœæããã¯ãªãã¯ããŸãã
ããŠã§ããµã€ãããåæããã¯ãªãã¯
ãèšå®ããã¯ãªãã¯ããŸãã
ããŠã§ããµã€ãã«ãã Firecrawlãã®ãèšå®ããã¯ãªãã¯ããŸãã
ãAPI Keyããå ¥åããŸãã
ããããŸã APIããŒãååŸããŠããªãå Žåã¯ãFirecrawlã®ããŒãžããååŸããŸãããã
ç¡æã§ååŸããããšãå¯èœã§ãã
ä»åã¯ãSearchGPTãã®ããŒãžãç»é²ããŸãã
æ¯èŒçæ°ããã®ã§ãLLMã®äºååŠç¿ããŒã¿ã®äžã«ã¯å
¥ã£ãŠããããçŽ ã®LLMã§ã¯çããããªãã¯ãã§ãã
ãå®è¡ããã¯ãªãã¯ããŸãã
ïŒããŒãžã¹ã¯ã¬ã€ãã³ã°ã§ããããã§ãã
ã€ã¥ããŠã次ãžããã¯ãªãã¯ããŸãã
ãããã¹ãã®ååŠçãšã¯ãªãŒãã³ã°ãã®ããŒãžã衚瀺ãããŸãã
RAGã«é¢ããèšå®ã®ããŒãžã®ããã§ããã
å³åŽã«ãã¬ãã¥ãŒã衚瀺ãããŠããŸãã
ãšãããããã«ã¹ã¿ã ããã¯ãªãã¯ããŠã¿ãŸãã
ãã£ã³ã¯é·ããã£ã³ã¯ã®ãªãŒããŒã©ãããæå®å¯èœã§ãã
ãæ€çŽ¢èšå®ãã§ã¯ããã¯ãã«æ€çŽ¢ãããå
šææ€çŽ¢ããããã€ããªããæ€çŽ¢ããéžæã§ããŸãã
ä»åã¯ããã€ããªããæ€çŽ¢ããéžæããŸããã
ããã€ããªããæ€çŽ¢ãã§ã¯ããŠã§ã€ãèšå®ãããRerankã¢ãã«ããéžã¹ãŸãã
ããŠã§ã€ãèšå®ããéžæããŸãã
ãä¿åããŠåŠçããã¯ãªãã¯ããŸãã
ãã¬ããžãäœæãããŸããã
ãã®ããã«éãšã³ãžãã¢ã®äººã§ãç°¡åã«RAGãæ§ç¯ã§ããã®ã¯ããã§ããã
RAGã«ãã£ãŠãLLMã¯ç¥èãæ¡åŒµããŠåçãããããšãã§ããŸãã
ãããã¥ã¡ã³ãã«ç§»åããã¯ãªãã¯ããŸãã
å·Šã¡ãã¥ãŒã®ãæ€çŽ¢ãã¹ãããã¯ãªãã¯
ãSearchGPTãšã¯äœã§ããïŒããå ¥åã
å³åŽã«æ€çŽ¢çµæãåºåãããŸãã
ããã¯RAGã®æåŸã®Generationã¯ç¡ãããã æ€çŽ¢ããçµæã ããåºåãããããã§ãã
ããã§ã¯ããã¬ããžãå©çšããã¢ããªã±ãŒã·ã§ã³ãäœã£ãŠã¿ãŸãããã
ãæåããäœæããã¯ãªãã¯ããŸãã
ååãã€ããããäœæããããã¯ãªãã¯ããŸãã
è¿œå ãããã¬ããžã掻çšããã«ã¯ããã³ã³ããã¹ããã®ãè¿œå ããã¯ãªãã¯ããŸãã
ããã»ã©ã®Wikiã§äœæãããã¬ããžãéžæããŠãè¿œå ããã¯ãªãã¯ããŸãã
ããããã°ãšãã¬ãã¥ãŒãã§ãã¹ãããŸãã
ã¡ãã£ãšéããããªæ°ãããŸããããã£ãšãæ€çŽ¢ãšã³ãžã³ã®ãããã¿ã€ãããšèšãããã£ãã®ã§ãããã
倧æ ã§ã¯ééã£ãŠã¯ç¡ãããã§ãã
ãšãŒãžã§ã³ã
ãæåããäœæããŒããšãŒãžã§ã³ãããéžæããŸãã
ã¯ãŒã¯ãããŒ
Difyããªãã¿ã®ã¯ãŒã¯ãããŒã§ãã
Difyã匷åãªããŒã«ãšãªãã®ã¯ããã®ã¯ãŒã¯ãããŒã®ãããã§ãããéãšã³ãžãã¢ã®äººã§ãããŒã³ãŒãã§è€éãªçæAIã®ã¢ããªã±ãŒã·ã§ã³ãäœããŸãã
ãæåããäœæããŒãã¯ãŒã¯ãããŒããéžæããŸãã
ã¯ãŒã¯ãããŒç»é¢ãèµ·åããŸãã
ããšã¯èªåã®èªç±èªåšã«ãããŒãäœãã ãã§ããã
ãŸãšã
DifyãããŒã«ã«PCã§åãããŠã¿ãŸããã
䜿ã£ãŠã¿ãéãã§ã¯éåžžã®ãµãŒãã¹çãšéãã¯ç¡ãããã§ãã
èªåã®æå ã«ããPCã§Difyã®ã¯ãŒã¯ãããŒãäœããã®ã¯ããã§ããïŒ
ã»ãã¥ãªãã£ãæ°ã«ãªã£ãŠãªããªãæ軜ã«ãµãŒãã¹ã®Difyã䜿ããªãå Žåãªã©ãèªåç«ã¡ã®ãªã³ãã¬ã®ãµãŒãã«Difyãèµ·åãããŠäœ¿ã£ãããæ§ã ãªçšéã§äœ¿ãããã§ãã