Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Docs/Bot_Commands_User_Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@
* **权限**: 普通管理员或全局管理员。
* **相关指令**: `选择生图模型` 显示可用生图模型并通过编号选择,`生图模型` / `查看生图模型` 查看当前生图模型,`清除生图模型` 恢复使用全局默认。

* **设置当前聊天使用的音乐生成模型**
* **指令格式**: `设置音乐模型 <模型名称>`
* **功能**: 为当前聊天(群组或私聊)设置 `generate_music` 默认使用的 MiniMax 音乐生成模型;未设置时使用全局默认音乐模型。
* **示例**: `设置音乐模型 music-2.6`,或 `设置音乐模型 music-2.6-free`
* **权限**: 普通管理员或全局管理员。
* **相关指令**: `选择音乐模型` 显示可用音乐模型并通过编号选择,`音乐模型` / `查看音乐模型` 查看当前音乐模型,`清除音乐模型` 恢复使用全局默认。

### 2. 全局管理员指令

以下指令仅限机器人全局管理员(在 `Env.cs` 中配置的 `AdminId`)使用。
Expand Down Expand Up @@ -207,6 +214,16 @@
7. 管理员发送: `gpt-image-2`,或 MiniMax 的 `image-01` / `image-01-live`
8. 机器人回复: `默认生图模型已设置为: gpt-image-2...`
* **说明**: 生图工具使用内置工具 `generate_image`,默认优先使用当前群通过 `设置生图模型 <模型名>` 或 `选择生图模型` 配置的模型;群内未配置时使用全局默认 `gpt-image-2`。OpenAI-compatible 模型调用 `/v1/images/generations`;MiniMax `image-01` / `image-01-live` 调用 `/v1/image_generation`。API 地址和 API Key 不在工具参数中填写,而是来自该模型关联的 LLM 渠道;因此可通过 `新建渠道` / `编辑渠道` 自定义 API 地址,例如 `https://api.openai.com/v1`、`https://api.minimaxi.com` 或自建兼容网关。
* **音乐工具开关与模型设置:**
1. 管理员发送: `开启音乐工具`
2. 机器人回复: `音乐工具已开启...`
3. 管理员发送: `关闭音乐工具`
4. 机器人回复: `音乐工具已关闭,并会从 LLM 工具提示词中隐藏。`
5. 管理员发送: `设置默认音乐模型`
6. 机器人回复: `请输入没有群级配置时使用的默认音乐模型名称...`
7. 管理员发送: `music-2.6`,或 MiniMax 的 `music-2.6-free` / `music-cover` / `music-cover-free`
8. 机器人回复: `默认音乐模型已设置为: music-2.6...`
* **说明**: 音乐生成工具使用内置工具 `generate_music`,默认优先使用当前群通过 `设置音乐模型 <模型名>` 或 `选择音乐模型` 配置的模型;群内未配置时使用全局默认 `music-2.6`。MiniMax 音乐接口调用 `/v1/music_generation`,生成完成后会保存音频文件并默认自动回复到当前聊天。API 地址和 API Key 来自该模型关联的 LLM 渠道;建议渠道类型选择 `MiniMax`,网关例如 `https://api.minimaxi.com`。
* **指令**: `新建渠道`
* **功能**: 开始创建新的LLM(大语言模型)API渠道的流程,包括名称、网关地址、API类型 (OpenAI/Ollama)、API Key、最大并行数和优先级。
* **指令**: `编辑渠道`
Expand All @@ -229,6 +246,10 @@
* **功能**: 开启、关闭或查看 LLM 生图内置工具。关闭后工具不会注入到 LLM 工具提示词或 native tool definitions 中。
* **指令**: `设置默认生图模型`
* **功能**: 设置没有群级生图模型配置时使用的全局默认模型,内置默认 `gpt-image-2`;MiniMax 可用 `image-01` / `image-01-live`。需要将该模型通过 `添加模型` 关联到一个带自定义 API 地址的 LLM 渠道。
* **指令**: `开启音乐工具` / `关闭音乐工具` / `音乐工具状态`
* **功能**: 开启、关闭或查看 LLM 音乐生成内置工具。关闭后工具不会注入到 LLM 工具提示词或 native tool definitions 中。
* **指令**: `设置默认音乐模型`
* **功能**: 设置没有群级音乐模型配置时使用的全局默认模型,内置默认 `music-2.6`;MiniMax 可用 `music-2.6` / `music-2.6-free` / `music-cover` / `music-cover-free`。需要将该模型通过 `添加模型` 关联到一个 MiniMax 渠道。

* **MCP服务器管理** (在群组中由全局管理员发送,会触发交互式配置流程)
* **说明**: 以下指令用于管理MCP (Model Context Protocol) 服务器。它们会启动一个多步骤的对话流程(状态机),机器人会依次询问配置所需的各项信息。请按照机器人的提示逐步回复。
Expand Down
2 changes: 2 additions & 0 deletions Docs/Existing_Codebase_Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@
* **`SendPhotoToolService.cs`**: 发送图片工具(send_photo_base64, send_photo_file)。
* **`SendVideoToolService.cs`**: 发送视频工具(send_video_file)。
* **`SendDocumentToolService.cs`**: 发送文件工具(send_document_file)。
* **`ImageGenerationToolService.cs`**: 图片生成工具(generate_image),支持 OpenAI-compatible 和 MiniMax 图片接口。
* **`MusicGenerationToolService.cs`**: MiniMax 音乐生成工具(generate_music),生成完成后保存音频并可自动回复到当前聊天。

### 17. `Sink/`

Expand Down
19 changes: 19 additions & 0 deletions Docs/README_MCP.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,25 @@ API 地址和 API Key 来自该模型关联的 LLM 渠道,因此可通过 `新

MiniMax 不支持选择输出文件格式;`output_format` 仅用于 OpenAI-compatible 图片接口。MiniMax 的 URL 响应会按实际 Content-Type 或 URL 扩展名保存,base64 响应默认按 PNG 保存。

### 2.2.2 音乐生成工具

| 工具名称 | 描述 | 参数 |
|---------|------|------|
| `generate_music` | 通过配置的 MiniMax 音乐 API 生成歌曲或翻唱,默认使用当前群的音乐模型;未配置时使用全局默认 `music-2.6`;接口走 `/v1/music_generation`;音频保存到本地并默认自动回复到当前聊天 | `prompt?`, `lyrics?`, `model?`, `isInstrumental?`, `lyricsOptimizer?`, `outputFormat?`, `sampleRate?`, `bitrate?`, `format?`, `aigcWatermark?`, `audioUrl?`, `audioBase64?`, `coverFeatureId?`, `sendToChat?`, `caption?`, `title?`, `performer?`, `replyToMessageId?`, `timeoutSeconds?` |

管理员命令:
- `开启音乐工具`:允许 `generate_music` 注入到 LLM 工具提示词和 native tool definitions。
- `关闭音乐工具`:隐藏 `generate_music`,关闭后 LLM 不会看到该工具。
- `音乐工具状态`:查看开关状态和默认音乐模型。
- `设置默认音乐模型`:设置无群级配置时使用的全局默认音乐模型,内置默认 `music-2.6`;MiniMax 可设置为 `music-2.6`、`music-2.6-free`、`music-cover` 或 `music-cover-free`。
- 群内普通管理员可发送 `选择音乐模型` 从已识别的音乐生成模型里按编号选择,也可用 `设置音乐模型 <模型名>` 直接设置当前群的音乐模型,或用 `清除音乐模型` 恢复使用全局默认。

音乐模型识别优先使用模型能力 `music_generation` / `text_to_music`;没有能力数据时,会按 MiniMax `music-2.6` / `music-2.6-free` / `music-cover` / `music-cover-free` 兜底识别。

API 地址和 API Key 来自该模型关联的 LLM 渠道,因此可通过 `新建渠道` / `编辑渠道` 自定义网关地址,例如 `https://api.minimaxi.com`。配置 MiniMax 时,渠道类型建议选择 `MiniMax`,再通过 `添加模型` 关联音乐模型。

`music-2.6` / `music-2.6-free` 支持文生音乐和纯音乐;非纯音乐默认需要传 `lyrics`,除非 `lyricsOptimizer` 为 true。`music-cover` / `music-cover-free` 支持基于 `audioUrl`、`audioBase64` 或预处理得到的 `coverFeatureId` 生成翻唱。

Comment thread
coderabbitai[bot] marked this conversation as resolved.
**文件大小限制**:
- 本地 Bot API(内置或外部): 最大 2GB
- 云端API: 最大 50MB
Expand Down
10 changes: 8 additions & 2 deletions Docs/README_ModelCapabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

#### ModelWithCapabilities.cs
- 数据传输对象,包含模型信息和能力信息
- 提供便捷的属性访问(如 SupportsToolCalling、SupportsVision、SupportsEmbedding)
- 提供便捷的属性访问(如 SupportsToolCalling、SupportsVision、SupportsEmbedding、SupportsImageGeneration、SupportsMusicGeneration
- 包含能力设置和获取的辅助方法

### 2. 数据库更改
Expand Down Expand Up @@ -112,6 +112,8 @@ OpenRouter提供的详细能力信息包括:
- 自动检测`tools`、`function_calling`支持
- 检测`stream`、`response_format`等参数
- 记录完整的支持参数列表
- 图片生成模型可通过 `image_generation` / `text_to_image` 能力或常见模型名识别
- 音乐生成模型可通过 `music_generation` / `text_to_music` 能力或 MiniMax `music-2.6` / `music-cover` 系列模型名识别

4. **定价信息**
- prompt价格
Expand Down Expand Up @@ -162,6 +164,10 @@ OpenRouter提供的详细能力信息包括:

// 查询支持视觉的模型
var visionModels = await modelCapabilityService.GetModelsByCapability("vision", true);

// 查询图片/音乐生成模型
var imageModels = await modelCapabilityService.GetImageGenerationModels();
var musicModels = await modelCapabilityService.GetMusicGenerationModels();
```

## 技术特点
Expand Down Expand Up @@ -191,4 +197,4 @@ OpenRouter提供的详细能力信息包括:
✅ **编译成功** - 所有功能已实现并通过编译
⚠️ **文件锁定** - 由于程序正在运行,无法覆盖exe文件(这是正常现象)

OpenRouter适配现已完成,可以正常获取模型列表和详细的能力信息!
OpenRouter适配现已完成,可以正常获取模型列表和详细的能力信息!
17 changes: 17 additions & 0 deletions TelegramSearchBot.Common/Model/AI/ModelWithCapabilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public class ModelWithCapabilities {
/// </summary>
public bool SupportsImageGeneration => GetCapabilityBool("image_generation") || GetCapabilityBool("text_to_image") || IsKnownImageGenerationModelName(ModelName);

/// <summary>
/// 是否是音乐生成模型
/// </summary>
public bool SupportsMusicGeneration => GetCapabilityBool("music_generation") || GetCapabilityBool("text_to_music") || IsKnownMusicGenerationModelName(ModelName);

/// <summary>
/// 获取布尔类型的能力值
/// </summary>
Expand Down Expand Up @@ -95,5 +100,17 @@ public static bool IsKnownImageGenerationModelName(string modelName) {
lowerName.Contains("stable-diffusion") ||
lowerName.Contains("sdxl");
}

public static bool IsKnownMusicGenerationModelName(string modelName) {
if (string.IsNullOrWhiteSpace(modelName)) {
return false;
}

var lowerName = modelName.Trim().ToLowerInvariant();
return lowerName.Equals("music-2.6") ||
lowerName.Equals("music-2.6-free") ||
lowerName.Equals("music-cover") ||
lowerName.Equals("music-cover-free");
}
}
}
32 changes: 32 additions & 0 deletions TelegramSearchBot.Common/Model/Tools/MusicGenerationResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Collections.Generic;

namespace TelegramSearchBot.Model.Tools {
public class MusicGenerationResult {
public bool Success { get; set; }
public string Error { get; set; } = null!;
public string Model { get; set; } = null!;
public int? ChannelId { get; set; }
public string ChannelName { get; set; } = null!;
public string Endpoint { get; set; } = null!;
public GeneratedMusicInfo Music { get; set; } = null!;
public SendAudioResult SentAudio { get; set; } = null!;
}

public class GeneratedMusicInfo {
public string FilePath { get; set; } = null!;
public long FileSizeBytes { get; set; }
public string ContentType { get; set; } = null!;
public int? DurationMilliseconds { get; set; }
public int? SampleRate { get; set; }
public int? Channels { get; set; }
public int? Bitrate { get; set; }
}

public class SendAudioResult {
public bool Success { get; set; }
public int? MessageId { get; set; }
public long ChatId { get; set; }
public string Error { get; set; } = null!;
public bool SentAsDocument { get; set; }
}
}
Loading
Loading