Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 291d65bb3e | |||
| bd3ad03da6 | |||
| 5fa6788357 | |||
| c5c5a98ac4 | |||
| a1151143cf | |||
| f5024984f7 | |||
| f4880fd90d |
@@ -2,7 +2,7 @@
|
||||
如需修改配置,请在 `data/cmd_config.json` 中修改或者在管理面板中可视化修改。
|
||||
"""
|
||||
|
||||
VERSION = "3.5.4"
|
||||
VERSION = "3.5.5"
|
||||
DB_PATH = "data/data_v3.db"
|
||||
|
||||
# 默认配置
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "AstrBot"
|
||||
version = "3.5.4"
|
||||
version = "3.5.5"
|
||||
description = "易上手的多平台 LLM 聊天机器人及开发框架"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
|
||||
Reference in New Issue
Block a user