mirror of
https://github.com/langgenius/dify-docs.git
synced 2026-03-27 13:28:32 +07:00
105 lines
3.9 KiB
Plaintext
105 lines
3.9 KiB
Plaintext
---
|
||
dimensions:
|
||
type:
|
||
primary: reference
|
||
detail: core
|
||
level: beginner
|
||
standard_title: Model Plugin Introduction
|
||
language: zh
|
||
title: Model 插件
|
||
description: 介绍模型插件的基本概念和结构。模型插件让Dify能够调用不同供应商(如OpenAI、Anthropic、Google等)的各类模型,包括大语言模型(LLM)、文本嵌入、语音转文字等不同类型。
|
||
todo: 考虑恢复被注释的'开始开发模型插件'章节,提供初学者友好的3步骤快速指引
|
||
---
|
||
|
||
Model 模型插件使 Dify 平台能够调用该模型供应商下的所有 LLM。例如,安装 OpenAI 模型插件后,Dify 平台即可调用 OpenAI 提供的 `GPT-4`、`GPT-4o-2024-05-13` 等模型。
|
||
|
||
## 模型插件结构
|
||
|
||
为了便于理解在开发模型插件过程中可能涉及的概念,以下是模型插件内的结构简介:
|
||
|
||
* **模型供应商**:大模型的开发公司,例如 **OpenAI、Anthropic、Google** 等;
|
||
* **模型分类**:根据模型供应商的不同,存在大语言模型(LLM)、文本嵌入模型(Text embedding)、语音转文字(Speech2text)等分类;
|
||
* **具体模型**:`claude-3-5-sonnet`、`gpt-4-turbo` 等。
|
||
|
||
插件项目中的代码层级结构:
|
||
|
||
```bash
|
||
- 模型供应商
|
||
- 模型分类
|
||
- 具体模型
|
||
```
|
||
|
||
以 **Anthropic** 为例,模型插件的示例结构如下:
|
||
|
||
```bash
|
||
- Anthropic
|
||
- llm
|
||
claude-3-5-sonnet-20240620
|
||
claude-3-haiku-20240307
|
||
claude-3-opus-20240229
|
||
claude-3-sonnet-20240229
|
||
claude-instant-1.2
|
||
claude-instant-1
|
||
```
|
||
|
||
以 OpenAI 为例,因为它支持多种模型类型,所以存在多层模型分类,结构如下:
|
||
|
||
```bash
|
||
├── models
|
||
│ ├── llm
|
||
│ │ ├── chatgpt-4o-latest
|
||
│ │ ├── gpt-3.5-turbo
|
||
│ │ ├── gpt-4-0125-preview
|
||
│ │ ├── gpt-4-turbo
|
||
│ │ ├── gpt-4o
|
||
│ │ ├── llm
|
||
│ │ ├── o1-preview
|
||
│ │ └── text-davinci-003
|
||
│ ├── moderation
|
||
│ │ ├── moderation
|
||
│ │ └── text-moderation-stable
|
||
│ ├── speech2text
|
||
│ │ ├── speech2text
|
||
│ │ └── whisper-1
|
||
│ ├── text_embedding
|
||
│ │ ├── text-embedding-3-large
|
||
│ │ └── text_embedding
|
||
│ └── tts
|
||
│ ├── tts-1-hd
|
||
│ ├── tts-1
|
||
│ └── tts
|
||
```
|
||
|
||
## 模型配置
|
||
|
||
模型插件通过配置文件定义模型的行为和属性。详细的模型设计规则和配置格式请参考[模型设计规则](/plugin-dev-zh/0411-model-designing-rules)文档和[模型架构](/plugin-dev-zh/0412-model-schema)规范。
|
||
|
||
{/*
|
||
### 开始开发模型插件
|
||
|
||
请参考以下顺序阅读文档,了解如何开发一个模型插件。
|
||
|
||
1. [创建模型供应商](/zh-hans/plugins/quick-start/develop-plugins/model-plugin/create-model-providers)
|
||
2. 接入[预定义](/zh-hans/guides/model-configuration/predefined-model) / [自定义](/zh-hans/plugins/quick-start/develop-plugins/model-plugin/customizable-model)模型
|
||
3. [调试插件](/zh-hans/plugins/quick-start/debug-plugin)
|
||
*/}
|
||
|
||
## 进一步阅读
|
||
|
||
- [快速接入一个新模型](/plugin-dev-zh/0211-getting-started-new-model) - 学习如何为已支持的供应商添加新模型
|
||
- [模型设计规则](/plugin-dev-zh/0411-model-designing-rules) - 详细了解模型配置的规范
|
||
- [模型架构](/plugin-dev-zh/0412-model-schema) - 深入理解模型插件的架构
|
||
- [通用规范定义](/plugin-dev-zh/0411-general-specifications) - 了解插件元数据定义方式
|
||
- [插件开发基本概念](/plugin-dev-zh/0111-getting-started-dify-plugin) - 返回插件开发入门指南
|
||
|
||
{/*
|
||
Contributing Section
|
||
DO NOT edit this section!
|
||
It will be automatically generated by the script.
|
||
*/}
|
||
|
||
---
|
||
|
||
[编辑此页面](https://github.com/langgenius/dify-docs/edit/main/plugin-dev-zh/0411-model-plugin-introduction.mdx) | [提交问题](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml)
|
||
|