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

自己做的旅游网站简介校友网站建设的意义

自己做的旅游网站简介,校友网站建设的意义,网站后台开发做什么,重庆施工员证查询网站本文使用Dify v1.0.0-beta.1版本。模型插件结构基本是模型供应商(模型公司,比如siliconflow、xinference)- 模型分类(模型类型,比如llm、rerank、speech2text、text_embedding、tts)- 具体模型(…

本文使用Dify v1.0.0-beta.1版本。模型插件结构基本是模型供应商(模型公司,比如siliconflowxinference)- 模型分类(模型类型,比如llmrerankspeech2texttext_embeddingtts)- 具体模型(比如,deepseek-v2.5)。本文以siliconflow为例,介绍Dify中的预定义模型插件开发例子。

一.siliconflow模型插件

SiliconCloud (MaaS) 简化AI模型的部署,同时提供强大的性能支持。通过该插件,用户可访问多种模型(如大语言模型、文本嵌入、重排序、语音转文本、文本转语音等),并可通过模型名称、API 密钥及其它参数进行配置。

1.多层模型分类

├─llm
│      deepdeek-coder-v2-instruct.yaml
│      deepseek-v2-chat.yaml
│      deepseek-v2.5.yaml
│      gemma-2-27b-it.yaml
│      gemma-2-9b-it.yaml
│      glm4-9b-chat.yaml
│      hunyuan-a52b-instruct.yaml
│      internlm2_5-20b-chat.yaml
│      internlm2_5-7b-chat.yaml
│      Internvl2-26b.yaml
│      Internvl2-8b.yaml
│      internvl2-llama3-76b.yaml
│      meta-mlama-3-70b-instruct.yaml
│      meta-mlama-3-8b-instruct.yaml
│      meta-mlama-3.1-405b-instruct.yaml
│      meta-mlama-3.1-70b-instruct.yaml
│      meta-mlama-3.1-8b-instruct.yaml
│      mistral-7b-instruct-v0.2.yaml
│      mistral-8x7b-instruct-v0.1.yaml
│      qwen2-1.5b-instruct.yaml
│      qwen2-57b-a14b-instruct.yaml
│      qwen2-72b-instruct.yaml
│      qwen2-7b-instruct.yaml
│      qwen2-vl-72b-instruct.yaml
│      qwen2-vl-7b-Instruct.yaml
│      qwen2.5-14b-instruct.yaml
│      qwen2.5-32b-instruct.yaml
│      qwen2.5-72b-instruct.yaml
│      qwen2.5-7b-instruct.yaml
│      qwen2.5-coder-32b-instruct.yaml
│      qwen2.5-coder-7b-instruct.yaml
│      qwen2.5-math-72b-instruct.yaml
│      yi-1.5-34b-chat.yaml
│      yi-1.5-6b-chat.yaml
│      yi-1.5-9b-chat.yaml
│
├─rerank
│      bce-reranker-base_v1.yaml
│      bge-reranker-v2-m3.yaml
│
├─speech2text
│      funaudio-sense-voice-small.yaml
│      sense-voice-small.yaml
│
├─text_embedding
│      bce-embedding-base-v1.yaml
│      bge-large-en-v1.5.yaml
│      bge-large-zh-v1.5.yaml
│      bge-m3.yaml
│
└─ttsfish-speech-1.4.yaml

2.通过API秘钥配置

安装 SiliconFlow插件后,通过输入 API密钥进行配置。如下所示:

二.创建模型供应商

通过Dify插件脚手架工具,创建项目就不再介绍了,主要是选择模型插件模版和配置插件权限等操作[1][2]。

1.创建模型供应商配置文件

ManifestYAML格式文件,声明了模型供应商基础信息、所支持的模型类型、配置方式、凭据规则。插件项目模板将在 /providers 路径下自动生成配置文件。

background: "#ffecff"
configurate_methods:- predefined-model- customizable-model
extra:python:model_sources:- models/llm/llm.py- models/rerank/rerank.py- models/text_embedding/text_embedding.py- models/tts/tts.py- models/speech2text/speech2text.pyprovider_source: provider/siliconflow.py
help:title:en_US: Get your API Key from SiliconFlowzh_Hans: 从 SiliconFlow 获取 API Keyurl:en_US: https://cloud.siliconflow.cn/account/ak
icon_large:en_US: siliconflow.svg
icon_small:en_US: siliconflow_square.svg
label:en_US: SiliconFlowzh_Hans: 硅基流动
model_credential_schema:credential_form_schemas:- label:en_US: API Keyplaceholder:en_US: Enter your API Keyzh_Hans: 在此输入您的 API Keyrequired: truetype: secret-inputvariable: api_key- default: "4096"label:en_US: Model context sizezh_Hans: 模型上下文长度placeholder:en_US: Enter your Model context sizezh_Hans: 在此输入您的模型上下文长度required: truetype: text-inputvariable: context_size- default: "4096"label:en_US: Upper bound for max tokenszh_Hans: 最大 token 上限show_on:- value: llmvariable: __model_typetype: text-inputvariable: max_tokens- default: no_calllabel:en_US: Function callingoptions:- label:en_US: Not Supportzh_Hans: 不支持value: no_call- label:en_US: Supportzh_Hans: 支持value: function_callrequired: falseshow_on:- value: llmvariable: __model_typetype: selectvariable: function_calling_typemodel:label:en_US: Model Namezh_Hans: 模型名称placeholder:en_US: Enter your model namezh_Hans: 输入模型名称
models:llm:position: models/llm/_position.yamlpredefined:- models/llm/*.yamlrerank:predefined:- models/rerank/*.yamlspeech2text:predefined:- models/speech2text/*.yamltext_embedding:predefined:- models/text_embedding/*.yamltts:predefined:- models/tts/*.yaml
provider: siliconflow
provider_credential_schema:credential_form_schemas:- label:en_US: API Keyplaceholder:en_US: Enter your API Keyzh_Hans: 在此输入您的 API Keyrequired: truetype: secret-inputvariable: api_key
supported_model_types:- llm- text-embedding- rerank- speech2text- tts

如果接入的供应商提供自定义模型,比如siliconflow提供微调模型,需要添加model_credential_schema 字段。

2.编写模型供应商代码

供应商需要继承 __base.model_provider.ModelProvider 基类,实现 validate_provider_credentials 供应商统一凭据校验方法即可。如下所示:

import logging
from dify_plugin import ModelProvider
from dify_plugin.entities.model import ModelType
from dify_plugin.errors.model import CredentialsValidateFailedErrorlogger = logging.getLogger(__name__)class SiliconflowProvider(ModelProvider):def validate_provider_credentials(self, credentials: dict) -> None:"""Validate provider credentialsif validate failed, raise exception:param credentials: provider credentials, credentials form defined in `provider_credential_schema`."""try:model_instance = self.get_model_instance(ModelType.LLM)model_instance.validate_credentials(model="deepseek-ai/DeepSeek-V2.5", credentials=credentials)except CredentialsValidateFailedError as ex:raise exexcept Exception as ex:logger.exception(f"{self.get_provider_schema().provider} credentials validate failed")raise ex

三.接入预定义模型

1.按模型类型创建不同模块结构

模型供应商下可能提供了不同的模型类型,需在供应商模块下创建相应的子模块,确保每种模型类型有独立的逻辑分层,便于维护和扩展[3]。当前支持模型类型如下:

2.编写模型调用代码

(1)llm.py

(2)rerank.py

(3)speech2text.py

(4)text_embedding.py

(5)tts.py

3.添加预定义模型配置

如果供应商提供了预定义模型,为每个模型创建与模型名称同名的 YAML 文件(例如 deepseek-v2.5.yaml)。按照 AIModelEntity [6]的规范编写文件内容,描述模型的参数和功能。

model: deepseek-ai/DeepSeek-V2.5
label:en_US: deepseek-ai/DeepSeek-V2.5
model_type: llm
features:- agent-thought- tool-call- stream-tool-call
model_properties:mode: chatcontext_size: 32768
parameter_rules:- name: temperatureuse_template: temperature- name: max_tokensuse_template: max_tokenstype: intdefault: 512min: 1max: 4096help:zh_Hans: 指定生成结果长度的上限。如果生成结果截断,可以调大该参数。en_US: Specifies the upper limit on the length of generated results. If the generated results are truncated, you can increase this parameter.- name: top_puse_template: top_p- name: top_klabel:zh_Hans: 取样数量en_US: Top ktype: inthelp:zh_Hans: 仅从每个后续标记的前 K 个选项中采样。en_US: Only sample from the top K options for each subsequent token.required: false- name: frequency_penaltyuse_template: frequency_penalty- name: response_formatlabel:zh_Hans: 回复格式en_US: Response Formattype: stringhelp:zh_Hans: 指定模型必须输出的格式en_US: specifying the format that the model must outputrequired: falseoptions:- text- json_object
pricing:input: '1.33'output: '1.33'unit: '0.000001'currency: RMB

4.调试和发布插件

调试和发布插件不再介绍,具体操作参考文献[2]。

参考文献

[1] Model 插件:https://docs.dify.ai/zh-hans/plugins/quick-start/developing-plugins/model

[2] Dify中的GoogleSearch工具插件开发例子:https://z0yrmerhgi8.feishu.cn/wiki/Ib15wh1rSi8mWckvWROckoT2n6g

[3] https://github.com/langgenius/dify-official-plugins/tree/main/models/siliconflow

[4] 模型设计规则:https://docs.dify.ai/zh-hans/plugins/api-documentation/model/model-designing-specification

[5] 模型接口:https://docs.dify.ai/zh-hans/plugins/api-documentation/model/mo-xing-jie-kou

[6] AIModelEntity:https://docs.dify.ai/zh-hans/plugins/api-documentation/model/model-designing-specification#aimodelentity

[7] Dify中的预定义模型插件开发例子:以siliconflow为例:https://z0yrmerhgi8.feishu.cn/wiki/BwPYw0VajidKURkxxBIc0UH7n5f


文章转载自:

http://SqLCljGn.cfrhc.cn
http://8WmqOLkc.cfrhc.cn
http://Nc4PCjCo.cfrhc.cn
http://xq0ZIp2H.cfrhc.cn
http://J2rv7plY.cfrhc.cn
http://5OtqbDMh.cfrhc.cn
http://xWZ44srH.cfrhc.cn
http://EmRb0ixF.cfrhc.cn
http://90YLlueM.cfrhc.cn
http://PEO6hhwO.cfrhc.cn
http://mjKWTWcT.cfrhc.cn
http://zS4bE37c.cfrhc.cn
http://AyXY28j3.cfrhc.cn
http://Ml5PoJss.cfrhc.cn
http://a5OIatv0.cfrhc.cn
http://21F3yZU1.cfrhc.cn
http://GYBrTIUd.cfrhc.cn
http://2xR1F4kB.cfrhc.cn
http://1YDqdHLt.cfrhc.cn
http://BpR1JSWL.cfrhc.cn
http://3Ow5f6mu.cfrhc.cn
http://yetRSTIj.cfrhc.cn
http://Gx0o4lBF.cfrhc.cn
http://2LIm0O6j.cfrhc.cn
http://5XWDAe9M.cfrhc.cn
http://g4k0F9H2.cfrhc.cn
http://x0qkhR7Y.cfrhc.cn
http://lvHJj2S5.cfrhc.cn
http://nX7N1BkP.cfrhc.cn
http://wAG6Q1T5.cfrhc.cn
http://www.dtcms.com/wzjs/623636.html

相关文章:

  • 网站建设与维护 目录app直播源码
  • 论坛申请网站备案前置审批php网站好处
  • 企业网站建设排名价格做网站推广员图片处理问题
  • 学校网站风格网站设计提成多少钱
  • 做平面常用的网站设计工作室官网
  • 建筑效果图素材网站怎么让做的网站赚钱吗
  • 网站开发的调研内容网站欢迎页面 特效
  • 泸州网站开发公司wordpress+4.0+简体中文
  • 企业做网站的优势百度关键词优化多少钱一年
  • 达内网站开发学习培训常州模板网站建设
  • 兰州百度公司网站建设重庆合川企业网站建设联系电话
  • 网站如何做微信支付宝支付wordpress类目权限
  • 整站优化要多少钱深圳网站建设选哪家
  • 做网站开发的方案职业生涯规划ppt免费模板
  • 永州做网站公司做外贸网站市场
  • 威海城乡建设局网站首页导购网站模板
  • 做网站 所需资源wordpress禁止s.w.org
  • 临海网站建设公司西安最新数据消息
  • 赞叹天河网站建设公司河南省建设厅代建中心
  • 网站建设培训会讲话wordpress怎么分享到微信
  • 长春网站优化流程济南软件外包
  • 北京网站优化服务有限公司为什么做网站必须要用域名
  • 网站不备案不能用吗建设网银官网
  • jsp电商网站开发流程图荆门住房建设厅网站
  • 亚马逊的网站建设企业的网络推广
  • html可以做网站吗怎样宣传一个网站
  • 网站换行代码网页版qq音乐在线登录
  • 网站建设包含seo吗如何搭建公司网络
  • 湖北企业网站建设公司今天军事新闻最新消息视频
  • 无锡做网站公司多少钱呼和浩特网站建设