利用 Llama 3.1模型 + Dify开源LLM应用开发平台,在你的Windows环境中搭建一套AI工作流

devtools/2024/10/18 2:16:20/

文章目录

    • 1. 什么是Ollama
    • 2. 什么是Dify?
    • 3. 下载Ollama
    • 4. 安装Ollama
    • 5. Ollama Model library模型库
    • 6. 本地部署Llama 3.1模型
    • 7. 安装Docker Desktop
    • 8. 使用Docker-Compose部署Dify
    • 9. 注册Dify账号
    • 10. 集成本地部署的 Llama 3.1模型
    • 11. 集成智谱AI大模型
    • 12. 添加Dify团队成员
    • 13. 导入DSL - 小红书文案生成脚本
    • 14. 所遇问题
    • 15. 参考链接

llama_1">1. 什么是Ollama

image-20241012175128004

Ollama 是一种可以学习和回答问题的 AI 模型,它能够进行自然语言交互,类似于人类对话。它具备一些独特的功能,如:

  1. 自主学习: Ollama 可以通过自身的学习过程改善其回答质量和知识范围。
  2. 无限回复: Ollama 能够不断地回答问题,无论你问多少个,直到你满意为止。
  3. 自然语言: Ollama 支持多种语言,包括英语、西班牙语等,你可以与它进行母语对话。

2. 什么是Dify?

Dify是一个开源的LLM应用程序开发平台。Dify直观的界面结合了人工智能工作流程、RAG管道、代理功能、模型管理、可观察性功能等,让您快速从原型进入生产。

llama_17">3. 下载Ollama

下载链接:https://ollama.com

image-20241012170904054

image-20241012170949264

llama_28">4. 安装Ollama

打开安装包,安装Ollama

image-20240814172442161

llama_Model_library_34">5. Ollama Model library模型库

Ollama supports a list of models available on ollama.com/library

Here are some example models that can be downloaded:

ModelParametersSizeDownload
Llama 3.18B4.7GBollama run llama3.1
Llama 3.170B40GBollama run llama3.1:70b
Llama 3.1405B231GBollama run llama3.1:405b
Phi 3 Mini3.8B2.3GBollama run phi3
Phi 3 Medium14B7.9GBollama run phi3:medium
Gemma 22B1.6GBollama run gemma2:2b
Gemma 29B5.5GBollama run gemma2
Gemma 227B16GBollama run gemma2:27b
Mistral7B4.1GBollama run mistral
Moondream 21.4B829MBollama run moondream
Neural Chat7B4.1GBollama run neural-chat
Starling7B4.1GBollama run starling-lm
Code Llama7B3.8GBollama run codellama
Llama 2 Uncensored7B3.8GBollama run llama2-uncensored
LLaVA7B4.5GBollama run llava
Solar10.7B6.1GBollama run solar

Note:You should have at least 8 GB of RAM available to run the 7B models, 16 GB to run the 13B models, and 32 GB to run the 33B models.

6. 本地部署Llama 3.1模型

To run and chat with Llama 3.1:

ollama run llama3.1:8b

image-20240814171432310

Start ollama

C:\Users\xyb>ollama serve

image-20241012180127996

List models on your computer

C:\Users\xyb>ollama list
NAME            ID              SIZE    MODIFIED
llama3.1:8b     91ab477bec9d    4.7 GB  8 weeks ago

Show model information

C:\Users\xyb>ollama show llama3.1:8bModelarch                    llamaparameters              8.0Bquantization            Q4_0context length          131072embedding length        4096Parametersstop    "<|start_header_id|>"stop    "<|end_header_id|>"stop    "<|eot_id|>"LicenseLLAMA 3.1 COMMUNITY LICENSE AGREEMENTLlama 3.1 Version Release Date: July 23, 2024

ollama -h

C:\Users\xyb>ollama -h
Large language model runnerUsage:ollama [flags]ollama [command]Available Commands:serve       Start ollamacreate      Create a model from a Modelfileshow        Show information for a modelrun         Run a modelpull        Pull a model from a registrypush        Push a model to a registrylist        List modelsps          List running modelscp          Copy a modelrm          Remove a modelhelp        Help about any commandFlags:-h, --help      help for ollama-v, --version   Show version informationUse "ollama [command] --help" for more information about a command.

7. 安装Docker Desktop

在Windows 环境下,安装Docker Desktop。

image-20241012174905791

8. 使用Docker-Compose部署Dify

进入 Dify 源代码的 docker 目录,执行一键启动命令:

cd dify/dockercp .env.example .envdocker compose up -d

输入过程如下:

C:\dify\docker>docker-compose up  -d
[+] Running 11/11✔ Network docker_default             Created                     0.1s✔ Network docker_ssrf_proxy_network  Created                     0.0s✔ Container docker-web-1             Started                     1.4s✔ Container docker-weaviate-1        Started                     1.2s✔ Container docker-ssrf_proxy-1      Started                     1.9s✔ Container docker-sandbox-1         Started                     1.9s✔ Container docker-redis-1           Started                     1.4s✔ Container docker-db-1              Started                     1.7s✔ Container docker-worker-1          Started                     2.6s✔ Container docker-api-1             Started                     2.8s✔ Container docker-nginx-1           Started                     3.7s

启动完成后,你的 docker 里就会看到这个:

在这里插入图片描述
image-20241012120722598

也可以在Docker-Compose中查看到已启动的容器。

image-20240818150320373

9. 注册Dify账号

打开浏览器,输入http://127.0.0.1

设置管理员账户。输入邮箱、用户名、密码。

image-20241012163648495

填写完成后,点击设置。

image-20240815093239830

跳转至登录揭秘那,输入邮箱和密码完成登录。

image-20240815093327170

至此,我们利用Docker Compose 在Windows本地环境中,完成Dify的搭建部署工作。

image-20240815093356383

10. 集成本地部署的 Llama 3.1模型

  • 点击设置

image-20240815093653323

  • 选择模型提供商Ollama

image-20240815093813927

填写如下参数信息。

!!!注意!!!:模型名称和基础URL要填写正确,否则会添加失败报错。

image-20240818145633535

  • 添加成功。

image-20240818144324916

  • 我们也可以输入以下地址,验证所添加的ollama模型是否已启动。

image-20241012172323267

11. 集成智谱AI大模型

  • 获取智谱 AI API Key

获取链接:智谱AI开放平台

image-20240818145757305

2e0556xxxxxxxxxxxxxxxxxxxxxxxxxxxE6of

image-20241012164255172

image-20241012164336131

image-20241012164440679

12. 添加Dify团队成员

image-20241012164545813

image-20241012164614694

http://127.0.0.1/activate?email=xxxxxxxx@outlook.com&token=34aa37d7-7d9a-4b64-9ed6-d0372380ad7f

image-20241012165623216

image-20241012165659255

13. 导入DSL - 小红书文案生成脚本

  • 导入DSL

image-20241012170623745

  • 小红书文案生成脚本工作流如下:

image-20240815093458359

  • 输入关键字

image-20241012174128200

  • 输出结果

image-20241012174037311

  • 生成内容如下:
标题:
1. 🌟【日常美学】🌼 这样的小确幸,让你幸福感爆棚!🍵📖✨
2. 💖【生活小秘诀】🌸 发现日常中的小美好,幸福感瞬间up!📸
3. 🌿【限量版生活】🌼 每天都是独一无二的美好!🍵📖✨
4. 📖【生活美学】🌸 一本好书,一杯香茗,幸福感满满!💖
5. 🌼【小确幸分享】🍵 这样的小日常,让你心情大好!📸
6. ✨【日常小美好】🌸 发现生活中的小确幸,幸福感飙升!📖
7. 🍵【生活小确幸】🌼 一杯香茗,一束鲜花,幸福感满满!💖
8. 📸【记录美好】🌸 每天都是限量版,用心发现小确幸!✨
9. 💖【生活美学】🌼 这样的小日常,幸福感瞬间up!🍵📖
10. 🌿【小确幸日常】🌸 一本好书,一束鲜花,幸福感爆棚!✨
11. 🌼【日常小秘诀】🍵 发现生活中的小美好,幸福感大增!💖
12. 📖【限量版日常】🌸 每天都是独一无二的美好!📸✨
13. ✨【生活小确幸】🌼 一杯香茗,一本好书,幸福感满满!🍵
14. 🍵【日常美学】🌸 这样的小确幸,让你心情大好!💖
15. 📸【小确幸分享】🌼 发现日常中的小美好,幸福感飙升!📖
16. 💖【记录美好】🌸 每天都是限量版,用心发现小确幸!🌿✨
17. 🌿【生活小美好】🌼 一本好书,一束鲜花,幸福感满满!🍵
18. 🌼【日常小确幸】🍵 这样的小日常,幸福感瞬间up!📸💖
19. 📖【小确幸日常】🌸 发现生活中的小美好,幸福感大增!✨
20. ✨【限量版生活】🌼 每天都是独一无二的美好!🍵📖💖
文案:
🌿🌸【生活小确幸】🍵 每天都是限量版,用心发现生活中的小美好!📖 一杯香茗,🌼 一本好书,简单日常也能闪闪发光✨。分享我的生活小秘诀,幸福感瞬间up up!📸 记录每一刻,生活美学,从心开始💖。你也有这样的小确幸吗?快来评论区分享吧!🌟🌿#生活美学 #小确幸 #日常分享 #幸福感 #记录美好 #限量版生活

14. 所遇问题

C:\Users\xyb>ollama serve
Error: listen tcp :11434: bind: An attempt was made to access a socket in a way forbidden by its access permissions.C:\Users\xyb>ollama run llama3.1:8b
Error: could not connect to ollama app, is it running?

需要关闭本地环境中的代理。

An error occurred during credentials validation: HTTPConnectionPool(host='127.0.0.1', port=11434): Max retries exceeded with url: /api/chat (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7eff701373d0>: Failed to establish a new connection: [Errno 111] Connection refused'))An error occurred during credentials validation: HTTPConnectionPool(host='localhost', port=11434): Max retries exceeded with url: /api/chat (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7eff70136260>: Failed to establish a new connection: [Errno 111] Connection refused'))

填写Ollama模型名称和基础URL信息有误导致的。

image-20240815115529322

image-20240815115533417

An error occurred during credentials validation: API request failed with status code 404: {"error":"model \"Llama 3.1\" not found, try pulling it first"}

image-20240818132217486

15. 参考链接

1️⃣https://mp.weixin.qq.com/s/jAX7uI_gjV4e7nzgb_rkrQ

2️⃣https://github.com/langgenius/dify

3️⃣Windows preview · Ollama Blog

4️⃣llama3.1:8b

5️⃣Download Ollama on Windows

6️⃣ollama/ollama: Get up and running with Llama 3.1, Mistral, Gemma 2, and other large language models.

Dify 教程二:使用本地大模型 | Coder 小站 (ihsxu.com)

github.com/langgenius/dify)

3️⃣Windows preview · Ollama Blog

4️⃣llama3.1:8b

5️⃣Download Ollama on Windows

6️⃣ollama/ollama: Get up and running with Llama 3.1, Mistral, Gemma 2, and other large language models.


http://www.ppmy.cn/devtools/125193.html

相关文章

昇思MindSpore进阶教程--数据处理性能优化(下)

大家好&#xff0c;我是刘明&#xff0c;明志科技创始人&#xff0c;华为昇思MindSpore布道师。 技术上主攻前端开发、鸿蒙开发和AI算法研究。 努力为大家带来持续的技术分享&#xff0c;如果你也喜欢我的文章&#xff0c;就点个关注吧 操作系统性能优化 由于MindSpore的数据处…

闲谈Promise

预备知识 回调函数&#xff1a;当一个函数作为参数传入另一个函数中&#xff0c;并且它不会立刻执行&#xff0c;当满足一定条件之后&#xff0c;才会执行&#xff0c;这种函数称为回调函数。比如&#xff1a;定时器。异步任务&#xff1a;与之对应的概念是同步任务&#xff0…

AutoKey:开启高效办公与生活的自动化之门

1、AutoKey 的整体优势AutoKey 是开源桌面自动化工具&#xff0c;虽专为 Linux 和 X11 用户设计&#xff0c;但在其他操作系统上也有卓越表现。其核心是与 Python 完美融合&#xff0c;带来无限可能&#xff0c;让用户能轻松创建自动化任务。 2、在日常办公中的作用 在日常办公…

路由通信 的 VLAN技术

一、VLAN基础 虚拟局域网&#xff08;Virtual Local Area Network&#xff0c;VLAN&#xff09; 根据管理功能、组织机构或应用类型对交换局域网进行分段而形成的逻辑网络。 交换机最多支持4094个VLAN&#xff0c;其中默认管理VLAN是VLAN1&#xff0c;不能创建&#xff0c;也…

支持向量机(SVM)基础教程

一、引言 支持向量机&#xff08;Support Vector Machine&#xff0c;简称SVM&#xff09;是一种高效的监督学习算法&#xff0c;广泛应用 于分类和回归分析。SVM以其强大的泛化能力、简洁的数学形式和优秀的分类效果而备受机器学 习领域的青睐。 二、SVM基本原理 2.1 最大间…

Spring Boot在医疗信息交互系统中的应用

第1章绪论 计算机已经从科研院所&#xff0c;大中型企业&#xff0c;走进了平常百姓家&#xff0c;Internet遍及世界各地&#xff0c;在网上能够用计算机进行文字草拟、修改、打印清样、文件登陆、检索、综合统计、分类、数据库管理等&#xff0c;用科学的方法将无序的信息进行…

MySQL中表的操作

目录 一、查看所有表 1.1、语法 二、创建表 2.1、语法 2.2、示例&#xff1a; 2.3、创建数据加时使⽤校验语句[if not exists] 三、查看表结构 3.1、语法 3.2、示例 四、删除表 4.1、语法 4.2、示例 4.3、注意事项 五、主要数据类型 5.1、数值类型 5.2、日期和…

论文笔记:RelationPrompt :Zero-Shot Relation Triplet Extraction

论文来源: ACL Findings 2022 论文链接:https://arxiv.org/pdf/2203.09101.pdf 论文代码:http://github.com/declare-lab/RelationPrompt 本篇论文是由阿里达摩院自然语言智能实验室于2022年发表的关于零样本关系抽取的顶会论文,本篇博客将记录我在阅读过程中的一些笔记…