当前位置: 首页 > java >正文

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.xdnf.cn/news/14190.html

相关文章:

  • TDengine 如何从 2.x 迁移到 3.0
  • Java并发编程实战 Day 22:高性能无锁编程技术
  • JAVA关键字-final
  • Semaphore入门案例
  • Java线程池ThreadPoolExecutor的状态
  • ERROR 1396 (HY000): Operation ALTER USER failed for ‘root‘@‘%‘
  • 基于 C 语言的图书管理系统开发详解​
  • 基于YOLOv11+PP-OCRv5深度学习的智能车牌检测与识别系统python源码+pytorch模型+评估指标曲线+精美GUI界面
  • 【SpringMVC 入门介绍】
  • 零基础RT-thread第二节:按键控制
  • Redux 原理深度剖析
  • 备忘录模式:文本编辑器撤销功能实现
  • 2025年渗透测试面试题总结-字节跳动[实习]安全研究员(题目+回答)
  • 浏览器 报502 网关错误,解决方法2
  • 论文精读Lami-Detr:Open-Vocabulary Detection with Language Model Instruction
  • 芯片的起点——从硅到晶圆制造
  • 用Python写一个可视化大屏
  • 简说ping、telnet、netcat
  • 论文阅读-单目视觉惯性系统时间标定
  • MySQL 锁学习笔记
  • 计算机网络-自顶向下—第二章应用层-重点复习笔记
  • 在C++中的封装(Encapsulation)
  • Linux学习笔记:PCIe内核篇(1):初始化与枚举流程
  • 第1章 C# 和 .NET 框架 笔记
  • MCP简介和应用
  • 第十七章 Linux之大数据定制篇——Shell编程
  • ES知识合集(四):高级篇
  • 20250614让NanoPi NEO core开发板在Ubuntu core16.04系统下使用耳机播音测试
  • 「Linux文件及目录管理」目录结构及显示类命令
  • Python虚拟环境的使用