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

langchain 实现多智能体多轮对话

这里写目录标题

    • 工具定义
    • 模型选择
    • graph节点函数定义
    • graph 运行

工具定义

import random
from typing import Annotated, Literalfrom langchain_core.tools import tool
from langchain_core.tools.base import InjectedToolCallId
from langgraph.prebuilt import InjectedState
from langgraph.types import Command@tool
def get_travel_recommendations():"""Get recommendation for travel destinations"""return random.choice(["aruba", "turks and caicos"])@tool
def get_hotel_recommendations(location: Literal["aruba", "turks and caicos"]):"""Get hotel recommendations for a given destination."""return {"aruba": ["The Ritz-Carlton, Aruba (Palm Beach)""Bucuti & Tara Beach Resort (Eagle Beach)"],"turks and caicos": ["Grace Bay Club", "COMO Parrot Cay"],}[location]def make_handoff_tool(*, agent_name: str):"""Create a tool that can return handoff via a Command"""tool_name = f"transfer_to_{agent_name}"@tool(tool_name)def handoff_to_agent(state: Annotated[dict, InjectedState],tool_call_id: Annotated[str, InjectedToolCallId],):"""Ask another agent for help."""tool_message = {"role": "tool","content": f"Successfully transferred to {agent_name}","name": tool_name,"tool_call_id": tool_call_id,}return Command(# navigate to another agent node in the PARENT graphgoto=agent_name,graph=Command.PARENT,# This is the state update that the agent `agent_name` will see when it is invoked.# We're passing agent's FULL internal message history AND adding a tool message to make sure# the resulting chat history is valid.update={"messages": state["messages"] + [tool_message]},)return handoff_to_agent

模型选择

from langchain_openai import ChatOpenAI
model = ChatOpenAI(temperature=0,model="GLM-4-PLUS",openai_api_key="your api key",openai_api_base="https://open.bigmodel.cn/api/paas/v4/"
)

graph节点函数定义

from langgraph.graph import MessagesState, StateGraph, START
from langgraph.prebuilt import create_react_agent, InjectedState
from langgraph.types import Command, interrupt
from langgraph.checkpoint.memory import MemorySaver# Define travel advisor tools and ReAct agent
travel_advisor_tools = [get_travel_recommendations,make_handoff_tool(agent_name="hotel_advisor"),
]
travel_advisor = create_react_agent(model,travel_advisor_tools,prompt=("You are a general travel expert that can recommend travel destinations (e.g. countries, cities, etc). ""If you need hotel recommendations, ask 'hotel_advisor' for help. ""You MUST include human-readable response before transferring to another agent."),
)def call_travel_advisor(state: MessagesState,
) -> Command[Literal["hotel_advisor", "human"]]:# You can also add additional logic like changing the input to the agent / output from the agent, etc.# NOTE: we're invoking the ReAct agent with the full history of messages in the stateresponse = travel_advisor.invoke(state)return Command(update=response, goto="human")# Define hotel advisor tools and ReAct agent
hotel_advisor_tools = [get_hotel_recommendations,make_handoff_tool(agent_name="travel_advisor"),
]
hotel_advisor = create_react_agent(model,hotel_advisor_tools,prompt=("You are a hotel expert that can provide hotel recommendations for a given destination. ""If you need help picking travel destinations, ask 'travel_advisor' for help.""You MUST include human-readable response before transferring to another agent."),
)def call_hotel_advisor(state: MessagesState,
) -> Command[Literal["travel_advisor", "human"]]:response = hotel_advisor.invoke(state)return Command(update=response, goto="human")def human_node(state: MessagesState, config
) -> Command[Literal["hotel_advisor", "travel_advisor", "human"]]:"""A node for collecting user input."""user_input = input("Ready for user input.")# identify the last active agent# (the last active node before returning to human)langgraph_triggers = config["metadata"]["langgraph_triggers"]if len(langgraph_triggers) != 1:raise AssertionError("Expected exactly 1 trigger in human node")active_agent = langgraph_triggers[0].split(":")[1]return Command(update={"messages": [{"role": "human","content": user_input,}]},goto=active_agent,)builder = StateGraph(MessagesState)
builder.add_node("travel_advisor", call_travel_advisor)
builder.add_node("hotel_advisor", call_hotel_advisor)# This adds a node to collect human input, which will route
# back to the active agent.
builder.add_node("human", human_node)# We'll always start with a general travel advisor.
builder.add_edge(START, "travel_advisor")checkpointer = MemorySaver()
graph = builder.compile(checkpointer=checkpointer)

Graph可视化

from IPython.display import display, Imagedisplay(Image(graph.get_graph().draw_mermaid_png()))

在这里插入图片描述

graph 运行

import uuidthread_config = {"configurable": {"thread_id": uuid.uuid4()}}user_input = {"messages": [{"role": "user", "content": "i wanna go somewhere warm in the caribbean"}]}for update in graph.stream(user_input,config=thread_config,stream_mode="updates",):for node_id, value in update.items():print(f"{node_id}: {value}")
travel_advisor: {'messages': [HumanMessage(content='i wanna go somewhere warm in the caribbean', additional_kwargs={}, response_metadata={}, id='b7a9d8a8-f569-464a-8942-c98f477b8ce2'), AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_-9024507181658326780', 'function': {'arguments': '{}', 'name': 'get_travel_recommendations'}, 'type': 'function', 'index': 0}], 'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 7, 'prompt_tokens': 203, 'total_tokens': 210, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'GLM-4-PLUS', 'system_fingerprint': None, 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-9ed5c54c-2540-41d2-9704-769075778a98-0', tool_calls=[{'name': 'get_travel_recommendations', 'args': {}, 'id': 'call_-9024507181658326780', 'type': 'tool_call'}], usage_metadata={'input_tokens': 203, 'output_tokens': 7, 'total_tokens': 210, 'input_token_details': {}, 'output_token_details': {}}), ToolMessage(content='turks and caicos', name='get_travel_recommendations', id='9dbe9001-1341-40fd-a431-b391bcfab0d8', tool_call_id='call_-9024507181658326780'), AIMessage(content="For a warm getaway in the Caribbean, I recommend visiting Turks and Caicos. It's known for its beautiful beaches and pleasant climate. Would you like hotel recommendations for Turks and Caicos? If so, I can ask the hotel advisor for assistance.", additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 52, 'prompt_tokens': 217, 'total_tokens': 269, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'GLM-4-PLUS', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None}, id='run-aed9c540-eb16-4782-8dc2-aae47932df30-0', usage_metadata={'input_tokens': 217, 'output_tokens': 52, 'total_tokens': 269, 'input_token_details': {}, 'output_token_details': {}})]}
human: {'messages': [{'role': 'human', 'content': 'hotel recommendation'}]}
travel_advisor: {'messages': [HumanMessage(content='i wanna go somewhere warm in the caribbean', additional_kwargs={}, response_metadata={}, id='b7a9d8a8-f569-464a-8942-c98f477b8ce2'), AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_-9024507181658326780', 'function': {'arguments': '{}', 'name': 'get_travel_recommendations'}, 'type': 'function', 'index': 0}], 'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 7, 'prompt_tokens': 203, 'total_tokens': 210, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'GLM-4-PLUS', 'system_fingerprint': None, 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-9ed5c54c-2540-41d2-9704-769075778a98-0', tool_calls=[{'name': 'get_travel_recommendations', 'args': {}, 'id': 'call_-9024507181658326780', 'type': 'tool_call'}], usage_metadata={'input_tokens': 203, 'output_tokens': 7, 'total_tokens': 210, 'input_token_details': {}, 'output_token_details': {}}), ToolMessage(content='turks and caicos', name='get_travel_recommendations', id='9dbe9001-1341-40fd-a431-b391bcfab0d8', tool_call_id='call_-9024507181658326780'), AIMessage(content="For a warm getaway in the Caribbean, I recommend visiting Turks and Caicos. It's known for its beautiful beaches and pleasant climate. Would you like hotel recommendations for Turks and Caicos? If so, I can ask the hotel advisor for assistance.", additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 52, 'prompt_tokens': 217, 'total_tokens': 269, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'GLM-4-PLUS', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None}, id='run-aed9c540-eb16-4782-8dc2-aae47932df30-0', usage_metadata={'input_tokens': 217, 'output_tokens': 52, 'total_tokens': 269, 'input_token_details': {}, 'output_token_details': {}}), HumanMessage(content='hotel recommendation', additional_kwargs={}, response_metadata={}, id='931caa5f-a5c7-4c4c-991a-d7e3843c7aa6'), AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_-9024511201749198020', 'function': {'arguments': '{}', 'name': 'transfer_to_hotel_advisor'}, 'type': 'function', 'index': 0}], 'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 9, 'prompt_tokens': 273, 'total_tokens': 282, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'GLM-4-PLUS', 'system_fingerprint': None, 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-92da714d-1d8c-4a96-b6c8-3b0d2ac916c6-0', tool_calls=[{'name': 'transfer_to_hotel_advisor', 'args': {}, 'id': 'call_-9024511201749198020', 'type': 'tool_call'}], usage_metadata={'input_tokens': 273, 'output_tokens': 9, 'total_tokens': 282, 'input_token_details': {}, 'output_token_details': {}}), {'role': 'tool', 'content': 'Successfully transferred to hotel_advisor', 'name': 'transfer_to_hotel_advisor', 'tool_call_id': 'call_-9024511201749198020'}]}
hotel_advisor: {'messages': [HumanMessage(content='i wanna go somewhere warm in the caribbean', additional_kwargs={}, response_metadata={}, id='b7a9d8a8-f569-464a-8942-c98f477b8ce2'), AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_-9024507181658326780', 'function': {'arguments': '{}', 'name': 'get_travel_recommendations'}, 'type': 'function', 'index': 0}], 'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 7, 'prompt_tokens': 203, 'total_tokens': 210, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'GLM-4-PLUS', 'system_fingerprint': None, 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-9ed5c54c-2540-41d2-9704-769075778a98-0', tool_calls=[{'name': 'get_travel_recommendations', 'args': {}, 'id': 'call_-9024507181658326780', 'type': 'tool_call'}], usage_metadata={'input_tokens': 203, 'output_tokens': 7, 'total_tokens': 210, 'input_token_details': {}, 'output_token_details': {}}), ToolMessage(content='turks and caicos', name='get_travel_recommendations', id='9dbe9001-1341-40fd-a431-b391bcfab0d8', tool_call_id='call_-9024507181658326780'), AIMessage(content="For a warm getaway in the Caribbean, I recommend visiting Turks and Caicos. It's known for its beautiful beaches and pleasant climate. Would you like hotel recommendations for Turks and Caicos? If so, I can ask the hotel advisor for assistance.", additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 52, 'prompt_tokens': 217, 'total_tokens': 269, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'GLM-4-PLUS', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None}, id='run-aed9c540-eb16-4782-8dc2-aae47932df30-0', usage_metadata={'input_tokens': 217, 'output_tokens': 52, 'total_tokens': 269, 'input_token_details': {}, 'output_token_details': {}}), HumanMessage(content='hotel recommendation', additional_kwargs={}, response_metadata={}, id='931caa5f-a5c7-4c4c-991a-d7e3843c7aa6'), AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_-9024511201749198020', 'function': {'arguments': '{}', 'name': 'transfer_to_hotel_advisor'}, 'type': 'function', 'index': 0}], 'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 9, 'prompt_tokens': 273, 'total_tokens': 282, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'GLM-4-PLUS', 'system_fingerprint': None, 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-92da714d-1d8c-4a96-b6c8-3b0d2ac916c6-0', tool_calls=[{'name': 'transfer_to_hotel_advisor', 'args': {}, 'id': 'call_-9024511201749198020', 'type': 'tool_call'}], usage_metadata={'input_tokens': 273, 'output_tokens': 9, 'total_tokens': 282, 'input_token_details': {}, 'output_token_details': {}}), ToolMessage(content='Successfully transferred to hotel_advisor', name='transfer_to_hotel_advisor', id='ce44c5c6-0fa4-4d7e-9452-60399000e83f', tool_call_id='call_-9024511201749198020'), AIMessage(content="I've transferred your request to the hotel advisor who will provide you with hotel recommendations for Turks and Caicos. They will assist you in finding the perfect accommodation for your warm Caribbean getaway.", additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 39, 'prompt_tokens': 334, 'total_tokens': 373, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'GLM-4-PLUS', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None}, id='run-08b49c36-2726-4935-bf7e-ed6149d03f00-0', usage_metadata={'input_tokens': 334, 'output_tokens': 39, 'total_tokens': 373, 'input_token_details': {}, 'output_token_details': {}})]}
human: {'messages': [{'role': 'human', 'content': 'Well, give me some hotel recom'}]}
hotel_advisor: {'messages': [HumanMessage(content='i wanna go somewhere warm in the caribbean', additional_kwargs={}, response_metadata={}, id='b7a9d8a8-f569-464a-8942-c98f477b8ce2'), AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_-9024507181658326780', 'function': {'arguments': '{}', 'name': 'get_travel_recommendations'}, 'type': 'function', 'index': 0}], 'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 7, 'prompt_tokens': 203, 'total_tokens': 210, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'GLM-4-PLUS', 'system_fingerprint': None, 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-9ed5c54c-2540-41d2-9704-769075778a98-0', tool_calls=[{'name': 'get_travel_recommendations', 'args': {}, 'id': 'call_-9024507181658326780', 'type': 'tool_call'}], usage_metadata={'input_tokens': 203, 'output_tokens': 7, 'total_tokens': 210, 'input_token_details': {}, 'output_token_details': {}}), ToolMessage(content='turks and caicos', name='get_travel_recommendations', id='9dbe9001-1341-40fd-a431-b391bcfab0d8', tool_call_id='call_-9024507181658326780'), AIMessage(content="For a warm getaway in the Caribbean, I recommend visiting Turks and Caicos. It's known for its beautiful beaches and pleasant climate. Would you like hotel recommendations for Turks and Caicos? If so, I can ask the hotel advisor for assistance.", additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 52, 'prompt_tokens': 217, 'total_tokens': 269, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'GLM-4-PLUS', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None}, id='run-aed9c540-eb16-4782-8dc2-aae47932df30-0', usage_metadata={'input_tokens': 217, 'output_tokens': 52, 'total_tokens': 269, 'input_token_details': {}, 'output_token_details': {}}), HumanMessage(content='hotel recommendation', additional_kwargs={}, response_metadata={}, id='931caa5f-a5c7-4c4c-991a-d7e3843c7aa6'), AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_-9024511201749198020', 'function': {'arguments': '{}', 'name': 'transfer_to_hotel_advisor'}, 'type': 'function', 'index': 0}], 'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 9, 'prompt_tokens': 273, 'total_tokens': 282, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'GLM-4-PLUS', 'system_fingerprint': None, 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-92da714d-1d8c-4a96-b6c8-3b0d2ac916c6-0', tool_calls=[{'name': 'transfer_to_hotel_advisor', 'args': {}, 'id': 'call_-9024511201749198020', 'type': 'tool_call'}], usage_metadata={'input_tokens': 273, 'output_tokens': 9, 'total_tokens': 282, 'input_token_details': {}, 'output_token_details': {}}), ToolMessage(content='Successfully transferred to hotel_advisor', name='transfer_to_hotel_advisor', id='ce44c5c6-0fa4-4d7e-9452-60399000e83f', tool_call_id='call_-9024511201749198020'), AIMessage(content="I've transferred your request to the hotel advisor who will provide you with hotel recommendations for Turks and Caicos. They will assist you in finding the perfect accommodation for your warm Caribbean getaway.", additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 39, 'prompt_tokens': 334, 'total_tokens': 373, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'GLM-4-PLUS', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None}, id='run-08b49c36-2726-4935-bf7e-ed6149d03f00-0', usage_metadata={'input_tokens': 334, 'output_tokens': 39, 'total_tokens': 373, 'input_token_details': {}, 'output_token_details': {}}), HumanMessage(content='Well, give me some hotel recom', additional_kwargs={}, response_metadata={}, id='8a6d6e7f-5d26-4c77-aa7c-95485581e7e4'), AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_-9024517077266482785', 'function': {'arguments': '{"location": "turks and caicos"}', 'name': 'get_hotel_recommendations'}, 'type': 'function', 'index': 0}], 'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 17, 'prompt_tokens': 382, 'total_tokens': 399, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'GLM-4-PLUS', 'system_fingerprint': None, 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-b072e101-db1e-4809-b87d-d767df0e9f10-0', tool_calls=[{'name': 'get_hotel_recommendations', 'args': {'location': 'turks and caicos'}, 'id': 'call_-9024517077266482785', 'type': 'tool_call'}], usage_metadata={'input_tokens': 382, 'output_tokens': 17, 'total_tokens': 399, 'input_token_details': {}, 'output_token_details': {}}), ToolMessage(content='["Grace Bay Club", "COMO Parrot Cay"]', name='get_hotel_recommendations', id='45cc7ee3-9d7e-4df5-aacc-914878812d5b', tool_call_id='call_-9024517077266482785'), AIMessage(content='Here are some hotel recommendations for Turks and Caicos:\n\n1. Grace Bay Club\n2. COMO Parrot Cay\n\nThese hotels are known for their excellent amenities and beautiful locations. Enjoy your stay in Turks and Caicos!', additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 48, 'prompt_tokens': 413, 'total_tokens': 461, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'GLM-4-PLUS', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None}, id='run-76dc546c-5272-48cc-ae1b-63437bf6051f-0', usage_metadata={'input_tokens': 413, 'output_tokens': 48, 'total_tokens': 461, 'input_token_details': {}, 'output_token_details': {}})]}
human: {'messages': [{'role': 'human', 'content': ''}]}

参考链接:https://langchain-ai.github.io/langgraph/how-tos/multi-agent-multi-turn-convo-functional/

相关文章:

langchain 实现多智能体多轮对话

这里写目录标题 工具定义模型选择graph节点函数定义graph 运行 工具定义 import random from typing import Annotated, Literalfrom langchain_core.tools import tool from langchain_core.tools.base import InjectedToolCallId from langgraph.prebuilt import InjectedSt…...

Java-数据结构-优先级队列(堆)

一、优先级队列 ① 什么是优先级队列? 在此之前,我们已经学习过了"队列"的相关知识,我们知道"队列"是一种"先进先出"的数据结构,我们还学习过"栈",是"后进先出"的…...

C++实现状态模式

首先上代码&#xff1a; #include <iostream> #include <memory>class Context;class State { public:virtual void Handle(Context * context) 0; //纯虚函数virtual ~State() default; //虚析构函数 };//创建状态A class ConcreateStateA : public State{…...

FreeRTOS学习笔记2:FreeRTOS的基础知识

1.FreeRTOS介绍 FreeRTOS是一个免费的嵌入式实时操作系统&#xff0c;同时它在市面上也是一款主流的操作系统&#xff0c;是工作上必不可少的技能。它具有以下六种特点&#xff1a; 1.免费开源&#xff1a;在商业产品中使用&#xff0c;无潜在商业风险&#xff0c;无需担心。 2…...

计算机网络之计算机网络的分类

计算机网络可以根据不同的角度进行分类&#xff0c;以下是几种常见的分类方式&#xff1a; 1. 按照规模和范围&#xff1a; 局域网&#xff08;LAN&#xff0c;Local Area Network&#xff09;&#xff1a;覆盖较小范围&#xff08;例如一个建筑物或校园&#xff09;&#xf…...

从理论到实践:Linux 进程替换与 exec 系列函数

个人主页&#xff1a;chian-ocean 文章专栏-Linux 前言&#xff1a; 在Linux中&#xff0c;进程替换&#xff08;Process Substitution&#xff09;是一个非常强大的特性&#xff0c;它允许将一个进程的输出直接当作一个文件来处理。这种技术通常用于Shell脚本和命令行操作中…...

Flutter常用Widget小部件

小部件Widget是一个类&#xff0c;按照继承方式&#xff0c;分为无状态的StatelessWidget和有状态的StatefulWidget。 这里先创建一个简单的无状态的Text小部件。 Text文本Widget 文件&#xff1a;lib/app/app.dart。 import package:flutter/material.dart;class App exte…...

微信小程序实战0 设置

1.调节模拟器到右侧位置 2.设置编辑页面的字体和行距。...

2025开源DouyinLiveRecorder全平台直播间录制工具整合包,多直播同时录制、教学直播录制、教学视频推送、简单易用不占内存

一、DouyinLiveRecorder软件介绍&#xff08;文末提供下载&#xff09; 官方地址&#xff1a;GitHub - ihmily/DouyinLiveRecorder 本文信息来源于作者GitHub地址 一款简易的可循环值守的直播录制工具&#xff0c;基于FFmpeg实现多平台直播源录制&#xff0c;支持自定义配置录制…...

使用 postman 测试思源笔记接口

思源笔记 API 权鉴 官方文档-中文&#xff1a;https://github.com/siyuan-note/siyuan/blob/master/API_zh_CN.md 权鉴相关介绍截图&#xff1a; 对应的xxx&#xff0c;在软件中查看 如上图&#xff1a;在每次发送 API 请求时&#xff0c;需要在 Header 中添加 以下键值对&a…...

当WebGIS遇到智慧文旅-以长沙市不绕路旅游攻略为例

目录 前言 一、旅游数据组织 1、旅游景点信息 2、路线时间推荐 二、WebGIS可视化实现 1、态势标绘实现 2、相关位置展示 三、成果展示 1、第一天旅游路线 2、第二天旅游路线 3、第三天旅游路线 4、交通、订票、住宿指南 四、总结 前言 随着信息技术的飞速发展&…...

阿里最新普通x231 逆向分析

声明: 本文章中所有内容仅供学习交流使用&#xff0c;不用于其他任何目的&#xff0c;抓包内容、敏感网址、数据接口等均已做脱敏处理&#xff0c;严禁用于商业用途和非法用途&#xff0c;否则由此产生的一切后果均与作者无关&#xff01; 逆向前言 12月份的时候更新了过一次…...

php的使用及storm环境部署

php语法 环境搭建&#xff1a;在小皮中新建网站&#xff0c;注意先填写域名再点击选择根目录。 成功创建网站后&#xff0c;打开发现forbidden&#xff0c;因为新建的网站里是空的&#xff0c;需要新建index.php文件----> 在Phpstorm中左上角打开文件&#xff0c;打开那个文…...

高可用 Keepalived 服务部署流程

一、配置文件 vim /etc/keepalived/keepalived.confGLOBAL CONFIGURATION --- 全局配置部分VRRPD CONFIGURATION --- VRRP协议配置部分LVS CONFIGURATION --- LVS服务管理配置部分[rootlb01 ~]# cat /etc/keepalived/keepalived.…...

【新春特辑】2025年1月科技浪潮中的AI最新时事与科技趋势

2025年1月科技浪潮中的AI最新时事与科技趋势 一、AI科技时事 人工智能代理&#xff08;AI Agent&#xff09;的发展 最新进展&#xff1a;人工智能代理正逐步成为科技领域的新热点。这些代理能够自主执行特定任务&#xff0c;如管理日程、回复邮件等。然而&#xff0c;它们仍…...

解决Django非ORM模型提示初始化request问题

提问 Django在DRF时候自定义显示一些非model的字段提示TypeError: Field.__init__() got an unexpected keyword argument request 解答1 错误提示 TypeError: Field.__init__() got an unexpected keyword argument request 显示在创建序列化器实例时&#xff0c;传递了一个…...

G. XOUR

题目链接&#xff1a;Problem - G - Codeforces 题目大意&#xff1a;给你一个n长的序列&#xff0c; 其中你可以将a[i] XOR a[j] 的值 严格小于4的数对进行交换。 你可以操作任何几次&#xff0c; 让最后的数列最小。如果在 x 和 y 不同的第一个位置&#xff0c; xi<yi &…...

有没有个性化的UML图例

绿萝小绿萝 (53****338) 2012-05-10 11:55:45 各位大虾&#xff0c;有没有个性化的UML图例 绿萝小绿萝 (53****338) 2012-05-10 11:56:03 例如部署图或时序图的图例 潘加宇 (35***47) 2012-05-10 12:24:31 "个性化"指的是&#xff1f; 你的意思使用你自己的图标&…...

【RAG】SKLearnVectorStore 避免使用gpt4all会connection err

gpt4all 列表中包含了多个开源的大模型,如 Qwen2.5、Llama 3、DeepSeek、Mistral 等,但 不包含 OpenAI 的 GPT-4o。GPT-4o 是 OpenAI 提供的闭源模型,目前只能通过 OpenAI API 或 ChatGPT 官方应用(网页版、移动端)访问,并不支持本地运行,也没有 GGUF 量化格式的模型文件…...

vue框架技术相关概述以及前端框架整合

vue框架技术概述及前端框架整合 1 node.js 介绍&#xff1a;什么是node.js Node.js就是运行在服务端的JavaScript。 Node.js是一个事件驱动I/O服务端JavaScript环境&#xff0c;基于Google的V8引擎。 作用 1 运行java需要安装JDK&#xff0c;而Node.js是JavaScript的运行环…...

从零实现富文本编辑器#5-编辑器选区模型的状态结构表达

先前我们总结了浏览器选区模型的交互策略&#xff0c;并且实现了基本的选区操作&#xff0c;还调研了自绘选区的实现。那么相对的&#xff0c;我们还需要设计编辑器的选区表达&#xff0c;也可以称为模型选区。编辑器中应用变更时的操作范围&#xff0c;就是以模型选区为基准来…...

mongodb源码分析session执行handleRequest命令find过程

mongo/transport/service_state_machine.cpp已经分析startSession创建ASIOSession过程&#xff0c;并且验证connection是否超过限制ASIOSession和connection是循环接受客户端命令&#xff0c;把数据流转换成Message&#xff0c;状态转变流程是&#xff1a;State::Created 》 St…...

Qt Widget类解析与代码注释

#include "widget.h" #include "ui_widget.h"Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget) {ui->setupUi(this); }Widget::~Widget() {delete ui; }//解释这串代码&#xff0c;写上注释 当然可以&#xff01;这段代码是 Qt …...

vue3 字体颜色设置的多种方式

在Vue 3中设置字体颜色可以通过多种方式实现&#xff0c;这取决于你是想在组件内部直接设置&#xff0c;还是在CSS/SCSS/LESS等样式文件中定义。以下是几种常见的方法&#xff1a; 1. 内联样式 你可以直接在模板中使用style绑定来设置字体颜色。 <template><div :s…...

GitHub 趋势日报 (2025年06月08日)

&#x1f4ca; 由 TrendForge 系统生成 | &#x1f310; https://trendforge.devlive.org/ &#x1f310; 本日报中的项目描述已自动翻译为中文 &#x1f4c8; 今日获星趋势图 今日获星趋势图 884 cognee 566 dify 414 HumanSystemOptimization 414 omni-tools 321 note-gen …...

Rapidio门铃消息FIFO溢出机制

关于RapidIO门铃消息FIFO的溢出机制及其与中断抖动的关系&#xff0c;以下是深入解析&#xff1a; 门铃FIFO溢出的本质 在RapidIO系统中&#xff0c;门铃消息FIFO是硬件控制器内部的缓冲区&#xff0c;用于临时存储接收到的门铃消息&#xff08;Doorbell Message&#xff09;。…...

鸿蒙DevEco Studio HarmonyOS 5跑酷小游戏实现指南

1. 项目概述 本跑酷小游戏基于鸿蒙HarmonyOS 5开发&#xff0c;使用DevEco Studio作为开发工具&#xff0c;采用Java语言实现&#xff0c;包含角色控制、障碍物生成和分数计算系统。 2. 项目结构 /src/main/java/com/example/runner/├── MainAbilitySlice.java // 主界…...

Reasoning over Uncertain Text by Generative Large Language Models

https://ojs.aaai.org/index.php/AAAI/article/view/34674/36829https://ojs.aaai.org/index.php/AAAI/article/view/34674/36829 1. 概述 文本中的不确定性在许多语境中传达,从日常对话到特定领域的文档(例如医学文档)(Heritage 2013;Landmark、Gulbrandsen 和 Svenevei…...

Java求职者面试指南:Spring、Spring Boot、MyBatis框架与计算机基础问题解析

Java求职者面试指南&#xff1a;Spring、Spring Boot、MyBatis框架与计算机基础问题解析 一、第一轮提问&#xff08;基础概念问题&#xff09; 1. 请解释Spring框架的核心容器是什么&#xff1f;它在Spring中起到什么作用&#xff1f; Spring框架的核心容器是IoC容器&#…...

Python Ovito统计金刚石结构数量

大家好,我是小马老师。 本文介绍python ovito方法统计金刚石结构的方法。 Ovito Identify diamond structure命令可以识别和统计金刚石结构,但是无法直接输出结构的变化情况。 本文使用python调用ovito包的方法,可以持续统计各步的金刚石结构,具体代码如下: from ovito…...