create_react_agent + MCP tools

文章目录

    • MCP tools 调用
    • 结果输出
      • MCP Tool 内容
      • 成功返回
      • 失败返回


普通工具调用

https://blog.csdn.net/2401_89025022/article/details/148629902


MCP tools 调用

import time 
import asyncio 
import json 
from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
from langchain_mcp_adapters.client import MultiServerMCPClientbase_url = 'https://ark.cn-beijing.volces.com/api/v3'
model = "ep-20250304190324-vpgqc"
api_key = 'ec8607...0d6bec80e' llm = ChatOpenAI(model=model, base_url=base_url, api_key=api_key, temperature=0.1)  def create_agent(agent_name: str, tools: list, prompt: str):"""Factory function to create agents with consistent configuration."""return create_react_agent(name=agent_name, model=llm, tools=tools, prompt=prompt )async def create_agent_with_tool(): mcp_servers = {  'amap-amap-sse': {'transport': 'sse', 'url': 'https://mcp.amap.com/sse?key=1d01eb1e...020d600da'}}loaded_tools = []tool_names = []client = MultiServerMCPClient(mcp_servers) print('-- mcp client', client) tools = await client.get_tools()   for tool in tools: print('\n-- tool name : ', tool.name) print(tool.description)   loaded_tools.append(tool) tool_names.append(tool.name )# print('-- loaded_tools : ', loaded_tools, len(loaded_tools) ) print('-- loaded_tools : ', len(loaded_tools), ', '.join(tool_names) )   print('\n\n')#print(loaded_tools)#print('\n\n')#print(loaded_tools[1])  # print(vars(tool)) agent = create_agent(agent_name='test1', tools=loaded_tools, prompt='' ) t0 = time.time()q = '请帮我规划 深圳西丽到石厦的骑行路线' # q = '深圳石厦地铁站的经纬度坐标是多少?'resp2 = agent.invoke({"messages": [{"role": "user", "content": q }]})print('\n\n')  # print(resp2 ) # print('\n', json.dumps(resp2, ensure_ascii=False, indent=4))   # print('-- cost : ', time.time() - t0 ) if __name__ == '__main__':asyncio.run(create_agent_with_tool())      

结果输出

MCP Tool 内容

[StructuredTool(name = 'maps_direction_bicycling', description = '骑行路径规划用于规划骑行通勤方案,规划时会考虑天桥、单行线、封路等情况。最大支持 500km 的骑行路线规划', args_schema = {'type': 'object',  'required': ['origin', 'destination'],'properties': {'origin': {'type': 'string','description': '出发点经纬度,坐标格式为:经度,纬度'},'destination': {'type': 'string','description': '目的地经纬度,坐标格式为:经度,纬度'}}}, response_format = 'content_and_artifact',coroutine = < function convert_mcp_tool_to_langchain_tool. < locals > .call_tool at 0x110d5cfe0 > ),...
]

成功返回

{'messages': [HumanMessage(  // 1content = '请帮我规划 深圳西丽到石厦的骑行路线',additional_kwargs = {},response_metadata = {},id = '1efec420-47f9-4a0a-8d4a-e47eb905024d'),AIMessage(  // 2name = 'test1',id = 'run--ef361011-bd51-4717-9d71-8628d7654f6a-0',content = '',additional_kwargs = {'tool_calls': [{'id': 'call_z2062i697h3tv5bjn6ol66zf','function': {'arguments': ' {"address": "深圳西丽", "city": "深圳"}','name': 'maps_geo'},'type': 'function'}],'refusal': None},response_metadata = { 'model_name': 'doubao-1-5-pro-32k-250115','system_fingerprint': None,'id': '0217498713874923dc958bd234ae18541b7d6d3762c899f8ee541','service_tier': 'default','finish_reason': 'tool_calls','logprobs': None,'token_usage': {'completion_tokens': 33,'prompt_tokens': 1683,'total_tokens': 1716,'completion_tokens_details': {'accepted_prediction_tokens': None,'audio_tokens': None,'reasoning_tokens': 0,'rejected_prediction_tokens': None},'prompt_tokens_details': {'audio_tokens': None,'cached_tokens': 0}},},tool_calls = [{'name': 'maps_geo','args': {'address': '深圳西丽','city': '深圳'},'id': 'call_z2062i697h3tv5bjn6ol66zf','type': 'tool_call'}],usage_metadata = {'input_tokens': 1683,'output_tokens': 33,'total_tokens': 1716,'input_token_details': {'cache_read': 0},'output_token_details': {'reasoning': 0}}),ToolMessage(  // 3content = "Error: NotImplementedError('StructuredTool does not support sync invocation.')\n Please fix your mistakes.",name = 'maps_geo',id = '115db843-1871-4dc0-be8e-2ff3aee90b0f',tool_call_id = 'call_z2062i697h3tv5bjn6ol66zf',status = 'error'),AIMessage(content = '',additional_kwargs = {'tool_calls': [{'id': 'call_qp5ygrgzgyt2e89zwrlv9cjz','function': {'arguments': ' {\n        "address": "深圳西丽", \n        "city": "深圳"\n    }','name': 'maps_geo'},'type': 'function'}],'refusal': None},response_metadata = {'token_usage': {'completion_tokens': 47,'prompt_tokens': 1761,'total_tokens': 1808,'completion_tokens_details': {'accepted_prediction_tokens': None,'audio_tokens': None,'reasoning_tokens': 0,'rejected_prediction_tokens': None},'prompt_tokens_details': {'audio_tokens': None,'cached_tokens': 0}},'model_name': 'doubao-1-5-pro-32k-250115','system_fingerprint': None,'id': '0217498713888753dc958bd234ae18541b7d6d3762c899fd997f5','service_tier': 'default','finish_reason': 'tool_calls','logprobs': None},name = 'test1',id = 'run--fed37332-8e66-4d4f-ac53-b0f497f47042-0',tool_calls = [{'name': 'maps_geo','args': {'address': '深圳西丽','city': '深圳'},'id': 'call_qp5ygrgzgyt2e89zwrlv9cjz','type': 'tool_call'}],usage_metadata = {'input_tokens': 1761,'output_tokens': 47,'total_tokens': 1808,'input_token_details': {'cache_read': 0},'output_token_details': {'reasoning': 0}}),ToolMessage(  // 4content = "Error: NotImplementedError('StructuredTool does not support sync invocation.')\n Please fix your mistakes.",name = 'maps_geo',id = '693fe120-0eec-4935-bb8c-924a567adb29',tool_call_id = 'call_qp5ygrgzgyt2e89zwrlv9cjz',status = 'error'),AIMessage(content = '',additional_kwargs = {'tool_calls': [{'id': 'call_es029zxcwliwliegsojeemrw','function': {'arguments': ' {\n        "address": "深圳西丽", \n        "city": "深圳"\n    }','name': 'maps_geo'},'type': 'function'}],'refusal': None},response_metadata = {'token_usage': {'completion_tokens': 50,'prompt_tokens': 1839,'total_tokens': 1889,'completion_tokens_details': {'accepted_prediction_tokens': None,'audio_tokens': None,'reasoning_tokens': 0,'rejected_prediction_tokens': None},'prompt_tokens_details': {'audio_tokens': None,'cached_tokens': 0}},'model_name': 'doubao-1-5-pro-32k-250115','system_fingerprint': None,'id': '0217498713924413dc958bd234ae18541b7d6d3762c899fdb95d0','service_tier': 'default','finish_reason': 'tool_calls','logprobs': None},name = 'test1',id = 'run--306aade0-58e7-416a-bb08-c4b1f6bd1dfb-0',tool_calls = [{'name': 'maps_geo','args': {'address': '深圳西丽','city': '深圳'},'id': 'call_es029zxcwliwliegsojeemrw','type': 'tool_call'}],usage_metadata = {'input_tokens': 1839,'output_tokens': 50,'total_tokens': 1889,'input_token_details': {'cache_read': 0},'output_token_details': {'reasoning': 0}}),ToolMessage(  // 5content = "Error: NotImplementedError('StructuredTool does not support sync invocation.')\n Please fix your mistakes.",name = 'maps_geo',id = '8f9de025-20cf-4913-ada8-5a1ea836f91c',tool_call_id = 'call_es029zxcwliwliegsojeemrw',status = 'error'),AIMessage(content = '',additional_kwargs = {'tool_calls': [{'id': 'call_6iw2766xj1zybxz7sahxpkox','function': {'arguments': ' {\n        "address": "深圳西丽", \n        "city": "深圳"\n    }','name': 'maps_geo'},'type': 'function'}],'refusal': None},response_metadata = {'token_usage': {'completion_tokens': 50,'prompt_tokens': 1917,'total_tokens': 1967,'completion_tokens_details': {'accepted_prediction_tokens': None,'audio_tokens': None,'reasoning_tokens': 0,'rejected_prediction_tokens': None},'prompt_tokens_details': {'audio_tokens': None,'cached_tokens': 0}},'model_name': 'doubao-1-5-pro-32k-250115','system_fingerprint': None,'id': '0217498713948953dc958bd234ae18541b7d6d3762c899f839b10','service_tier': 'default','finish_reason': 'tool_calls','logprobs': None},name = 'test1',id = 'run--0dd6a935-29c3-43fa-9c2d-d0ff78e57a1d-0',tool_calls = [{'name': 'maps_geo','args': {'address': '深圳西丽','city': '深圳'},'id': 'call_6iw2766xj1zybxz7sahxpkox','type': 'tool_call'}],usage_metadata = {'input_tokens': 1917,'output_tokens': 50,'total_tokens': 1967,'input_token_details': {'cache_read': 0},'output_token_details': {'reasoning': 0}}),ToolMessage(  // 6content = "Error: NotImplementedError('StructuredTool does not support sync invocation.')\n Please fix your mistakes.",name = 'maps_geo',id = '30a71f82-e6d1-4d8f-80c2-b4284d1234bd',tool_call_id = 'call_6iw2766xj1zybxz7sahxpkox',status = 'error'),AIMessage(content = '',additional_kwargs = {'tool_calls': [{'id': 'call_dum8xqpr869ogf9qoyxqaiy5','function': {'arguments': ' {"address": "深圳西丽", "city": "深圳"}','name': 'maps_geo'},'type': 'function'}],'refusal': None},response_metadata = {'token_usage': {'completion_tokens': 33,'prompt_tokens': 1995,'total_tokens': 2028,'completion_tokens_details': {'accepted_prediction_tokens': None,'audio_tokens': None,'reasoning_tokens': 0,'rejected_prediction_tokens': None},'prompt_tokens_details': {'audio_tokens': None,'cached_tokens': 0}},'model_name': 'doubao-1-5-pro-32k-250115','system_fingerprint': None,'id': '0217498713975123dc958bd234ae18541b7d6d3762c899f5b1dad','service_tier': 'default','finish_reason': 'tool_calls','logprobs': None},name = 'test1',id = 'run--e37f3f82-8fbf-4a5e-9c4a-097e0083f9fa-0',tool_calls = [{'name': 'maps_geo','args': {'address': '深圳西丽','city': '深圳'},'id': 'call_dum8xqpr869ogf9qoyxqaiy5','type': 'tool_call'}],usage_metadata = {'input_tokens': 1995,'output_tokens': 33,'total_tokens': 2028,'input_token_details': {'cache_read': 0},'output_token_details': {'reasoning': 0}}),ToolMessage(  // 7content = "Error: NotImplementedError('StructuredTool does not support sync invocation.')\n Please fix your mistakes.",name = 'maps_geo',id = '75a39bda-1cfa-42f3-9b9f-ddde1dbaf51b',tool_call_id = 'call_dum8xqpr869ogf9qoyxqaiy5',status = 'error'),AIMessage(content = '',additional_kwargs = {'tool_calls': [{'id': 'call_64xccrpjh2gyezwsidsfx65l','function': {'arguments': ' {"address": "深圳西丽", "city": "深圳"}','name': 'maps_geo'},'type': 'function'}],'refusal': None},response_metadata = {'token_usage': {'completion_tokens': 33,'prompt_tokens': 2073,'total_tokens': 2106,'completion_tokens_details': {'accepted_prediction_tokens': None,'audio_tokens': None,'reasoning_tokens': 0,'rejected_prediction_tokens': None},'prompt_tokens_details': {'audio_tokens': None,'cached_tokens': 0}},'model_name': 'doubao-1-5-pro-32k-250115','system_fingerprint': None,'id': '0217498713992753dc958bd234ae18541b7d6d3762c899f1f63cd','service_tier': 'default','finish_reason': 'tool_calls','logprobs': None},name = 'test1',id = 'run--10d44363-46aa-4239-ae58-48963459e9a7-0',tool_calls = [{'name': 'maps_geo','args': {'address': '深圳西丽','city': '深圳'},'id': 'call_64xccrpjh2gyezwsidsfx65l','type': 'tool_call'}],usage_metadata = {'input_tokens': 2073,'output_tokens': 33,'total_tokens': 2106,'input_token_details': {'cache_read': 0},'output_token_details': {'reasoning': 0}}),ToolMessage(  // 8content = "Error: NotImplementedError('StructuredTool does not support sync invocation.')\n Please fix your mistakes.",name = 'maps_geo',id = 'e89bd532-79e5-4ee8-ad5b-30292ffcc591',tool_call_id = 'call_64xccrpjh2gyezwsidsfx65l',status = 'error'),AIMessage(content = '为了规划从深圳西丽到石厦的骑行路线,我将先把这两个地点转换为经纬度,然后进行骑行路径规划。\n',additional_kwargs = {'tool_calls': [{'id': 'call_7dknl1cxy93vckagzxvgcyh3','function': {'arguments': ' {"address": "深圳西丽", "city": "深圳"}','name': 'maps_geo'},'type': 'function'}],'refusal': None},response_metadata = {'token_usage': {'completion_tokens': 66,'prompt_tokens': 2151,'total_tokens': 2217,'completion_tokens_details': {'accepted_prediction_tokens': None,'audio_tokens': None,'reasoning_tokens': 0,'rejected_prediction_tokens': None},'prompt_tokens_details': {'audio_tokens': None,'cached_tokens': 0}},'model_name': 'doubao-1-5-pro-32k-250115','system_fingerprint': None,'id': '0217498714015093dc958bd234ae18541b7d6d3762c899f6fc981','service_tier': 'default','finish_reason': 'tool_calls','logprobs': None},name = 'test1',id = 'run--acc8772a-f244-4e38-8a2d-85bd366d04de-0',tool_calls = [{'name': 'maps_geo','args': {'address': '深圳西丽','city': '深圳'},'id': 'call_7dknl1cxy93vckagzxvgcyh3','type': 'tool_call'}],usage_metadata = {'input_tokens': 2151,'output_tokens': 66,'total_tokens': 2217,'input_token_details': {'cache_read': 0},'output_token_details': {'reasoning': 0}}),ToolMessage(  // 9 content = "Error: NotImplementedError('StructuredTool does not support sync invocation.')\n Please fix your mistakes.",name = 'maps_geo',id = '55c5e117-957c-4526-95ba-1d2f2ea61cfd',tool_call_id = 'call_7dknl1cxy93vckagzxvgcyh3',status = 'error'),AIMessage(content = '由于当前环境无法直接调用工具获取结果,我将为你梳理后续的调用步骤。\n\n在成功获取到深圳西丽的经纬度后,接下来需要获取石厦的经纬度,调用如下:\n',additional_kwargs = {'tool_calls': [{'id': 'call_5oq6qi1g26okge2z6l1gco4k','function': {'arguments': ' {"address": "石厦", "city": "深圳"}','name': 'maps_geo'},'type': 'function'}],'refusal': None},response_metadata = {'token_usage': {'completion_tokens': 80,'prompt_tokens': 2262,'total_tokens': 2342,'completion_tokens_details': {'accepted_prediction_tokens': None,'audio_tokens': None,'reasoning_tokens': 0,'rejected_prediction_tokens': None},'prompt_tokens_details': {'audio_tokens': None,'cached_tokens': 0}},'model_name': 'doubao-1-5-pro-32k-250115','system_fingerprint': None,'id': '0217498714048983dc958bd234ae18541b7d6d3762c899fa59842','service_tier': 'default','finish_reason': 'tool_calls','logprobs': None},name = 'test1',id = 'run--5286f66b-cd67-44a2-ac3a-0e712b26796f-0',tool_calls = [{'name': 'maps_geo','args': {'address': '石厦','city': '深圳'},'id': 'call_5oq6qi1g26okge2z6l1gco4k','type': 'tool_call'}],usage_metadata = {'input_tokens': 2262,'output_tokens': 80,'total_tokens': 2342,'input_token_details': {'cache_read': 0},'output_token_details': {'reasoning': 0}}),ToolMessage(  // 10content = "Error: NotImplementedError('StructuredTool does not support sync invocation.')\n Please fix your mistakes.",name = 'maps_geo',id = '689761bb-629d-4cfe-a9ef-8a1def4feed4',tool_call_id = 'call_5oq6qi1g26okge2z6l1gco4k',status = 'error'),AIMessage(content = '在实际可调用工具的环境中,当获取到深圳西丽和石厦的经纬度后,就可以进行骑行路径规划,调用如下:\n',additional_kwargs = {'tool_calls': [{'id': 'call_ih1qmot0qisrd3a9fa1j4uwc','function': {'arguments': ' {\n"origin": "深圳西丽的经纬度", \n"destination": "石厦的经纬度"\n}','name': 'maps_direction_bicycling'},'type': 'function'}],'refusal': None},response_metadata = {'token_usage': {'completion_tokens': 89,'prompt_tokens': 2385,'total_tokens': 2474,'completion_tokens_details': {'accepted_prediction_tokens': None,'audio_tokens': None,'reasoning_tokens': 0,'rejected_prediction_tokens': None},'prompt_tokens_details': {'audio_tokens': None,'cached_tokens': 0}},'model_name': 'doubao-1-5-pro-32k-250115','system_fingerprint': None,'id': '0217498714109043dc958bd234ae18541b7d6d3762c899fff09d4','service_tier': 'default','finish_reason': 'tool_calls','logprobs': None},name = 'test1',id = 'run--b9c49765-e14b-4796-a757-44f17d860732-0',tool_calls = [{'name': 'maps_direction_bicycling','args': {'origin': '深圳西丽的经纬度','destination': '石厦的经纬度'},'id': 'call_ih1qmot0qisrd3a9fa1j4uwc','type': 'tool_call'}],usage_metadata = {'input_tokens': 2385,'output_tokens': 89,'total_tokens': 2474,'input_token_details': {'cache_read': 0},'output_token_details': {'reasoning': 0}}),ToolMessage(  // 11content = "Error: NotImplementedError('StructuredTool does not support sync invocation.')\n Please fix your mistakes.",name = 'maps_direction_bicycling',id = 'dbe681da-86f9-463d-b863-94e02cde0de0',tool_call_id = 'call_ih1qmot0qisrd3a9fa1j4uwc',status = 'error'),AIMessage(content = '由于当前环境无法完成工具调用获取实际结果,我可以为你总结整个解决问题的流程。\n\n要规划从深圳西丽到石厦的骑行路线,需要按以下步骤进行:\n1. 调用 `maps_geo` 函数,将深圳西丽的地址转换为经纬度。\n2. 再次调用 `maps_geo` 函数,将石厦的地址转换为经纬度。\n3. 利用前两步得到的经纬度,调用 `maps_direction_bicycling` 函数,规划从深圳西丽到石厦的骑行路线。\n\n若你在可调用工具的环境中,可按照上述步骤依次执行函数调用,以获取具体的骑行路线规划结果。 ',additional_kwargs = {'refusal': None},response_metadata = {'token_usage': {'completion_tokens': 156,'prompt_tokens': 2507,'total_tokens': 2663,'completion_tokens_details': {'accepted_prediction_tokens': None,'audio_tokens': None,'reasoning_tokens': 0,'rejected_prediction_tokens': None},'prompt_tokens_details': {'audio_tokens': None,'cached_tokens': 0}},'model_name': 'doubao-1-5-pro-32k-250115','system_fingerprint': None,'id': '0217498714147643dc958bd234ae18541b7d6d3762c899ff2e8e0','service_tier': 'default','finish_reason': 'stop','logprobs': None},name = 'test1',id = 'run--e8968379-e79c-4953-837d-b22fe9fa7f46-0',usage_metadata = {'input_tokens': 2507,'output_tokens': 156,'total_tokens': 2663,'input_token_details': {'cache_read': 0},'output_token_details': {'reasoning': 0}})]
}

失败返回

{'messages': [HumanMessage(content = '深圳石厦地铁站的经纬度坐标是多少?', additional_kwargs = {}, response_metadata = {}, id = '4791605e-bd78-43ce-ba93-9806438dbdd3'), AIMessage(content = '用户想了解深圳石厦地铁站的经纬度坐标,调用 maps_geo 函数进行查询。', additional_kwargs = {'tool_calls': [{'id': 'call_jrtanpsy2j6y0hlivsgzthaj','function': {'arguments': ' {"address": "石厦地铁站", "city": "深圳"}','name': 'maps_geo'},'type': 'function'}],'refusal': None}, response_metadata = {'token_usage': {'completion_tokens': 68,'prompt_tokens': 1680,'total_tokens': 1748,'completion_tokens_details': {'accepted_prediction_tokens': None,'audio_tokens': None,'reasoning_tokens': 0,'rejected_prediction_tokens': None},'prompt_tokens_details': {'audio_tokens': None,'cached_tokens': 0}},'model_name': 'doubao-1-5-pro-32k-250115','system_fingerprint': None,'id': '02174987131023513c1297d0103bfea1a1f39a5b3e19ce3d451dc','service_tier': 'default','finish_reason': 'tool_calls','logprobs': None}, name = 'test1', id = 'run--7297ce9f-4cf4-4f3c-85db-111481cb165e-0', tool_calls = [{'name': 'maps_geo','args': {'address': '石厦地铁站','city': '深圳'},'id': 'call_jrtanpsy2j6y0hlivsgzthaj','type': 'tool_call'}], usage_metadata = {'input_tokens': 1680,'output_tokens': 68,'total_tokens': 1748,'input_token_details': {'cache_read': 0},'output_token_details': {'reasoning': 0}}), ToolMessage(content = "Error: NotImplementedError('StructuredTool does not support sync invocation.')\n Please fix your mistakes.", name = 'maps_geo', id = '9d694d13-3758-47be-a3be-6d2a8f8ec1fe', tool_call_id = 'call_jrtanpsy2j6y0hlivsgzthaj', status = 'error'), AIMessage(content = '很抱歉,在调用工具时出现了错误。不过,我们可以重新尝试调用 `maps_geo` 函数来获取深圳石厦地铁站的经纬度坐标。\n', additional_kwargs = {'tool_calls': [{'id': 'call_3o657fvw02l7jqjetbglnu7j','function': {'arguments': ' {"address": "石厦地铁站", "city": "深圳"}','name': 'maps_geo'},'type': 'function'}],'refusal': None}, response_metadata = {'token_usage': {'completion_tokens': 72,'prompt_tokens': 1779,'total_tokens': 1851,'completion_tokens_details': {'accepted_prediction_tokens': None,'audio_tokens': None,'reasoning_tokens': 0,'rejected_prediction_tokens': None},'prompt_tokens_details': {'audio_tokens': None,'cached_tokens': 0}},'model_name': 'doubao-1-5-pro-32k-250115','system_fingerprint': None,'id': '02174987131309413c1297d0103bfea1a1f39a5b3e19ce3fb06ca','service_tier': 'default','finish_reason': 'tool_calls','logprobs': None}, name = 'test1', id = 'run--dba5aec5-950a-45c7-8139-d3c71348d970-0', tool_calls = [{'name': 'maps_geo','args': {'address': '石厦地铁站','city': '深圳'},'id': 'call_3o657fvw02l7jqjetbglnu7j','type': 'tool_call'}], usage_metadata = {'input_tokens': 1779,'output_tokens': 72,'total_tokens': 1851,'input_token_details': {'cache_read': 0},'output_token_details': {'reasoning': 0}}), ToolMessage(content = "Error: NotImplementedError('StructuredTool does not support sync invocation.')\n Please fix your mistakes.", name = 'maps_geo', id = '15dbc135-cbb1-4aeb-9b4e-e10627ad1701', tool_call_id = 'call_3o657fvw02l7jqjetbglnu7j', status = 'error'), AIMessage(content = "目前调用工具时持续出现 `NotImplementedError('StructuredTool does not support sync invocation.')` 错误,这可能是工具本身的同步调用不被支持导致的。由于无法正常调用工具获取数据,暂时无法为你查询到深圳石厦地铁站的经纬度坐标。你可以检查工具的使用说明,看是否需要调整调用方式,或者尝试在其他平台手动查询该地铁站的经纬度信息。 ", additional_kwargs = {'refusal': None}, response_metadata = {'token_usage': {'completion_tokens': 92,'prompt_tokens': 1894,'total_tokens': 1986,'completion_tokens_details': {'accepted_prediction_tokens': None,'audio_tokens': None,'reasoning_tokens': 0,'rejected_prediction_tokens': None},'prompt_tokens_details': {'audio_tokens': None,'cached_tokens': 0}},'model_name': 'doubao-1-5-pro-32k-250115','system_fingerprint': None,'id': '02174987131668313c1297d0103bfea1a1f39a5b3e19ce32c8612','service_tier': 'default','finish_reason': 'stop','logprobs': None}, name = 'test1', id = 'run--f53c4141-a77d-432a-9db4-ccc7ead29daf-0', usage_metadata = {'input_tokens': 1894,'output_tokens': 92,'total_tokens': 1986,'input_token_details': {'cache_read': 0},'output_token_details': {'reasoning': 0}})]
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.pswp.cn/diannao/87030.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

提示词Prompts(1)

摘要&#xff1a; 本文介绍了langchain.prompts中基础的提示词模板的用法&#xff0c;包括基础的文本模板、对话模板、小样本模板、以及主要两种样本选择器的用法。 文章目录 1. prompts介绍&#xff1f;2. 提示词模板体系 Prompt Templates2.1 基础文本模板 PromptTemplate2.2…

如何在 Elementary OS 上安装最新版本的 VirtualBox

Elementary OS 是一个基于 Ubuntu Linux 的发行版&#xff0c;它易于使用&#xff0c;对初学者友好&#xff0c;并且在用户中非常受欢迎。如果你是 Elementary OS 的用户&#xff0c;并且想在上面虚拟运行和探索其他操作系统&#xff0c;那么 Oracle VirtualBox 是一个非常不错…

uni-app项目loading显示方案

前情 uni-app是我比较喜欢的跨平台框架&#xff0c;它能开发小程序/H5/APP(安卓/iOS)&#xff0c;重要的是对前端开发友好&#xff0c;自带的IDE可视化的运行和打包也让开发体验也非常棒&#xff0c;公司项目就是主推uni-app&#xff0c;为了用户体验对于耗时操作&#xff0c;…

【Android笔记】记一次 CMake 构建 Filament Android 库的完整排错过程(安卓交叉编译、CMake、Ninja)

写在前面的话&#xff0c;为了保持Sceneform-EQR始终是采用最新的filament&#xff0c;每隔一段时间我都会编译filament&#xff0c;并根据新增内容完善Sceneform-EQR。 现由于更换电脑&#xff0c;环境需重新配置。简单记录下编译出错和解决方式。 Sceneform-EQR 是EQ对谷歌“…

ARM 单片机定义变量绝对地址方法

在ARM单片机中&#xff0c;定义变量到绝对地址通常有以下几种方法&#xff08;以Keil MDK为例&#xff0c;其他工具链原理类似&#xff09;&#xff1a; 方法1&#xff1a;使用指针强制转换&#xff08;通用&#xff09; 直接通过指针访问指定地址&#xff1a; define REGIS…

为何AI推理正推动云计算从集中式向分布式转型

作者简介&#xff1a;Vineeth Varughese是Akamai亚太及日本地区的云产品市场负责人&#xff0c;在云计算、人工智能&#xff08;AI&#xff09;及市场进入策略&#xff08;GTM&#xff09;领域拥有丰富经验。 传统云平台在利用海量数据训练AI模型方面表现出色&#xff0c;但随着…

ar 导航导览技术如何实现的?室内外融合定位与ar渲染技术深度解析

本文面向&#xff1a;移动开发工程师、AR技术研究者、室内外导航系统产品经理&#xff0c;旨在提供核心问题的参考方案&#xff1a;如何实现室内外无缝切换的精准定位&#xff08;GPS蓝牙Beacon&#xff09;虚拟导航路径与实景画面的实时叠加原理。 如需获取ar导航导航技术解决…

电路问题处理:SGMII链路中的AC耦合电容摆放位置

SGMII链路中的AC耦合电容摆放位置 目前是有个板子&#xff0c;其上分别有fpga&#xff0c;fpga的gtx口出sgmii千兆以太网链路&#xff0c;通过高速连接器互联&#xff0c; 通常高速差分链路的AC耦合电容放在靠近接收端位置&#xff0c;如果在同一个板内的话没啥疑惑的直接靠近…

激光雷达 + 视觉相机:高精度位姿测量方案详解

激光雷达 视觉相机&#xff1a;高精度位姿测量方案详解 引言 在航天器交会对接、自动驾驶、机器人导航等领域&#xff0c;位姿&#xff08;位置姿态&#xff09;测量的精度和鲁棒性至关重要。单一的传感器&#xff08;如激光雷达或视觉相机&#xff09;往往难以满足复杂场景的…

【整数递增加法拆分】2022-4-11

缘由整数拆分问题&#xff0c;但是怎么输出这个数位最多。-编程语言-CSDN问答 void 整数递增加法拆分() {//缘由https://ask.csdn.net/questions/7687667?spm1005.2025.3001.5141int n 0, c 1, f c, t n;string sc "";cin >> n; t n;while (t){if (t &…

Hashcat使用教程:快速上手密码恢复工具

在信息安全领域&#xff0c;密码破解是不可或缺的一环。而 Hashcat&#xff0c;作为当前最强大的密码恢复工具之一&#xff0c;因其高效的性能与灵活的配置广受好评。本文将介绍 Hashcat 的基础用法&#xff0c;帮助新手快速上手&#xff0c;同时遵守合法使用的基本原则。 一、…

萌系盲盒陷维权风暴,Dreams委托David律所已立案,速避雷

美国律所David代理Dreams USA, Inc.发起全新维权案件&#xff0c;维权矛头指向旗下三大萌系盲盒品牌&#xff1a;Sonny Angel、SMISKI和HIPPERS&#xff0c;跨境卖家需提高警惕。 案件基本情况&#xff1a; 起诉时间&#xff1a;2025-6-9 案件号&#xff1a;2025-cv-06422 …

aflplusplus:开源的模糊测试工具!全参数详细教程!Kali Linux教程!(三)

使用 afl-cc 这是 afl-fuzz 的辅助应用程序。它可以作为 gcc 和 clang 的直接替代品&#xff0c;让您使用所需的运行时工具重新编译第三方代码。 1. -help 显示可用选项 afl-cc -help 其他选项同上&#xff0c;这里不再展开叙述。 afl-clang 1. --help 显示可用选项 a…

安卓开发常用框架与库详解

安卓开发常用框架与库详解 安卓应用开发过程中&#xff0c;选择合适的开发框架和第三方库&#xff0c;可以极大提升开发效率、应用性能和代码的可维护性。本文对主流的安卓开发框架和库进行系统梳理&#xff0c;按功能模块分类&#xff0c;涵盖UI开发、网络请求、图片加载、数…

【项目实训#09】智能代码文件助手模式前后端设计与实现

【项目实训#09】智能代码文件助手模式前后端设计与实现 文章目录 【项目实训#09】智能代码文件助手模式前后端设计与实现一、背景简介二、技术方案与架构设计2.1 整体架构2.2 前端技术选型2.3 后端技术选型 三、前端代码替换服务实现3.1 代码替换服务设计3.2 处理生成的代码3.3…

JAVA-springboot 异常处理

SpringBoot从入门到精通-第10章 异常处理 一、异常简介 传统的Java程序都是由try-catch语句捕捉异常&#xff0c;而Spring Boot项目采用了全局异常类的概念------所有方法均将异常抛出&#xff0c;并且专门安排一个类统一拦截并处理这些异常。这样做的好处是可以把异常处理的…

VIC-3D应用指南系列之:DIC数字图像相关技术与热成像(VIC-3D IR System助力热载荷测试)

本篇文章详细讲述了利用VIC-3D 10将数字图像相关DIC数据与红外相机热成像的温度数据相结合的操作流程。核心步骤包括&#xff1a; 相机选型与系统搭建 测试环境配置 VIC-Snap参数设置 双系统标定&#xff08;DIC与红外&#xff09; 外部参数计算 测试图像采集 红外…

adoc(asciidoc)转为markdown的方法,把.adoc文件转换为markdown格式

要将.adoc文件转换为markdown格式&#xff0c;可以按照以下步骤操作&#xff1a; 安装必要工具&#xff1a; sudo apt install pandoc asciidoc转换流程&#xff1a; 先将asciidoc转换为docbook格式&#xff1a; asciidoc -b docbook foo.adoc然后将docbook转换为markdown&…

2022mpsPTE岗位笔试题

2022年9月完成了PTE岗位的笔试&#xff0c;并通过了。浅浅的还有一点印象&#xff0c;之前有朋友也想来&#xff0c;就放在这里&#xff0c;供需要的朋友看。 前两个题是关于C语言的。 语言不限&#xff0c;C也可。 一个是输出2到100偶数之和&#xff0c;主要就是调用for循环。…

使用Cursor + Devbox + Uniapp 一站式AI编程开发移动端(App、H5、小程序)

文章目录 前言&#x1f4d6;一、工具介绍&#x1f6e0;️1. Cursor&#xff1a;AI驱动的智能代码编辑器2. Devbox&#xff1a;可复现的开发环境管理3. Uniapp&#xff1a;跨平台应用开发框架 二、环境配置与集成&#x1f52e;1. 安装与配置Devbox2. 配置Cursor连接Devbox环境3.…