Chen188 / dify-aws-tool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

 English  | 简体中文 


Dify AWS Tool

Introduction

This repo provides some sample code to show how to integrate SageMaker Provider and some AWS Service based tools to Dify.

In addition to the reference code, you can also refer to the Dify official guide for more information.

Prerequisites

  • Dify Environment

  • AWS Account and AWS Experience

  • Basic experience with Linux environments

Assets

[Attention]:We welcome contributions of more workflows, SageMaker models, and built-in tools. You can fork this repository and submit a merge request, please also update README.md, you need to add a new row to the corresponding table

Workflow

DSL Name Description Link Dependency Owner
Term_based_translate Translation Workflow with Term mapping Retrieval Tool DSL Tool(Term_multilingual_mapping) ybalbert
Code_translate Code Transform between different Program Language DSL Tool(LambdaYamlToJson) binc
Basic_RAG_Sample simple basic rag workflow with rerank tool DSL Tool(Rerank) ybalbert
Andrewyng/translation-agent Andrew Ng's translate agent. DSL chuanxie

Builtin_Tools

Tool Name Tool Type Description Deploy_doc Owner
Rerank PAAS Text Similarity Rerank Tool Notebook ybalbert
TTS PAAS Speech synthesis Tool Code ybalbert
Bedrock Guardrails SAAS Text moderation Tool, implemented through the independent assessment API ApplyGuardrail API provided on Amazon Bedrock Guardrail. amyli
Term_multilingual_mapping PAAS Word Segment/ Term mapping Retrieval Tool Repo ybalbert
Image Translation Tool PAAS Translate the text on Image Coming tanqy
LambdaYamlToJson PAAS Convert YAML into JSON README binc

Model_Provider

Model Name model_type Deploy_doc Owner
Bge-m3-rerank-v2 SageMaker\Rerank Notebook ybalbert
Bge-embedding-m3 SageMaker\Embedding Notebook ybalbert
CosyVoice SageMaker\TTS Code ybalbert
SenseVoice SageMaker\ASR Notebook ybalbert

How to Install

Below Script is only for SageMaker Model_provider and AWS Builtin Tools, you can import workflows from Web Interface. SageMaker Model_provider has already been integrated in Dify v0.6.15

  1. Set Env Variable

    dify_path=/home/ec2-user/dify #Please set the correct dify install path
    tag=aws
  2. download code

    cd /home/ec2-user/
    git clone https://github.com/aws-samples/dify-aws-tool/
  3. intall code

    # Part of models and tools have been integrated with dify already, no extra installation needed
    mv ./dify-aws-tool/builtin_tools/aws ${dify_path}/api/core/tools/provider/builtin/
    mv ./dify-aws-tool/model_provider/sagemaker ${dify_path}/api/core/model_runtime/model_providers/
  4. build image

    cd ${dify_path}/api
    sudo docker build -t dify-api:${tag} .
    
  5. Specify the new image for api and worker services

    # Modify docker/docker-compose.yaml, Please refer the below diff
    diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml
    index cffaa5a6a..38538e5ca 100644
    --- a/docker/docker-compose.yaml
    +++ b/docker/docker-compose.yaml
    @@ -177,7 +177,7 @@ x-shared-env: &shared-api-worker-env
     services:
       # API service
       api:
    -    image: langgenius/dify-api:0.6.14
    +    image: dify-api:aws
         restart: always
         environment:
           # Use the shared environment variables.
    @@ -197,7 +197,7 @@ services:
       # worker service
       # The Celery worker for processing the queue.
       worker:
    -    image: langgenius/dify-api:0.6.14
    +    image: dify-api:aws
         restart: always
         environment:
           # Use the shared environment variables.
  6. restart dify

    cd ${dify_path}/docker/
    sudo docker-compose down
    sudo docker-compose up -d

How to deploy SageMaker Endpoint

If you want to add your Embedding/Rerank model to Dify Sagemaker Model Provider, you should deploy them by yourself in AWS/SageMaker at first. Please see the Guide.

Target Audience

  • Dify / AWS User
  • GenAI Developer

About

License:MIT No Attribution


Languages

Language:Jupyter Notebook 60.4%Language:Python 38.4%Language:Shell 0.8%Language:Dockerfile 0.4%