Compare commits

...

7 Commits

Author SHA1 Message Date
Soulter 291d65bb3e release: v3.5.5 2025-04-21 11:09:18 +08:00
Soulter bd3ad03da6 Merge pull request #1361 from AstrBotDevs/hotfix/webui-mcp
fix: 修复 MCP 页面的一些问题
2025-04-21 10:54:19 +08:00
Soulter 5fa6788357 chore: properly storing interval ID for cleanup. 2025-04-21 10:54:06 +08:00
Soulter c5c5a98ac4 🐛 fix: 修复 MCP 页面的一些问题 2025-04-21 10:51:01 +08:00
Soulter a1151143cf Merge pull request #1357 from Raven95676/hotfix/gemini-functool
fix: 修复get_func_desc_google_genai_style未正确转换函数调用的问题
2025-04-21 10:26:44 +08:00
Raven95676 f5024984f7 perf: 移除冗余判断 2025-04-21 00:55:20 +08:00
Raven95676 f4880fd90d fix: 修复get_func_desc_google_genai_style未正确转换函数调用的问题 2025-04-21 00:11:31 +08:00
6 changed files with 78 additions and 27 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
如需修改配置,请在 `data/cmd_config.json` 中修改或者在管理面板中可视化修改。
"""
VERSION = "3.5.4"
VERSION = "3.5.5"
DB_PATH = "data/data_v3.db"
# 默认配置
+57 -21
View File
@@ -435,28 +435,64 @@ class FuncCall:
tools.append(tool)
return tools
def get_func_desc_google_genai_style(self) -> Dict:
def get_func_desc_google_genai_style(self) -> dict:
"""
获得 Google GenAI API 风格的**已经激活**的工具描述
"""
# Gemini API 支持的数据类型和格式
supported_types = {"string", "number", "integer", "boolean", "array", "object", "null"}
supported_formats = {
"string": {"enum", "date-time"},
"integer": {"int32", "int64"},
"number": {"float", "double"}
}
def convert_schema(schema: dict) -> dict:
"""转换 schema 为 Gemini API 格式"""
result = {}
if "type" in schema and schema["type"] in supported_types:
result["type"] = schema["type"]
if ("format" in schema and
schema["format"] in supported_formats.get(result["type"], set())):
result["format"] = schema["format"]
else:
# 暂时指定默认为null
result["type"] = "null"
support_fields = {"title", "description", "enum", "minimum", "maximum",
"maxItems", "minItems", "nullable", "required"}
result.update({k: schema[k] for k in support_fields if k in schema})
if "properties" in schema:
properties = {}
for key, value in schema["properties"].items():
prop_value = convert_schema(value)
if "default" in prop_value:
del prop_value["default"]
properties[key] = prop_value
if properties: # 只在有非空属性时添加
result["properties"] = properties
if "items" in schema:
result["items"] = convert_schema(schema["items"])
if "anyOf" in schema:
result["anyOf"] = [convert_schema(s) for s in schema["anyOf"]]
return result
tools = [
{
"name": f.name,
"description": f.description,
**({"parameters": convert_schema(f.parameters)})
}
for f in self.func_list if f.active
]
declarations = {}
tools = []
for f in self.func_list:
if not f.active:
continue
func_declaration = {"name": f.name, "description": f.description}
# 检查并添加非空的properties参数
params = f.parameters if isinstance(f.parameters, dict) else {}
params = copy.deepcopy(params)
if params.get("properties", {}):
properties = params["properties"]
for key, value in properties.items():
if "default" in value:
del value["default"]
params["properties"] = properties
func_declaration["parameters"] = params
tools.append(func_declaration)
if tools:
declarations["function_declarations"] = tools
return declarations
+6
View File
@@ -0,0 +1,6 @@
# What's Changed
## 🐛 修复的 Bug
1. 修复 Gemini 下可能无法正常使用 Tools 的问题 @Raven95676
2. 修复 WebUI MCP 页面的一些问题 @Soulter
@@ -10,7 +10,7 @@
<v-row v-else>
<v-col v-for="(item, index) in items" :key="index" cols="12" md="6" lg="4" xl="3">
<v-card class="item-card hover-elevation" :color="getItemEnabled(item) ? '' : 'grey-lighten-4'">
<!-- <div class="item-status-indicator" :class="{'active': getItemEnabled(item)}"></div> -->
<div class="item-status-indicator" :class="{'active': getItemEnabled(item)}"></div>
<v-card-title class="d-flex justify-space-between align-center pb-1 pt-3">
<span class="text-h4 text-truncate" :title="getItemTitle(item)">{{ getItemTitle(item) }}</span>
<v-tooltip location="top">
+12 -3
View File
@@ -60,7 +60,7 @@
<v-card-text class="px-4 py-3">
<item-card-grid :items="mcpServers || []" title-field="name" enabled-field="active"
empty-icon="mdi-server-off" empty-text="暂无 MCP 服务器点击 新增服务器 添加" @toggle-enabled="platformStatusChange"
empty-icon="mdi-server-off" empty-text="暂无 MCP 服务器点击 新增服务器 添加" @toggle-enabled="updateServerStatus"
@delete="deleteServer" @edit="editServer">
<template v-slot:item-details="{ item }">
@@ -486,6 +486,7 @@ export default {
},
data() {
return {
refreshInterval: null,
activeTab: 'local', // 当前激活的标签页
mcpServers: [],
tools: [],
@@ -568,13 +569,19 @@ export default {
this.getTools();
this.fetchMarketplaceServers();
// 定期刷新本地服务器列表
setInterval(() => {
this.refreshInterval = setInterval(() => {
this.getServers();
this.getTools();
}, 5000);
},
unmounted() {
// 清除定时器 if it exists
if (this.refreshInterval) {
clearInterval(this.refreshInterval);
}
},
methods: {
openurl(url) {
window.open(url, '_blank');
@@ -724,6 +731,8 @@ export default {
},
updateServerStatus(server) {
// 切换服务器状态
server.active = !server.active;
axios.post('/api/tools/mcp/update', server)
.then(response => {
this.getServers();
+1 -1
View File
@@ -1,6 +1,6 @@
[project]
name = "AstrBot"
version = "3.5.4"
version = "3.5.5"
description = "易上手的多平台 LLM 聊天机器人及开发框架"
readme = "README.md"
requires-python = ">=3.10"