OllamaChat
概述
OllamaChat 是一个超轻量的 Minecraft 插件,该插件使玩家能够实时与 AI 互动,上下文连贯对话。同时还可以直接调用其他 AI 服务(如 OpenAI)。无论您是想与 AI 伙伴聊天、提问,还是单纯探索 AI 的功能,OllamaChat 都能在 Minecraft 中实现这一切。
[v1.2.0 已支持 Bukkit、Spigot、Paper 与 Folia]
功能
- 多语言支持:默认支持英文和中文,用户可以根据需要切换语言或新增。
- 候选回复建议:生成可配置的、可点击执行的后续回复建议,带有悬停文本和速率限制。
- 多种 AI 支持:内置对 Ollama 和 OpenAI 等多个 AI 服务的支持。
- AI 驱动的对话:通过在 Minecraft 聊天中输入以
@bot、 /aichat 开头的消息与 AI 进行交流。
- Ollama 集成:利用 Ollama 的强大功能,提升您的 Minecraft 体验。
- 提示词管理:提示词管理系统,允许用户创建、删除、查看和选择提示词,以定制 AI 交互行为。
- 对话管理:对话管理功能,玩家可创建、切换、删除和列出与特定 AI 的对话,提升交互灵活性。
- 联网搜索:增加bocha/brave API支持,让AI回复时效性、准确性提高
使用方法
与 AI 聊天
要与 AI 互动,只需在 Minecraft 聊天中输入 @bot 加上您的消息。AI 会处理您的输入并作出相应回应。
示例:
@bot 今天的天气怎么样?
命令列表
| 命令 | 权限节点 | 说明 |
/ollamachat reload | ollamachat.reload | 重载插件配置和语言文件 |
/ollamachat toggle <ai-name> | ollamachat.toggle | 开关指定 AI 服务 |
/aichat <ai-name> <prompt> | ollamachat.use | 与指定 AI 服务对话 |
/ollamachat prompt set <promptName> <promptContent> | ollamachat.prompt.set | 新建提示词 |
/ollamachat prompt delete <promptName> | ollamachat.prompt.delete | 删除提示词 |
/ollamachat prompt list | ollamachat.prompt.list | 列出所有提示词 |
/ollamachat prompt select <promptName> | ollamachat.prompt.select | 设置默认提示词 |
/ollamachat prompt clear | ollamachat.prompt.select | 清空默认提示词 |
/ollamachat conversation new <aiName> <convName> | ollamachat.conversation.new | 新建对话 |
/ollamachat conversation select <aiName> <convName> | ollamachat.conversation.select | 切换对话 |
/ollamachat conversation delete <aiName> <convName> | ollamachat.conversation.delete | 删除对话 |
/ollamachat conversation list <aiName> | ollamachat.conversation.list | 列出某 AI 的所有对话 |
/ollamachat suggests toggle | ollamachat.suggests.toggle | 开关候选回复 |
/ollamachat suggests-presets toggle | ollamachat.suggests-presets.toggle | 开关预设候选回复 |
/ollamachat search toggle | ollamachat.search.toggle | 开关联网搜索 |
/ollamachat search status | ollamachat.search.status | 查看当前搜索配置 |
/ollamachat search query <text> | ollamachat.search.query | 手动联网搜索并获取 AI 回复 |
/ollamachat search engine [name] | ollamachat.search.engine | 查看或切换搜索引擎 |
/ollamachat search setkey <engine> <key> | ollamachat.search.setkey | 设置搜索引擎的 API 密钥 |
/ollamachat search setcount <number> | ollamachat.search.setcount | 设置搜索结果数量(1-50) |
/ollamachat search addkeyword <word> | ollamachat.search.keywords | 添加自动搜索触发词 |
/ollamachat search removekeyword <word> | ollamachat.search.keywords | 删除自动搜索触发词 |
/ollamachat search listkeywords | ollamachat.search.keywords | 列出所有触发词 |
权限节点
| 权限节点 | 说明 |
ollamachat.reload | 重载配置与语言文件 |
ollamachat.toggle | 开关 AI 服务 |
ollamachat.use | 向 AI 服务发送消息 |
ollamachat.prompt.set | 创建并保存提示词 |
ollamachat.prompt.delete | 删除提示词 |
ollamachat.prompt.list | 列出所有提示词 |
ollamachat.prompt.select | 选择或清空默认提示词 |
ollamachat.conversation.new | 新建对话 |
ollamachat.conversation.select | 切换对话 |
ollamachat.conversation.delete | 删除对话 |
ollamachat.conversation.list | 列出某 AI 的对话 |
ollamachat.suggests.toggle | 开关候选回复 |
ollamachat.suggests-presets.toggle | 开关预设候选回复 |
ollamachat.search.toggle | 开关联网搜索 |
ollamachat.search.status | 查看搜索配置 |
ollamachat.search.query | 执行手动联网搜索 |
ollamachat.search.engine | 切换搜索引擎 |
ollamachat.search.setkey | 设置搜索引擎 API 密钥 |
ollamachat.search.setcount | 设置搜索结果数量 |
ollamachat.search.keywords | 管理触发关键词 |
安装
- 下载插件:从 插件 GitHub 仓库 或 Modrinth 获取最新版本的 OllamaChat。
- 安装插件:将下载的
.jar 文件放入 Minecraft 服务器的 plugins 文件夹中。
- 配置插件:修改
config.yml 文件以自定义 AI 设置。
- 重新加载插件:使用
/ollamachat reload 命令应用任何配置更改。
配置
插件的配置文件 (config.yml) 允许您自定义 AI 互动的各个方面。
示例 config.yml:
# OllamaChat 配置文件 (版本: 1.1.8)
# ============================================================
# 通用设置
# ============================================================
# 使用的语言文件 (en_us, zh_cn 等)
language: zh_cn
# 启用 Ollama 集成
ollama-enabled: true
# Ollama API 地址
ollama-api-url: "http://localhost:11434/api/generate"
# 默认 Ollama 模型
model: "llama3"
# 每个对话保留的最大历史消息数
max-history: 5
# 最大回复长度(字符数)
max-response-length: 500
# 触发 AI 回复的消息前缀
trigger-prefixes:
- "@bot"
- "@ai"
# ============================================================
# 流式传输设置(此功能因现阶段局限性暂未完善开发)
# ============================================================
stream-settings:
enabled: true
# ============================================================
# 提示词设置
# ============================================================
# 默认提示词名称(留空则不使用)
default-prompt: ""
# 自定义提示词
# 可通过 /ollamachat prompt select 选用
prompts: {}
# ============================================================
# 候选回复设置
# ============================================================
# 用于生成候选回复的 AI 模型
suggested-response-models:
- "llama3"
# 是否启用候选回复
suggested-responses-enabled: true
# 生成的回复数量
suggested-response-count: 3
# 建议生成的冷却时间(秒,0 表示无限制)
suggested-response-cooldown: 10
# 是否启用预设回复(AI 不可用时的备用)
suggested-response-presets-enabled: true
# 预设回复内容
suggested-response-presets:
- "我明白你的意思。"
- "有意思。"
- "再多说一点。"
# 各模型用于生成建议的开关
suggested-response-model-toggles: {}
# ============================================================
# 联网搜索设置
# ============================================================
web-search:
# 是否启用联网搜索
enabled: false
# 消息含触发词时自动搜索
auto-trigger: true
# 自动搜索触发词
trigger-keywords:
- "搜索"
- "查一下"
- "找找"
- "查询"
- "什么是"
- "谁是"
- "什么时候"
- "在哪里"
# 返回的搜索结果数量 (1-50)
result-count: 5
# ============================================================
# 搜索引擎配置
# ============================================================
# 可选: bocha 或 brave
engine: "brave"
# ---------- Bocha 搜索引擎(侧重中文)----------
bocha:
# Bocha API 密钥(必填)
api-key: ""
# 仅搜索指定站点
include-sites: false
include-sites-list: []
# 排除指定站点
exclude-sites: false
exclude-sites-list: []
# 时间范围(天,0 为不限)
time-range: 0
# 时效性: Day, Week, Month, Quarter, Year
freshness: ""
# ---------- Brave 搜索引擎(国际)----------
brave:
# Brave API 密钥(必填)
api-key: ""
# 国家代码(如 US, CN, GB)
country: "US"
# 搜索语言(如 en, zh)
search-lang: "en"
# UI 语言
ui-lang: "en"
# 安全搜索级别: off, moderate, strict
safe-search: "moderate"
# ---------- 搜索结果格式化模板 ----------
# 占位符:
# {search_results} - 格式化后的搜索结果
# {prompt} - 用户原始问题
prompt-template: "根据以下搜索结果回答用户问题:\n\n{search_results}\n\n用户问题:{prompt}\n\n请基于搜索结果给出准确详细的回答。如果信息不足,请说明。"
# ============================================================
# 数据库设置
# ============================================================
database:
# 数据库类型: sqlite 或 mysql
type: sqlite
# MySQL 配置(仅 type 为 mysql 时生效)
mysql:
host: "localhost"
port: 3306
database: "ollamachat"
username: "root"
password: ""
# HikariCP 连接池设置
hikari:
maximum-pool-size: 10
minimum-idle: 2
connection-timeout: 30000
idle-timeout: 600000
max-lifetime: 1800000
cache-prep-stmts: true
prep-stmt-cache-size: 250
prep-stmt-cache-sql-limit: 2048
# ============================================================
# 进度条显示设置
# ============================================================
progress-display:
# 是否显示生成进度条
enabled: true
# 显示类型: bossbar 或 actionbar
type: "bossbar"
# BossBar 颜色(仅 type 为 bossbar 时生效)
color: "BLUE"
# BossBar 样式(仅 type 为 bossbar 时生效)
style: "SOLID"
# 更新间隔(刻,20 刻 = 1 秒)
update-interval: 1
# ============================================================
# 其他 AI 集成
# ============================================================
# 可配置 OpenAI、Claude 等其他 AI 服务
other-ai-configs: {}
# OpenAI 示例:
# openai:
# api-url: "https://api.openai.com/v1/chat/completions"
# api-key: "your-api-key-here"
# model: "gpt-3.5-turbo"
# enabled: true
# messages-format: true
#
# Claude 示例:
# claude:
# api-url: "https://api.anthropic.com/v1/messages"
# api-key: "your-api-key-here"
# model: "claude-3-opus-20240229"
# enabled: true
# messages-format: true
贡献
我们欢迎社区成员为改进 OllamaChat 做出贡献!如果您有想法、错误报告或功能请求,请在 GitHub 仓库 中提交问题或拉取请求。
许可证
OllamaChat 采用 MIT 许可证。更多详情请参阅 LICENSE 文件。
支持
如需帮助、问题或反馈,请访问我们的 GitHub 仓库或前往我们的聊天室。
注意:OllamaChat 正在积极开发中,会定期添加新功能和改进。