当前位置: 首页 > news >正文

dify离线插件安装

dify容器中python是python3.12
ubuntun22.04

安装conda python3.12 环境

conda create -n py312 python=3.12
conda activate py312

从dify下载插件

比如 ollama langgenius-ollama_0.0.7.difypkg

重新打包插件

./plugin_repackaging.sh local ./langgenius-ollama_0.0.7.difypkg

#!/bin/bash
# author: Junjie.MDEFAULT_GITHUB_API_URL=https://github.com
DEFAULT_MARKETPLACE_API_URL=https://marketplace.dify.ai
DEFAULT_PIP_MIRROR_URL=https://mirrors.aliyun.com/pypi/simpleGITHUB_API_URL="${GITHUB_API_URL:-$DEFAULT_GITHUB_API_URL}"
MARKETPLACE_API_URL="${MARKETPLACE_API_URL:-$DEFAULT_MARKETPLACE_API_URL}"
PIP_MIRROR_URL="${PIP_MIRROR_URL:-$DEFAULT_PIP_MIRROR_URL}"CURR_DIR=`dirname $0`
cd $CURR_DIR
CURR_DIR=`pwd`
USER=`whoami`
ARCH_NAME=`uname -m`
OS_TYPE=$(uname)
OS_TYPE=$(echo "$OS_TYPE" | tr '[:upper:]' '[:lower:]')CMD_NAME="dify-plugin-${OS_TYPE}-amd64-5g"
if [[ "arm64" == "$ARCH_NAME" || "aarch64" == "$ARCH_NAME" ]]; thenCMD_NAME="dify-plugin-${OS_TYPE}-arm64-5g"
fiPIP_PLATFORM=""
PACKAGE_SUFFIX="offline"market(){if [[ -z "$2" || -z "$3" || -z "$4" ]]; thenecho ""echo "Usage: "$0" market [plugin author] [plugin name] [plugin version]"echo "Example:"echo "	"$0" market junjiem mcp_sse 0.0.1"echo "	"$0" market langgenius agent 0.0.9"echo ""exit 1fiecho "From the Dify Marketplace downloading ..."PLUGIN_AUTHOR=$2PLUGIN_NAME=$3PLUGIN_VERSION=$4PLUGIN_PACKAGE_PATH=${CURR_DIR}/${PLUGIN_AUTHOR}-${PLUGIN_NAME}_${PLUGIN_VERSION}.difypkgPLUGIN_DOWNLOAD_URL=${MARKETPLACE_API_URL}/api/v1/plugins/${PLUGIN_AUTHOR}/${PLUGIN_NAME}/${PLUGIN_VERSION}/downloadecho "Downloading ${PLUGIN_DOWNLOAD_URL} ..."curl -L -o ${PLUGIN_PACKAGE_PATH} ${PLUGIN_DOWNLOAD_URL}if [[ $? -ne 0 ]]; thenecho "Download failed, please check the plugin author, name and version."exit 1fiecho "Download success."repackage ${PLUGIN_PACKAGE_PATH}
}github(){if [[ -z "$2" || -z "$3" || -z "$4" ]]; thenecho ""echo "Usage: "$0" github [Github repo] [Release title] [Assets name (include .difypkg suffix)]"echo "Example:"echo "	"$0" github junjiem/dify-plugin-tools-dbquery v0.0.2 db_query.difypkg"echo "	"$0" github https://github.com/junjiem/dify-plugin-agent-mcp_sse 0.0.1 agent-mcp_see.difypkg"echo ""exit 1fiecho "From the Github downloading ..."GITHUB_REPO=$2if [[ "${GITHUB_REPO}" != "${GITHUB_API_URL}"* ]]; thenGITHUB_REPO="${GITHUB_API_URL}/${GITHUB_REPO}"fiRELEASE_TITLE=$3ASSETS_NAME=$4PLUGIN_NAME="${ASSETS_NAME%.difypkg}"PLUGIN_PACKAGE_PATH=${CURR_DIR}/${PLUGIN_NAME}-${RELEASE_TITLE}.difypkgPLUGIN_DOWNLOAD_URL=${GITHUB_REPO}/releases/download/${RELEASE_TITLE}/${ASSETS_NAME}echo "Downloading ${PLUGIN_DOWNLOAD_URL} ..."curl -L -o ${PLUGIN_PACKAGE_PATH} ${PLUGIN_DOWNLOAD_URL}if [[ $? -ne 0 ]]; thenecho "Download failed, please check the github repo, release title and assets name."exit 1fiecho "Download success."repackage ${PLUGIN_PACKAGE_PATH}
}_local(){echo $2if [[ -z "$2" ]]; thenecho ""echo "Usage: "$0" local [difypkg path]"echo "Example:"echo "	"$0" local ./db_query.difypkg"echo "	"$0" local /root/dify-plugin/db_query.difypkg"echo ""exit 1fiPLUGIN_PACKAGE_PATH=`realpath $2`repackage ${PLUGIN_PACKAGE_PATH}
}repackage(){local PACKAGE_PATH=$1PACKAGE_NAME_WITH_EXTENSION=`basename ${PACKAGE_PATH}`PACKAGE_NAME="${PACKAGE_NAME_WITH_EXTENSION%.*}"echo "Unziping ..."#install_unzipunzip -o ${PACKAGE_PATH} -d ${CURR_DIR}/${PACKAGE_NAME}if [[ $? -ne 0 ]]; thenecho "Unzip failed."exit 1fiecho "Unzip success."echo "Repackaging ..."cd ${CURR_DIR}/${PACKAGE_NAME}conda infoecho "pip download ${PIP_PLATFORM} -r requirements.txt -d ./wheels --index-url ${PIP_MIRROR_URL} --trusted-host mirrors.aliyun.com"pip3 download ${PIP_PLATFORM} -r requirements.txt -d ./wheels if [[ $? -ne 0 ]]; thenecho "Pip download failed."exit 1fiif [[ "linux" == "$OS_TYPE" ]]; thensed -i '1i\--no-index --find-links=./wheels/' requirements.txtelif [[ "darwin" == "$OS_TYPE" ]]; thensed -i ".bak" '1i\
--no-index --find-links=./wheels/' requirements.txtrm -f requirements.txt.bakfiIGNORE_PATH=.difyignoreif [ ! -f "$IGNORE_PATH" ]; thenIGNORE_PATH=.gitignorefiif [ -f "$IGNORE_PATH" ]; thenif [[ "linux" == "$OS_TYPE" ]]; thensed -i '/^wheels\//d' "${IGNORE_PATH}"elif [[ "darwin" == "$OS_TYPE" ]]; thensed -i ".bak" '/^wheels\//d' "${IGNORE_PATH}"rm -f "${IGNORE_PATH}.bak"fificd ${CURR_DIR}chmod 755 ${CURR_DIR}/${CMD_NAME}${CURR_DIR}/${CMD_NAME} plugin package ${CURR_DIR}/${PACKAGE_NAME} -o ${CURR_DIR}/${PACKAGE_NAME}-${PACKAGE_SUFFIX}.difypkgecho "Repackage success."
}install_unzip(){if ! command -v unzip &> /dev/null; thenecho "Installing unzip ..."yum -y install unzipif [ $? -ne 0 ]; thenecho "Install unzip failed."exit 1fifi
}print_usage() {echo "usage: $0 [-p platform] [-s package_suffix] {market|github|local}"echo "-p platform: python packages' platform. Using for crossing repacking.For example: -p manylinux2014_x86_64 or -p manylinux2014_aarch64"echo "-s package_suffix: The suffix name of the output offline package.For example: -s linux-amd64 or -s linux-arm64"exit 1
}while getopts "p:s:" opt; docase "$opt" inp) PIP_PLATFORM="--platform ${OPTARG} --only-binary=:all:" ;;s) PACKAGE_SUFFIX="${OPTARG}" ;;*) print_usage; exit 1 ;;esac
doneshift $((OPTIND - 1))echo "$1"
case "$1" in'market')market $@;;'github')github $@;;'local')_local $@;;*)print_usage
exit 1
esac
exit 0
http://www.xdnf.cn/news/1269541.html

相关文章:

  • Android MediaMetadataRetriever取视频封面,Kotlin(1)
  • 密集遮挡场景识别率↑31%!陌讯轻量化部署方案在智慧零售的实战解析
  • 力扣(轮转数组)
  • Python基础教程(六)条件判断:引爆思维Python条件判断的九层境界
  • 网站站长如何借助php推送示例提交网站内容加速百度收录?
  • web应用服务器tomcat
  • 代码随想录算法训练营23天 | ​​
  • 力扣热题100-----118.杨辉三角
  • 信息安全简要
  • Python自动化测试断言详细实战代码
  • [激光原理与应用-202]:光学器件 - 增益晶体 - Nd:YVO₄增益晶体的制造过程与使用过程
  • 本地连接跳板机
  • 算法_python_学习记录_02
  • 32Nginx配置与多业务部署指南
  • [ MySQL 数据库 ] 多表关联查询
  • vulnhub-Beelzebub靶场通关攻略
  • “高大上“的SpringCloud?(微服务体系入门)
  • 麦当秀|MINDSHOW:在线AI PPT设计工具
  • Java基础-UDP通信实现一发一收
  • java -jar xxx.jar 提示xxx.jar中没有主清单属性报错解决方案
  • cross-env dotenv
  • 版本控制的详细说明介绍(已有github账号版)
  • pytorch+tensorboard+可视化CNN
  • 动手学深度学习(pytorch版):第二章节——预备知识(1)——数据操作
  • 数模个人笔记
  • USRP X310 X410 参数对比
  • ImageJ 实用技巧:通过 Overlay 实现图像透明标记的完整教程
  • 【Git】Visual Studio 实现合并分支
  • 2025年TOP5服装类跟单软件推荐榜单
  • MoVA:多模态视觉专家混合架构的创新设计与应用实践