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

news/2024/10/20 1:16:43/

文章目录

    • 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/news/1540382.html

相关文章

计算机前沿技术-人工智能算法-大语言模型-最新研究进展-2024-10-13

计算机前沿技术-人工智能算法-大语言模型-最新研究进展-2024-10-13 目录 文章目录 计算机前沿技术-人工智能算法-大语言模型-最新研究进展-2024-10-13目录1. The Cognitive Capabilities of Generative AI: A Comparative Analysis with Human Benchmarks2. WALL-E: World Alig…

Open-WebUI

Open-WebUI特点⭐ ️直观的界面&#xff1a;聊天界面从 ChatGPT 中汲取灵感&#xff0c;确保用户友好的体验。响应式设计&#xff1a;在桌面和移动设备上享受无缝体验。⚡快速响应&#xff1a;享受快速响应的性能。轻松设置&#xff1a;使用 Docker 或 Kubernetes&#xff08;…

ToB项目身份认证AD集成(完):利用ldap.js实现与windows AD对接实现用户搜索、认证、密码修改等功能 - 以及针对中文转义问题的补丁方法介绍

在前面的两篇文章中,我详细的介绍了使用ldap与window AD服务集成,实现ToB项目中的身份认证集成方案,包括技术方案介绍、环境配置: ToB项目身份认证AD集成(一):基于目录的用户管理、LDAP和Active Directory简述 ToB项目身份认证AD集成(二):一分钟搞定window server 20…

理解C#中空值条件运算符及空值检查简化

前言 .NET 4.6 及以上版本,提供了空值条件运算符 ?. 和 ?[]。这些运算符的引入,为我们提供了一种简明的方式来处理空值的场景、简化空值检查,可避免 NullReferenceExceptions 的异常。本文将探索 C# 的空值检查运算符。 介绍 空值,这里指的是 null。在定义对象后,未对其…

深入了解Vue Router:基本用法、重定向、动态路由与路由守卫的性能优化

文章目录 1. 引言2. Vue Router的基本用法2.1 基本配置 3. 重定向和命名路由的使用3.1 重定向3.2 命名路由 4. 在Vue Router中如何处理动态路由4.1 动态路由的概念4.2 如何处理动态路由4.3 动态路由的懒加载 5. 路由守卫的实现与性能影响5.1 什么是路由守卫&#xff1f;5.2 路由…

2024入门测参考答案(c语言版)

先自己看代码思考&#xff0c;不理解的地方可以截图私聊…… 7-1 祝福祖国&#xff01; 这是一个编程题模板。 2024年即将到来&#xff0c;作为一名大学生&#xff0c;为了表达在新的一年里&#xff0c;对祖国的祝福&#xff0c;请编写程序输出祝福语&#xff1a;在新的一年…

【Linux】进程ID和线程ID在日志中的体现

在分析内核打印日志流程的时候&#xff0c;发现有时候同一个进程函数调用关系比较混乱&#xff08;因为只打印了进程号&#xff09;&#xff0c;现象就是一个函数走着走着不知道走哪里去了。 另一个现象是&#xff0c;在Linux启动Firefox的时候&#xff0c;启了大概80个进程&…

android11 usb摄像头添加多分辨率支持

部分借鉴于&#xff1a;https://blog.csdn.net/weixin_45639314/article/details/142210634 目录 一、需求介绍 二、UVC介绍 三、解析 四、补丁修改 1、预览的限制主要存在于hal层和framework层 2、添加所需要的分辨率&#xff1a; 3、hal层修改 4、frameworks 5、备…