修复 bug
This commit is contained in:
parent
3de7ef68ba
commit
b33eab402d
@ -124,7 +124,7 @@ a {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.openmcp-code-block pre code {
|
.openmcp-code-block pre code {
|
||||||
background-color: none;
|
background-color: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.openmcp-code-block pre code::-webkit-scrollbar {
|
.openmcp-code-block pre code::-webkit-scrollbar {
|
||||||
|
@ -214,6 +214,7 @@ const renderMessages = computed(() => {
|
|||||||
const lastAssistantMessage = messages[messages.length - 1];
|
const lastAssistantMessage = messages[messages.length - 1];
|
||||||
if (lastAssistantMessage.role === 'assistant/tool_calls') {
|
if (lastAssistantMessage.role === 'assistant/tool_calls') {
|
||||||
lastAssistantMessage.toolResult = message.content;
|
lastAssistantMessage.toolResult = message.content;
|
||||||
|
lastAssistantMessage.extraInfo.usage = lastAssistantMessage.extraInfo.usage || message.extraInfo.usage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineComponent, defineProps, ref } from 'vue';
|
import { defineComponent, defineProps, ref, computed } from 'vue';
|
||||||
import { makeUsageStatistic } from './usage';
|
import { makeUsageStatistic } from './usage';
|
||||||
|
|
||||||
defineComponent({ name: 'message-meta' });
|
defineComponent({ name: 'message-meta' });
|
||||||
@ -42,7 +42,13 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const usageStatistic = makeUsageStatistic(props.message.extraInfo);
|
const usageStatistic = computed(() => {
|
||||||
|
return makeUsageStatistic(props.message.extraInfo);
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(props.message);
|
||||||
|
console.log(usageStatistic);
|
||||||
|
|
||||||
const showTime = ref(false);
|
const showTime = ref(false);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
<el-input
|
<el-input
|
||||||
v-if="property.type === 'string'"
|
v-if="property.type === 'string'"
|
||||||
v-model="formData[name]"
|
v-model="formData[name]"
|
||||||
|
type="text"
|
||||||
:placeholder="t('enter') + ' ' + (property.title || name)"
|
:placeholder="t('enter') + ' ' + (property.title || name)"
|
||||||
@keydown.enter.prevent="handleExecute"
|
@keydown.enter.prevent="handleExecute"
|
||||||
/>
|
/>
|
||||||
@ -115,7 +116,6 @@ const resetForm = () => {
|
|||||||
|
|
||||||
async function handleExecute() {
|
async function handleExecute() {
|
||||||
if (!currentTool.value) return;
|
if (!currentTool.value) return;
|
||||||
|
|
||||||
const toolResponse = await callTool(tabStorage.currentToolName, formData.value);
|
const toolResponse = await callTool(tabStorage.currentToolName, formData.value);
|
||||||
tabStorage.lastToolCallResponse = toolResponse;
|
tabStorage.lastToolCallResponse = toolResponse;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,10 @@ export function callTool(toolName: string, toolArgs: Record<string, any>) {
|
|||||||
command: 'tools/call',
|
command: 'tools/call',
|
||||||
data: {
|
data: {
|
||||||
toolName,
|
toolName,
|
||||||
toolArgs: JSON.parse(JSON.stringify(toolArgs))
|
toolArgs: JSON.parse(JSON.stringify(toolArgs, (key, value) => {
|
||||||
|
// 确保所有值都保持原始字符串形式
|
||||||
|
return typeof value === 'number' ? String(value) : value;
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -112,3 +112,76 @@ def generate_email(context: str) -> str:
|
|||||||
f"需求描述:{context}\n"
|
f"需求描述:{context}\n"
|
||||||
"要求:使用礼貌用语,长度不超过200字"
|
"要求:使用礼貌用语,长度不超过200字"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
from typing import NamedTuple, Optional
|
||||||
|
|
||||||
|
class CityWeather(NamedTuple):
|
||||||
|
city_name_en: str
|
||||||
|
city_name_cn: str
|
||||||
|
city_code: str
|
||||||
|
temp: str
|
||||||
|
wd: str
|
||||||
|
ws: str
|
||||||
|
sd: str
|
||||||
|
aqi: str
|
||||||
|
weather: str
|
||||||
|
|
||||||
|
def get_city_weather_by_city_name(city_code: str) -> Optional[CityWeather]:
|
||||||
|
"""根据城市名获取天气信息"""
|
||||||
|
|
||||||
|
if not city_code:
|
||||||
|
print(f"找不到{city_code}对应的城市")
|
||||||
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
|
# 构造请求URL
|
||||||
|
url = f"http://d1.weather.com.cn/sk_2d/{city_code}.html"
|
||||||
|
|
||||||
|
# 设置请求头
|
||||||
|
headers = {
|
||||||
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.0.0",
|
||||||
|
"Host": "d1.weather.com.cn",
|
||||||
|
"Referer": "http://www.weather.com.cn/"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 发送HTTP请求
|
||||||
|
response = requests.get(url, headers=headers)
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
# 解析JSON数据
|
||||||
|
# 解析JSON数据前先处理编码问题
|
||||||
|
content = response.text.encode('latin1').decode('unicode_escape')
|
||||||
|
json_start = content.find("{")
|
||||||
|
json_str = content[json_start:]
|
||||||
|
|
||||||
|
weather_data = json.loads(json_str)
|
||||||
|
|
||||||
|
# 构造返回对象
|
||||||
|
return CityWeather(
|
||||||
|
city_name_en=weather_data.get("nameen", ""),
|
||||||
|
city_name_cn=weather_data.get("cityname", "").encode('latin1').decode('utf-8'),
|
||||||
|
city_code=weather_data.get("city", ""),
|
||||||
|
temp=weather_data.get("temp", ""),
|
||||||
|
wd=weather_data.get("wd", "").encode('latin1').decode('utf-8'),
|
||||||
|
ws=weather_data.get("ws", "").encode('latin1').decode('utf-8'),
|
||||||
|
sd=weather_data.get("sd", ""),
|
||||||
|
aqi=weather_data.get("aqi", ""),
|
||||||
|
weather=weather_data.get("weather", "").encode('latin1').decode('utf-8')
|
||||||
|
)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"获取天气信息失败: {str(e)}")
|
||||||
|
return None
|
||||||
|
|
||||||
|
@mcp.tool(
|
||||||
|
name='get_weather_by_city_code',
|
||||||
|
description='根据城市天气预报的城市编码 (int),获取指定城市的天气信息'
|
||||||
|
)
|
||||||
|
def get_weather_by_code(city_code: int) -> str:
|
||||||
|
"""模拟天气查询协议,返回格式化字符串"""
|
||||||
|
city_weather = get_city_weather_by_city_name(city_code)
|
||||||
|
return str(city_weather)
|
||||||
|
@ -6,4 +6,5 @@ readme = "README.md"
|
|||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"mcp[cli]>=1.5.0",
|
"mcp[cli]>=1.5.0",
|
||||||
|
"requests>=2.32.3",
|
||||||
]
|
]
|
||||||
|
78
servers/uv.lock
generated
78
servers/uv.lock
generated
@ -34,6 +34,54 @@ wheels = [
|
|||||||
{ url = "https://files.pythonhosted.org/packages/38/fc/bce832fd4fd99766c04d1ee0eead6b0ec6486fb100ae5e74c1d91292b982/certifi-2025.1.31-py3-none-any.whl", hash = "sha256:ca78db4565a652026a4db2bcdf68f2fb589ea80d0be70e03929ed730746b84fe", size = 166393 },
|
{ url = "https://files.pythonhosted.org/packages/38/fc/bce832fd4fd99766c04d1ee0eead6b0ec6486fb100ae5e74c1d91292b982/certifi-2025.1.31-py3-none-any.whl", hash = "sha256:ca78db4565a652026a4db2bcdf68f2fb589ea80d0be70e03929ed730746b84fe", size = 166393 },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "charset-normalizer"
|
||||||
|
version = "3.4.1"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/16/b0/572805e227f01586461c80e0fd25d65a2115599cc9dad142fee4b747c357/charset_normalizer-3.4.1.tar.gz", hash = "sha256:44251f18cd68a75b56585dd00dae26183e102cd5e0f9f1466e6df5da2ed64ea3", size = 123188 }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/72/80/41ef5d5a7935d2d3a773e3eaebf0a9350542f2cab4eac59a7a4741fbbbbe/charset_normalizer-3.4.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:8bfa33f4f2672964266e940dd22a195989ba31669bd84629f05fab3ef4e2d125", size = 194995 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/7a/28/0b9fefa7b8b080ec492110af6d88aa3dea91c464b17d53474b6e9ba5d2c5/charset_normalizer-3.4.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:28bf57629c75e810b6ae989f03c0828d64d6b26a5e205535585f96093e405ed1", size = 139471 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/71/64/d24ab1a997efb06402e3fc07317e94da358e2585165930d9d59ad45fcae2/charset_normalizer-3.4.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f08ff5e948271dc7e18a35641d2f11a4cd8dfd5634f55228b691e62b37125eb3", size = 149831 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/37/ed/be39e5258e198655240db5e19e0b11379163ad7070962d6b0c87ed2c4d39/charset_normalizer-3.4.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:234ac59ea147c59ee4da87a0c0f098e9c8d169f4dc2a159ef720f1a61bbe27cd", size = 142335 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/88/83/489e9504711fa05d8dde1574996408026bdbdbd938f23be67deebb5eca92/charset_normalizer-3.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fd4ec41f914fa74ad1b8304bbc634b3de73d2a0889bd32076342a573e0779e00", size = 143862 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/c6/c7/32da20821cf387b759ad24627a9aca289d2822de929b8a41b6241767b461/charset_normalizer-3.4.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:eea6ee1db730b3483adf394ea72f808b6e18cf3cb6454b4d86e04fa8c4327a12", size = 145673 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/68/85/f4288e96039abdd5aeb5c546fa20a37b50da71b5cf01e75e87f16cd43304/charset_normalizer-3.4.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:c96836c97b1238e9c9e3fe90844c947d5afbf4f4c92762679acfe19927d81d77", size = 140211 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/28/a3/a42e70d03cbdabc18997baf4f0227c73591a08041c149e710045c281f97b/charset_normalizer-3.4.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:4d86f7aff21ee58f26dcf5ae81a9addbd914115cdebcbb2217e4f0ed8982e146", size = 148039 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/85/e4/65699e8ab3014ecbe6f5c71d1a55d810fb716bbfd74f6283d5c2aa87febf/charset_normalizer-3.4.1-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:09b5e6733cbd160dcc09589227187e242a30a49ca5cefa5a7edd3f9d19ed53fd", size = 151939 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b1/82/8e9fe624cc5374193de6860aba3ea8070f584c8565ee77c168ec13274bd2/charset_normalizer-3.4.1-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:5777ee0881f9499ed0f71cc82cf873d9a0ca8af166dfa0af8ec4e675b7df48e6", size = 149075 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/3d/7b/82865ba54c765560c8433f65e8acb9217cb839a9e32b42af4aa8e945870f/charset_normalizer-3.4.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:237bdbe6159cff53b4f24f397d43c6336c6b0b42affbe857970cefbb620911c8", size = 144340 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b5/b6/9674a4b7d4d99a0d2df9b215da766ee682718f88055751e1e5e753c82db0/charset_normalizer-3.4.1-cp311-cp311-win32.whl", hash = "sha256:8417cb1f36cc0bc7eaba8ccb0e04d55f0ee52df06df3ad55259b9a323555fc8b", size = 95205 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/1e/ab/45b180e175de4402dcf7547e4fb617283bae54ce35c27930a6f35b6bef15/charset_normalizer-3.4.1-cp311-cp311-win_amd64.whl", hash = "sha256:d7f50a1f8c450f3925cb367d011448c39239bb3eb4117c36a6d354794de4ce76", size = 102441 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/0a/9a/dd1e1cdceb841925b7798369a09279bd1cf183cef0f9ddf15a3a6502ee45/charset_normalizer-3.4.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:73d94b58ec7fecbc7366247d3b0b10a21681004153238750bb67bd9012414545", size = 196105 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d3/8c/90bfabf8c4809ecb648f39794cf2a84ff2e7d2a6cf159fe68d9a26160467/charset_normalizer-3.4.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dad3e487649f498dd991eeb901125411559b22e8d7ab25d3aeb1af367df5efd7", size = 140404 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ad/8f/e410d57c721945ea3b4f1a04b74f70ce8fa800d393d72899f0a40526401f/charset_normalizer-3.4.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c30197aa96e8eed02200a83fba2657b4c3acd0f0aa4bdc9f6c1af8e8962e0757", size = 150423 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f0/b8/e6825e25deb691ff98cf5c9072ee0605dc2acfca98af70c2d1b1bc75190d/charset_normalizer-3.4.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2369eea1ee4a7610a860d88f268eb39b95cb588acd7235e02fd5a5601773d4fa", size = 143184 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/3e/a2/513f6cbe752421f16d969e32f3583762bfd583848b763913ddab8d9bfd4f/charset_normalizer-3.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc2722592d8998c870fa4e290c2eec2c1569b87fe58618e67d38b4665dfa680d", size = 145268 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/74/94/8a5277664f27c3c438546f3eb53b33f5b19568eb7424736bdc440a88a31f/charset_normalizer-3.4.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ffc9202a29ab3920fa812879e95a9e78b2465fd10be7fcbd042899695d75e616", size = 147601 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/7c/5f/6d352c51ee763623a98e31194823518e09bfa48be2a7e8383cf691bbb3d0/charset_normalizer-3.4.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:804a4d582ba6e5b747c625bf1255e6b1507465494a40a2130978bda7b932c90b", size = 141098 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/78/d4/f5704cb629ba5ab16d1d3d741396aec6dc3ca2b67757c45b0599bb010478/charset_normalizer-3.4.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:0f55e69f030f7163dffe9fd0752b32f070566451afe180f99dbeeb81f511ad8d", size = 149520 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/c5/96/64120b1d02b81785f222b976c0fb79a35875457fa9bb40827678e54d1bc8/charset_normalizer-3.4.1-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:c4c3e6da02df6fa1410a7680bd3f63d4f710232d3139089536310d027950696a", size = 152852 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/84/c9/98e3732278a99f47d487fd3468bc60b882920cef29d1fa6ca460a1fdf4e6/charset_normalizer-3.4.1-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:5df196eb874dae23dcfb968c83d4f8fdccb333330fe1fc278ac5ceeb101003a9", size = 150488 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/13/0e/9c8d4cb99c98c1007cc11eda969ebfe837bbbd0acdb4736d228ccaabcd22/charset_normalizer-3.4.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:e358e64305fe12299a08e08978f51fc21fac060dcfcddd95453eabe5b93ed0e1", size = 146192 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b2/21/2b6b5b860781a0b49427309cb8670785aa543fb2178de875b87b9cc97746/charset_normalizer-3.4.1-cp312-cp312-win32.whl", hash = "sha256:9b23ca7ef998bc739bf6ffc077c2116917eabcc901f88da1b9856b210ef63f35", size = 95550 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/21/5b/1b390b03b1d16c7e382b561c5329f83cc06623916aab983e8ab9239c7d5c/charset_normalizer-3.4.1-cp312-cp312-win_amd64.whl", hash = "sha256:6ff8a4a60c227ad87030d76e99cd1698345d4491638dfa6673027c48b3cd395f", size = 102785 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/38/94/ce8e6f63d18049672c76d07d119304e1e2d7c6098f0841b51c666e9f44a0/charset_normalizer-3.4.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:aabfa34badd18f1da5ec1bc2715cadc8dca465868a4e73a0173466b688f29dda", size = 195698 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/24/2e/dfdd9770664aae179a96561cc6952ff08f9a8cd09a908f259a9dfa063568/charset_normalizer-3.4.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:22e14b5d70560b8dd51ec22863f370d1e595ac3d024cb8ad7d308b4cd95f8313", size = 140162 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/24/4e/f646b9093cff8fc86f2d60af2de4dc17c759de9d554f130b140ea4738ca6/charset_normalizer-3.4.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8436c508b408b82d87dc5f62496973a1805cd46727c34440b0d29d8a2f50a6c9", size = 150263 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/5e/67/2937f8d548c3ef6e2f9aab0f6e21001056f692d43282b165e7c56023e6dd/charset_normalizer-3.4.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2d074908e1aecee37a7635990b2c6d504cd4766c7bc9fc86d63f9c09af3fa11b", size = 142966 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/52/ed/b7f4f07de100bdb95c1756d3a4d17b90c1a3c53715c1a476f8738058e0fa/charset_normalizer-3.4.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:955f8851919303c92343d2f66165294848d57e9bba6cf6e3625485a70a038d11", size = 144992 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/96/2c/d49710a6dbcd3776265f4c923bb73ebe83933dfbaa841c5da850fe0fd20b/charset_normalizer-3.4.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:44ecbf16649486d4aebafeaa7ec4c9fed8b88101f4dd612dcaf65d5e815f837f", size = 147162 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b4/41/35ff1f9a6bd380303dea55e44c4933b4cc3c4850988927d4082ada230273/charset_normalizer-3.4.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:0924e81d3d5e70f8126529951dac65c1010cdf117bb75eb02dd12339b57749dd", size = 140972 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/fb/43/c6a0b685fe6910d08ba971f62cd9c3e862a85770395ba5d9cad4fede33ab/charset_normalizer-3.4.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:2967f74ad52c3b98de4c3b32e1a44e32975e008a9cd2a8cc8966d6a5218c5cb2", size = 149095 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/4c/ff/a9a504662452e2d2878512115638966e75633519ec11f25fca3d2049a94a/charset_normalizer-3.4.1-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:c75cb2a3e389853835e84a2d8fb2b81a10645b503eca9bcb98df6b5a43eb8886", size = 152668 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/6c/71/189996b6d9a4b932564701628af5cee6716733e9165af1d5e1b285c530ed/charset_normalizer-3.4.1-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:09b26ae6b1abf0d27570633b2b078a2a20419c99d66fb2823173d73f188ce601", size = 150073 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e4/93/946a86ce20790e11312c87c75ba68d5f6ad2208cfb52b2d6a2c32840d922/charset_normalizer-3.4.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:fa88b843d6e211393a37219e6a1c1df99d35e8fd90446f1118f4216e307e48cd", size = 145732 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/cd/e5/131d2fb1b0dddafc37be4f3a2fa79aa4c037368be9423061dccadfd90091/charset_normalizer-3.4.1-cp313-cp313-win32.whl", hash = "sha256:eb8178fe3dba6450a3e024e95ac49ed3400e506fd4e9e5c32d30adda88cbd407", size = 95391 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/27/f2/4f9a69cc7712b9b5ad8fdb87039fd89abba997ad5cbe690d1835d40405b0/charset_normalizer-3.4.1-cp313-cp313-win_amd64.whl", hash = "sha256:b1ac5992a838106edb89654e0aebfc24f5848ae2547d22c2c3f66454daa11971", size = 102702 },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/0e/f6/65ecc6878a89bb1c23a086ea335ad4bf21a588990c3f535a227b9eea9108/charset_normalizer-3.4.1-py3-none-any.whl", hash = "sha256:d98b1668f06378c6dbefec3b92299716b931cd4e6061f3c875a71ced1780ab85", size = 49767 },
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "click"
|
name = "click"
|
||||||
version = "8.1.8"
|
version = "8.1.8"
|
||||||
@ -254,6 +302,21 @@ wheels = [
|
|||||||
{ url = "https://files.pythonhosted.org/packages/1e/18/98a99ad95133c6a6e2005fe89faedf294a748bd5dc803008059409ac9b1e/python_dotenv-1.1.0-py3-none-any.whl", hash = "sha256:d7c01d9e2293916c18baf562d95698754b0dbbb5e74d457c45d4f6561fb9d55d", size = 20256 },
|
{ url = "https://files.pythonhosted.org/packages/1e/18/98a99ad95133c6a6e2005fe89faedf294a748bd5dc803008059409ac9b1e/python_dotenv-1.1.0-py3-none-any.whl", hash = "sha256:d7c01d9e2293916c18baf562d95698754b0dbbb5e74d457c45d4f6561fb9d55d", size = 20256 },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "requests"
|
||||||
|
version = "2.32.3"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "certifi" },
|
||||||
|
{ name = "charset-normalizer" },
|
||||||
|
{ name = "idna" },
|
||||||
|
{ name = "urllib3" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/63/70/2bf7780ad2d390a8d301ad0b550f1581eadbd9a20f896afe06353c2a2913/requests-2.32.3.tar.gz", hash = "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760", size = 131218 }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f9/9b/335f9764261e915ed497fcdeb11df5dfd6f7bf257d4a6a2a686d80da4d54/requests-2.32.3-py3-none-any.whl", hash = "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6", size = 64928 },
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rich"
|
name = "rich"
|
||||||
version = "13.9.4"
|
version = "13.9.4"
|
||||||
@ -273,10 +336,14 @@ version = "0.1.0"
|
|||||||
source = { virtual = "." }
|
source = { virtual = "." }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "mcp", extra = ["cli"] },
|
{ name = "mcp", extra = ["cli"] },
|
||||||
|
{ name = "requests" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.metadata]
|
[package.metadata]
|
||||||
requires-dist = [{ name = "mcp", extras = ["cli"], specifier = ">=1.5.0" }]
|
requires-dist = [
|
||||||
|
{ name = "mcp", extras = ["cli"], specifier = ">=1.5.0" },
|
||||||
|
{ name = "requests", specifier = ">=2.32.3" },
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shellingham"
|
name = "shellingham"
|
||||||
@ -345,6 +412,15 @@ wheels = [
|
|||||||
{ url = "https://files.pythonhosted.org/packages/e0/86/39b65d676ec5732de17b7e3c476e45bb80ec64eb50737a8dce1a4178aba1/typing_extensions-4.13.0-py3-none-any.whl", hash = "sha256:c8dd92cc0d6425a97c18fbb9d1954e5ff92c1ca881a309c45f06ebc0b79058e5", size = 45683 },
|
{ url = "https://files.pythonhosted.org/packages/e0/86/39b65d676ec5732de17b7e3c476e45bb80ec64eb50737a8dce1a4178aba1/typing_extensions-4.13.0-py3-none-any.whl", hash = "sha256:c8dd92cc0d6425a97c18fbb9d1954e5ff92c1ca881a309c45f06ebc0b79058e5", size = 45683 },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "urllib3"
|
||||||
|
version = "2.4.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/8a/78/16493d9c386d8e60e442a35feac5e00f0913c0f4b7c217c11e8ec2ff53e0/urllib3-2.4.0.tar.gz", hash = "sha256:414bc6535b787febd7567804cc015fee39daab8ad86268f1310a9250697de466", size = 390672 }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/6b/11/cc635220681e93a0183390e26485430ca2c7b5f9d33b15c74c2861cb8091/urllib3-2.4.0-py3-none-any.whl", hash = "sha256:4e16665048960a0900c702d4a66415956a584919c03361cac9f1df5c5dd7e813", size = 128680 },
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uvicorn"
|
name = "uvicorn"
|
||||||
version = "0.34.0"
|
version = "0.34.0"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"currentIndex": 2,
|
"currentIndex": 3,
|
||||||
"tabs": [
|
"tabs": [
|
||||||
{
|
{
|
||||||
"name": "资源",
|
"name": "资源",
|
||||||
@ -10,15 +10,6 @@
|
|||||||
"currentResourceName": "greeting"
|
"currentResourceName": "greeting"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "提词",
|
|
||||||
"icon": "icon-chat",
|
|
||||||
"type": "blank",
|
|
||||||
"componentIndex": 1,
|
|
||||||
"storage": {
|
|
||||||
"currentPromptName": "translate"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "交互测试",
|
"name": "交互测试",
|
||||||
"icon": "icon-robot",
|
"icon": "icon-robot",
|
||||||
@ -28,44 +19,76 @@
|
|||||||
"messages": [
|
"messages": [
|
||||||
{
|
{
|
||||||
"role": "user",
|
"role": "user",
|
||||||
"content": "你好,请问什么是",
|
"content": "请问杭州的天气是什么",
|
||||||
"extraInfo": {
|
"extraInfo": {
|
||||||
"created": 1744876735890,
|
"created": 1744881516541,
|
||||||
"serverName": "deepseek"
|
"serverName": "deepseek"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"role": "assistant",
|
"role": "assistant",
|
||||||
"content": "你好!请问你是想问什么呢?可以具体一点吗?比如:\n\n- 什么是人工智能?\n- 什么是区块链?\n- 什么是量子计算?\n- 或者其他任何你想了解的概念或问题?\n\n告诉我你的具体需求,我会尽力解答!",
|
"content": "",
|
||||||
|
"tool_calls": [
|
||||||
|
{
|
||||||
|
"id": "call_0_bbae6a23-1981-486c-a9b4-0f73166100be",
|
||||||
|
"index": 0,
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
|
"name": "weather",
|
||||||
|
"arguments": "{\"city\":\"杭州\"}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
"extraInfo": {
|
"extraInfo": {
|
||||||
"created": 1744876742266,
|
"created": 1744881520505,
|
||||||
"serverName": "deepseek",
|
"serverName": "deepseek",
|
||||||
"usage": {
|
"usage": {
|
||||||
"prompt_tokens": 453,
|
"prompt_tokens": 119,
|
||||||
"completion_tokens": 49,
|
"completion_tokens": 17,
|
||||||
"total_tokens": 502,
|
"total_tokens": 136,
|
||||||
"prompt_tokens_details": {
|
"prompt_tokens_details": {
|
||||||
"cached_tokens": 448
|
"cached_tokens": 0
|
||||||
},
|
},
|
||||||
"prompt_cache_hit_tokens": 448,
|
"prompt_cache_hit_tokens": 0,
|
||||||
"prompt_cache_miss_tokens": 5
|
"prompt_cache_miss_tokens": 119
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"role": "user",
|
"role": "tool",
|
||||||
"content": "你的名字是",
|
"tool_call_id": "call_0_bbae6a23-1981-486c-a9b4-0f73166100be",
|
||||||
|
"content": "[{\"type\":\"text\",\"text\":\"Weather in 杭州: Sunny, 25°C\"}]",
|
||||||
"extraInfo": {
|
"extraInfo": {
|
||||||
"created": 1744878380791,
|
"created": 1744881520527,
|
||||||
"serverName": "openai"
|
"serverName": "deepseek",
|
||||||
|
"usage": {
|
||||||
|
"prompt_tokens": 119,
|
||||||
|
"completion_tokens": 17,
|
||||||
|
"total_tokens": 136,
|
||||||
|
"prompt_tokens_details": {
|
||||||
|
"cached_tokens": 0
|
||||||
|
},
|
||||||
|
"prompt_cache_hit_tokens": 0,
|
||||||
|
"prompt_cache_miss_tokens": 119
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"role": "assistant",
|
"role": "assistant",
|
||||||
"content": "错误: OpenAI API error: 404 404 page not found",
|
"content": "杭州的天气是晴天,气温为25°C。",
|
||||||
"extraInfo": {
|
"extraInfo": {
|
||||||
"created": 1744878381940,
|
"created": 1744881525621,
|
||||||
"serverName": "openai"
|
"serverName": "deepseek",
|
||||||
|
"usage": {
|
||||||
|
"prompt_tokens": 162,
|
||||||
|
"completion_tokens": 12,
|
||||||
|
"total_tokens": 174,
|
||||||
|
"prompt_tokens_details": {
|
||||||
|
"cached_tokens": 128
|
||||||
|
},
|
||||||
|
"prompt_cache_hit_tokens": 128,
|
||||||
|
"prompt_cache_miss_tokens": 34
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -91,6 +114,138 @@
|
|||||||
"name": "capitalize",
|
"name": "capitalize",
|
||||||
"description": "将字符串首字母大写",
|
"description": "将字符串首字母大写",
|
||||||
"enabled": true
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "get_weather_by_city_code",
|
||||||
|
"description": "根据城市天气预报的城市编码 (int),获取指定城市的天气信息",
|
||||||
|
"enabled": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"enableWebSearch": false,
|
||||||
|
"temperature": 0.7,
|
||||||
|
"contextLength": 10,
|
||||||
|
"systemPrompt": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "工具",
|
||||||
|
"icon": "icon-tool",
|
||||||
|
"type": "blank",
|
||||||
|
"componentIndex": 2,
|
||||||
|
"storage": {
|
||||||
|
"currentToolName": "add"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "交互测试",
|
||||||
|
"icon": "icon-robot",
|
||||||
|
"type": "blank",
|
||||||
|
"componentIndex": 3,
|
||||||
|
"storage": {
|
||||||
|
"messages": [
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": "请问杭州的温度是多少?",
|
||||||
|
"extraInfo": {
|
||||||
|
"created": 1744891124259,
|
||||||
|
"serverName": "deepseek"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"role": "assistant",
|
||||||
|
"content": "",
|
||||||
|
"tool_calls": [
|
||||||
|
{
|
||||||
|
"id": "call_0_b289e7fb-386e-4071-8749-e02ff9506f74",
|
||||||
|
"index": 0,
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
|
"name": "get_weather_by_city_code",
|
||||||
|
"arguments": "{\"city_code\":101210101}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"extraInfo": {
|
||||||
|
"created": 1744891130497,
|
||||||
|
"serverName": "deepseek",
|
||||||
|
"usage": {
|
||||||
|
"prompt_tokens": 144,
|
||||||
|
"completion_tokens": 27,
|
||||||
|
"total_tokens": 171,
|
||||||
|
"prompt_tokens_details": {
|
||||||
|
"cached_tokens": 128
|
||||||
|
},
|
||||||
|
"prompt_cache_hit_tokens": 128,
|
||||||
|
"prompt_cache_miss_tokens": 16
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"role": "tool",
|
||||||
|
"tool_call_id": "call_0_b289e7fb-386e-4071-8749-e02ff9506f74",
|
||||||
|
"content": "[{\"type\":\"text\",\"text\":\"CityWeather(city_name_en='hangzhou', city_name_cn='杭州', city_code='101210101', temp='19.2', wd='', ws='', sd='76%', aqi='62', weather='晴')\"}]",
|
||||||
|
"extraInfo": {
|
||||||
|
"created": 1744891130615,
|
||||||
|
"serverName": "deepseek",
|
||||||
|
"usage": {
|
||||||
|
"prompt_tokens": 144,
|
||||||
|
"completion_tokens": 27,
|
||||||
|
"total_tokens": 171,
|
||||||
|
"prompt_tokens_details": {
|
||||||
|
"cached_tokens": 128
|
||||||
|
},
|
||||||
|
"prompt_cache_hit_tokens": 128,
|
||||||
|
"prompt_cache_miss_tokens": 16
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"role": "assistant",
|
||||||
|
"content": "杭州当前的温度是19.2℃,天气为晴,空气质量指数(AQI)为62,湿度为76%。",
|
||||||
|
"extraInfo": {
|
||||||
|
"created": 1744891135309,
|
||||||
|
"serverName": "deepseek",
|
||||||
|
"usage": {
|
||||||
|
"prompt_tokens": 236,
|
||||||
|
"completion_tokens": 25,
|
||||||
|
"total_tokens": 261,
|
||||||
|
"prompt_tokens_details": {
|
||||||
|
"cached_tokens": 192
|
||||||
|
},
|
||||||
|
"prompt_cache_hit_tokens": 192,
|
||||||
|
"prompt_cache_miss_tokens": 44
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"modelIndex": 0,
|
||||||
|
"enableTools": [
|
||||||
|
{
|
||||||
|
"name": "add",
|
||||||
|
"description": "对两个数字进行实数域的加法",
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "multiply",
|
||||||
|
"description": "对两个数字进行实数域的乘法运算",
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is_even",
|
||||||
|
"description": "判断一个整数是否为偶数",
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "capitalize",
|
||||||
|
"description": "将字符串首字母大写",
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "get_weather_by_city_code",
|
||||||
|
"description": "根据城市天气预报的城市编码 (int),获取指定城市的天气信息",
|
||||||
|
"enabled": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"enableWebSearch": false,
|
"enableWebSearch": false,
|
||||||
|
@ -55,6 +55,8 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
console.log('current file' + uri.fsPath);
|
console.log('current file' + uri.fsPath);
|
||||||
console.log(`relativePath: ${relativePath}`);
|
console.log(`relativePath: ${relativePath}`);
|
||||||
|
|
||||||
|
// 根据 relativePath 先去 setting 中进行选择
|
||||||
|
|
||||||
// 设置HTML内容
|
// 设置HTML内容
|
||||||
const html = getWebviewContent(context, panel);
|
const html = getWebviewContent(context, panel);
|
||||||
panel.webview.html = html || '';
|
panel.webview.html = html || '';
|
||||||
@ -68,7 +70,7 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
// 拦截消息,注入额外信息
|
// 拦截消息,注入额外信息
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case 'vscode/launch-command':
|
case 'vscode/launch-command':
|
||||||
const commandString = 'uv run mcp run ' + relativePath;
|
const commandString = 'mcp run ' + relativePath;
|
||||||
const launchResult = {
|
const launchResult = {
|
||||||
code: 200,
|
code: 200,
|
||||||
msg: {
|
msg: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user