对话式AI使用笔记
· 阅读需 4 分钟
阅读量: 101
阅读人次: 102
ChatGPT的火爆,给我们日常生活工作带来了很大的影响。目前,他就像一个智能超级搜索引擎,通过对话向它提问,以得到我们想要的回答,而不像传统的 Google,百度搜索只能通过关键词进行匹配搜索。
在日常使用时,也产生了很多使用方面的需求:
- ChatGPT 单独使用,购买会员比较贵,所有需要寻找其他付费中转服务。
- 需要部署一个属于自己的聊天应用,因为目前各家的效果都不一样,我们可以尝试选择不同的大语言模型进行提问。
- 本地部署,主要是使用 Ollama 部署一些 越狱版 模型,进行体验。
LobeChat
LobeChat 是一个现代化设计的开源 AI 聊天框架,旨在整合市面上众多主流的AI大模型(如ChatGPT、Gemini Pro、Claude3、Mistral、LLaMA2等),为用户提供统一的平台管理与使用体验。通过LobeChat,用户无需逐一访问各大模型网站,降低了使用门槛。此外,LobeChat是完全免费且开源的。
通过 Docker镜像 部署:
docker run -it -d --name lobe-chat-database -p 3210:3210 \
-e DATABASE_URL=postgres://postgres:mysecretpassword@host.docker.internal:5432/postgres \
-e KEY_VAULTS_SECRET=jgwsK28dspyVQoIf8/M3IIHl1h6LYYceSYNXeLpy6uk= \
-e NEXT_AUTH_SECRET=3904039cd41ea1bdf6c93db0db96e250 \
-e NEXT_AUTH_SSO_PROVIDERS=auth0 \
-e AUTH_AUTH0_ID=xxxxxx \
-e AUTH_AUTH0_SECRET=cSX_xxxxx \
-e AUTH_AUTH0_ISSUER=https://lobe-chat-demo.us.auth0.com \
-e APP_URL=http://localhost:3210 \
-e NEXTAUTH_URL=http://localhost:3210/api/auth \
-e S3_ACCESS_KEY_ID=xxxxxxxxxx \
-e S3_SECRET_ACCESS_KEY=xxxxxxxxxx \
-e S3_ENDPOINT=https://xxxxxxxxxx.r2.cloudflarestorage.com \
-e S3_BUCKET=lobechat \
-e S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com \
lobehub/lobe-chat-database
因为我们使用的是之前的创建的 pgvector/pgvector:pg16
容器,其并没有创建相关的数据库和表。这里我们手动创建:
# 进入容器内部,使用超级用户连接到 PostgreSQL
docker exec -it postgres bash
psql -U postgres
# 在 psql 中创建/删除 数据库lobechat
CREATE DATABASE lobechat;
DROP DATABASE IF EXISTS lobechat;
# 使用智普时,更改表属性
psql -U postgres -d lobechat
ALTER TABLE embeddings
ALTER COLUMN embeddings TYPE vector(256);
Ollama
在 Windows 下参照官方文档进行安装,在 Ollama 安装程序 OllamaSetup.exe
所在的文件夹使用终端打开,然后输入命令:
.\OllamaSetup.exe /DIR="F:\Ollama"
安装完成后:
- 设置用户环境变量
OLLAMA_MODELS
为F:\Ollama\Models
以更改模型文件存放位置。 - 设置用户环境变量
OLLAMA_ORIGINS
为*
,以配置 Ollama 允许跨域访问。 - 设置用户环境变量
OLLAMA_HOST
为0.0.0.0
,以运行 FRP 外网访问。 - 重启以保证环境变量生效。
可以使用 huihui_ai 提供的模型,以跳过限制。
ollama run huihui_ai/deepseek-r1-abliterated:32b
Ollama API 在 http://localhost:11434 上提供服务。
使用 nginx 进行反向代理:
server {
listen 443 ssl;
server_name next.amass.fun;
# 其他配置
location /ollama/ {
rewrite ^/ollama/(.*) /$1 break;
proxy_http_version 1.1;
proxy_set_header Connection $http_connection;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header x-wiz-real-ip $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host "ollama.amass.fun";
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://frp_http_proxy;
}
}
frp 配置:
[[proxies]]
name = "ollama"
type = "http"
localIP = "127.0.0.1"
localPort = 11434
customDomains = ["ollama.amass.fun"]
我们并没有 ollama.amass.fun
这个域名,只是在 nginx 反向代理时,对 Host 进行了重写,为了方便 FRP 根据域名进行转发。
DeepSeek
DeepSeek 以其推理能力和低成本而名声大噪。开放平台可以提供 API Key 服务供接入其他应用。