# OllamaChat
## 概述
**OllamaChat** 是一个尖端的 Minecraft 插件,它集成了 Ollama 和 OpenAI 类的 API,能够实现实时的 AI 交互、多语言支持以及高级的提示和对话管理,为游戏带来沉浸式体验。
### 示例

## 特性
- **AI 驱动的对话**: 使用 `@bot` 或 `@ai` 前缀与 AI 聊天,获得动态、智能的回复。
- **Ollama & OpenAI 集成**: 利用先进的 AI 模型来增强你的 Minecraft 体验。
- **多语言支持**: 通过 `lang` 文件夹文件支持多种语言(例如:英语、简体中文)。
- **切换 AI 服务**: 使用 `/ollamachat toggle ` 启用/禁用 AI 服务。
- **提示管理**: 创建、删除、列出、选择或清除自定义提示,以定制 AI 交互。
- **对话管理**: 启动、切换、删除或查看与 AI 实体的玩家特定对话。
- **智能回复建议**: 生成可配置、可点击的后续建议,带有悬停文本和速率限制。
- **进度显示**: 提示答案生成状态栏的视觉显示 (0% 到 100%)。
- **公共 API**: `OllamaChatAPI` 用于插件扩展性和 AI 查询支持。
## 使用方法
### 与 AI 聊天
在 Minecraft 聊天中输入 `@bot` 或 `@ai`,后跟你的消息,与 AI 交互。
**示例:**
```
@bot 建造城堡的最佳方法是什么?
```
### 命令
- **/ollamachat reload**: 重新加载插件配置和语言文件 (`ollamachat.reload`)。
- **/ollamachat toggle **: 启用/禁用指定的 AI 服务 (`ollamachat.toggle`)。
- **/aichat **: 与其他 AI 服务交互 (`ollamachat.use`)。
- **/ollamachat prompt set **: 创建一个新的提示 (`ollamachat.prompt.set`)。
- **/ollamachat prompt delete **: 删除一个提示 (`ollamachat.prompt.delete`)。
- **/ollamachat prompt list**: 列出所有提示 (`ollamachat.prompt.list`)。
- **/ollamachat prompt select **: 设置默认提示 (`ollamachat.prompt.select`)。
- **/ollamachat prompt clear**: 重置默认提示 (`ollamachat.prompt.select`)。
- **/ollamachat conversation new **: 启动一个新的对话 (`ollamachat.conversation.new`)。
- **/ollamachat conversation select **: 切换对话 (`ollamachat.conversation.select`)。
- **/ollamachat conversation delete **: 删除一个对话 (`ollamachat.conversation.delete`)。
- **/ollamachat conversation list **: 列出 AI 的对话 (`ollamachat.conversation.list`)。
- **/ollamachat suggests toggle**: 切换建议回复 (`ollamachat.suggests.toggle`)。
### 权限
| 命令 | 权限 | 描述 |
|---------|------------|-------------|
| `/ollamachat reload` | `ollamachat.reload` | 重新加载插件配置。 |
| `/ollamachat toggle ` | `ollamachat.toggle` | 切换指定的 AI 服务。 |
| `/aichat ` | `ollamachat.use` | 将消息发送到指定的 AI。 |
| `/ollamachat prompt set ` | `ollamachat.prompt.set` | 创建并保存一个新的提示。 |
| `/ollamachat prompt delete ` | `ollamachat.prompt.delete` | 删除指定的提示。 |
| `/ollamachat prompt list` | `ollamachat.prompt.list` | 列出所有提示和当前默认提示。 |
| `/ollamachat prompt select ` | `ollamachat.prompt.select` | 将一个提示设置为默认。 |
| `/ollamachat prompt clear` | `ollamachat.prompt.select` | 重置默认提示。 |
| `/ollamachat conversation new ` | `ollamachat.conversation.new` | 启动一个新的对话。 |
| `/ollamachat conversation select ` | `ollamachat.conversation.select` | 切换到现有的对话。 |
| `/ollamachat conversation delete ` | `ollamachat.conversation.delete` | 删除一个对话。 |
| `/ollamachat conversation list ` | `ollamachat.conversation.list` | 列出 AI 的所有对话。 |
| `/ollamachat suggests toggle` | `ollamachat.suggests.toggle` | 切换建议回复。 |
| `/ollamachat suggests-presets toggle` | `ollamachat.suggests-presets.toggle` | 切换预设建议回复。 |
**示例:**
```
/aichat ollama 告诉我关于红石的事情
/ollamachat prompt set creativePrompt "扮演一个友好的 Minecraft 建造者"
/ollamachat suggests toggle
```
## 安装
1. **下载**: 获取最新的 **OllamaChat**。
2. **安装**: 将 `.jar` 文件放入服务器的 `plugins` 文件夹中。
3. **配置**: 编辑 `config.yml` 以自定义 AI 设置、提示和建议。
4. **重新加载**: 使用 `/ollamachat reload` 应用更改。
## 配置
通过 `config.yml` 自定义 AI 交互:
```yaml
# Ollama API
ollama-api-url: "http://localhost:11434/api/generate"
model: "llama3"
ollama-enabled: true
# 流式设置
stream-settings:
enabled: true # 是否启用 AI 回复的流式传输
# 聊天
trigger-prefixes:
- "@bot"
- "@ai"
# 长度
max-response-length: 500 # AI 回复的最大字符长度
# 历史记录
max-history: 5 # 每个对话保留的最大聊天历史记录条目数
# 语言设置
language: "en_us" # 要使用的语言文件 (例如:en_us.json)
# 进度显示设置
progress-display:
enabled: true # 是否启用进度显示
type: "bossbar" # 显示类型 (bossbar 或 actionbar)
color: "BLUE" # BossBar 颜色 (BLUE, GREEN, RED 等)
style: "SOLID" # BossBar 样式 (SOLID, SEGMENTED_6 等)
update-interval: 1 # 进度更新频率 (秒)
# 建议回复
suggested-responses-enabled: false # 是否启用建议回复
suggested-response-models:
- "llama3" # 用于生成建议回复的 AI 模型
suggested-response-count: 3 # 生成的建议回复数量
suggested-response-prompt: "Conversation:\nUser: {prompt}\nAI: {response}\n\nBased on the above conversation, suggest {count} natural follow-up responses the user might want to say. They should be conversational in tone rather than questions. List them as:\n1. Response 1\n2. Response 2\n3. Response 3"
suggested-response-presets:
- "I see what you mean."
- "That's interesting!"
- "Tell me more about that."
suggested-response-model-toggles:
llama3: true # 对于 suggested-response-models 中的每个模型启用/禁用
suggested-response-cooldown: 10 # 建议回复之间的冷却时间 (秒)
suggested-response-presets-enabled: false # 是否启用预设建议回复
# 数据库
database:
type: sqlite # 数据库类型 (sqlite 或 mysql)
mysql:
host: localhost
port: 3306
database: ollamachat
username: root
password: ""
hikari: # MySQL 的 HikariCP 连接池设置
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 # 准备好的语句缓存的 SQL 限制
# 默认提示,添加到用户输入前 (为空则无)
default-prompt: ""
# 自定义提示
prompts:
# 示例:
# friendly: "你是一个友好的助手,用轻松愉快的语气回应。"
# formal: "你是一个专业的助手,用正式的语气回应。"
# 其他 AI 配置
other-ai-configs:
openai:
api-url: "https://api.openai.com/v1/chat/completions"
api-key: "your-openai-api-key"
model: "gpt-4"
enabled: false
messages-format: true
```
## 贡献
我们欢迎贡献!提交问题或拉取请求到我们的 [GitHub 仓库](https://github.com/mcraftbbs/Ollama-Chat)。
## 许可证
使用 MIT 许可证。请参阅 [LICENSE](https://github.com/mcraftbbs/Ollama-Chat?tab=MIT-1-ov-file)。
## 支持
如有帮助,请访问我们的 [GitHub 仓库](https://github.com/mcraftbbs/Ollama-Chat),加入我们的 [社区服务器](https://chat.sarskin.cn/invite/iHgI6LTX),或在 [Discord](https://discord.gg/VZSDJ54JrT) 上联系我们。