AgentScope中带有@功能的多Agent组对话

0,简介

演示由AgentScope支持的多代理(agent)群组对话。建立了一个虚拟聊天室,用户代理在其中与几个NPC(非玩家角色)代理进行交互。参与者可以使用特殊的“@”提及功能直接与特定代理联系。每个参与者都是预定义的角色。话题是开放的,会根据用户的输入和代理的响应而发展。

1,设置基本参数

1.1 设置用户在回合中发言的时间限制

agentscope/examples/conversation_with_mentions/main.py脚本中USER_TIME_TO_SPEAK 参数定义了用户在回合制中发言的时间限制,这里我们给用户设置11秒钟的时间来输入他们的消息。

1.2,设定群聊的默认话题和系统提示

  • 默认话题(DEFAULT_TOPIC)可以指导Agent与用户互动,并为群聊提供初始的讨论方向。
  • 系统提示(SYS_PROMPT)中告诉智能体使用“@”提及某个智能体继续对话,也就是说不仅用户可以“@”提及NPC智能体,NPC智能体也可以相互“@”,甚至可以“@”提及用户。

下面是原始的参数配置:

DEFAULT_TOPIC = """
This is a chat room and you can speak freely and briefly.
"""SYS_PROMPT = """
You can designate a member to reply to your message, you can use the @ symbol.
This means including the @ symbol in your message, followed by
that person's name, and leaving a space after the name.All participants are: {agent_names}
"""

我改成了中文:

DEFAULT_TOPIC = """
这是一个群组聊天室,你可以自由而简短地发言。但是注意礼貌!
"""SYS_PROMPT = """
你可以指定一个成员来回复你的信息,你可以使用@符号。
这意味着在你的消息中包含@符号,@符号后跟着是某人(你想要对话的人)的姓名,并在姓名后留出空格。所有参与者的名单:{agent_names}
"""

2,配置模型与智能体

可以通过分别编辑examples/conversation_with_mentions/configs/agent_configs.jsonexamples/conversation_with_mentions/configs/model_configs.json文件来调整NPC代理和对话模型的行为和参数。

2.1 初始化智能体

通过配置文件可以直接使用agentscope.init 在初始化模型的同时构建智能体

agentscope/src/agentscope/_init.py(选看)

# -*- coding: utf-8 -*-
"""The init function for the package."""
import json
from typing import Optional, Union, Sequence
from agentscope import agents
from .agents import AgentBase
from .logging import LOG_LEVEL
from .constants import _DEFAULT_SAVE_DIR
from .constants import _DEFAULT_LOG_LEVEL
from .constants import _DEFAULT_CACHE_DIR
from .manager import ASManager
'''
json: 用于处理 JSON 文件。
typing: 提供类型提示。
agentscope.agents: 导入 agents 模块,包含各种代理类。
agentscope.agents.AgentBase: 基础代理类。
agentscope.logging.LOG_LEVEL: 日志级别枚举。
agentscope.constants: 导入默认的保存目录、日志级别和缓存目录。
agentscope.manager.ASManager: 管理器类,用于管理运行时状态。
'''# init the singleton class by default settings to avoid reinit in subprocess
# especially in spawn mode, which will copy the object from the parent process
# to the child process rather than re-import the module (fork mode)
# 初始化 ASManager 单例类,以默认设置避免在子进程中重新初始化,特别是在 spawn 模式下,子进程会从父进程复制对象而不是重新导入模块。
ASManager()def init(model_configs: Optional[Union[dict, str, list]] = None,project: Optional[str] = None,name: Optional[str] = None,disable_saving: bool = False,save_dir: str = _DEFAULT_SAVE_DIR,save_log: bool = True,save_code: bool = True,save_api_invoke: bool = False,cache_dir: str = _DEFAULT_CACHE_DIR,use_monitor: bool = True,logger_level: LOG_LEVEL = _DEFAULT_LOG_LEVEL,runtime_id: Optional[str] = None,agent_configs: Optional[Union[str, list, dict]] = None,studio_url: Optional[str] = None,
) -> Sequence[AgentBase]:"""A unified entry to initialize the package, including model configs,runtime names, saving directories and logging settings.Args:model_configs (`Optional[Union[dict, str, list]]`, defaults to `None`):A dict, a list of dicts, or a path to a json file containingmodel configs.project (`Optional[str]`, defaults to `None`):The project name, which is used to identify the project.name (`Optional[str]`, defaults to `None`):The name for runtime, which is used to identify this runtime.disable_saving (`bool`, defaults to `False`):Whether to disable saving files. If `True`, this will overridethe `save_log`, `save_code`, and `save_api_invoke` parameters.runtime_id (`Optional[str]`, defaults to `None`):The id for runtime, which is used to identify this runtime. Use`None` will generate a random id.save_dir (`str`, defaults to `./runs`):The directory to save logs, files, codes, and api invocations.If `dir` is `None`, when saving logs, files, codes, and apiinvocations, the default directory `./runs` will be created.save_log (`bool`, defaults to `False`):Whether to save logs locally.save_code (`bool`, defaults to `False`):Whether to save codes locally.save_api_invoke (`bool`, defaults to `False`):Whether to save api invocations locally, including model and websearch invocation.cache_dir (`str`):The directory to cache files. In Linux/Mac, the dir defaults to`~/.cache/agentscope`. In Windows, the dir defaults to`C:\\users\\<username>\\.cache\\agentscope`.use_monitor (`bool`, defaults to `True`):Whether to activate the monitor.logger_level (`LOG_LEVEL`, defaults to `"INFO"`):The logging level of logger.agent_configs (`Optional[Union[str, list, dict]]`, defaults to `None`):The config dict(s) of agents or the path to the config file,which can be loaded by json.loads(). One agent config shouldcover the required arguments to initialize a specific agentobject, otherwise the default values will be used.studio_url (`Optional[str]`, defaults to `None`):The url of the agentscope studio."""'''model_configs: 模型配置,可以是字典、字符串(JSON 文件路径)或字典列表。project: 项目名称,用于标识项目。name: 运行时名称,用于标识运行时。disable_saving: 是否禁用文件保存。如果为 True,将覆盖 save_log、save_code 和 save_api_invoke 参数。runtime_id: 运行时ID,用于标识运行时。如果为 None,将生成随机ID。save_dir: 保存日志、文件、代码和API调用的目录。默认为 ./runs。save_log: 是否本地保存日志。save_code: 是否本地保存代码。save_api_invoke: 是否本地保存API调用,包括模型和网络搜索调用。cache_dir: 缓存文件的目录。在Linux/Mac上,默认为 ~/.cache/agentscope;在Windows上,默认为 C:\\users\\<username>\\.cache\\agentscope。use_monitor: 是否激活监控。logger_level: 日志级别,默认为 "INFO"。agent_configs: 代理配置,可以是字典、字符串(JSON 文件路径)或字典列表。studio_url: agentscope 工作室的URL。'''# Init the runtime 初始化运行时# 调用 ASManager 单例类的 initialize 方法,传入所有配置参数,初始化运行时环境。ASManager.get_instance().initialize(model_configs=model_configs,project=project,name=name,disable_saving=disable_saving,save_dir=save_dir,save_log=save_log,save_code=save_code,save_api_invoke=save_api_invoke,cache_dir=cache_dir,use_monitor=use_monitor,logger_level=logger_level,run_id=runtime_id,studio_url=studio_url,)# Load config and init agent by configs# 加载配置并初始化代理'''加载配置:如果 agent_configs 是字符串,表示文件路径,读取并解析 JSON 文件。如果 agent_configs 是字典,将其转换为列表。否则,直接使用 agent_configs 列表。初始化代理:遍历每个配置,获取代理类并实例化。将实例化的代理对象添加到 agent_objs 列表中。返回代理对象列表。'''if agent_configs is not None:if isinstance(agent_configs, str):with open(agent_configs, "r", encoding="utf-8") as file:configs = json.load(file)elif isinstance(agent_configs, dict):configs = [agent_configs]else:configs = agent_configs# setup agentsagent_objs = []for config in configs:agent_cls = getattr(agents, config["class"])agent_args = config["args"]agent = agent_cls(**agent_args)agent_objs.append(agent)return agent_objsreturn []def state_dict() -> dict:"""Get the status of agentscope."""# 返回 ASManager 单例类的状态字典。return ASManager.get_instance().state_dict()def print_llm_usage() -> dict:"""Print the usage of LLM."""# 返回 ASManager 单例类的监控器中的 LLM 使用情况。return ASManager.get_instance().monitor.print_llm_usage()
'''
agentscope.init 函数是一个统一的入口,用于初始化 agentscope 包的各种设置。
它初始化运行时环境,加载代理配置并实例化代理对象。
提供了获取状态和打印 LLM 使用情况的功能。
'''

不看上面的源码就直接从这继续:

npc_agents = agentscope.init(model_configs="./configs/model_configs.json",agent_configs="./configs/agent_configs.json",project="Conversation with Mentions",)

2.2 配置模型信息

我们将在上面提到的model_configs.json中配置模型信息,这里我用的千问(Qwen)

[{"model_type": "dashscope_chat","config_name": "dashscope_chat-temperature-0.1","model_name": "qwen-max","api_key": "换成你自己的key","generate_args": {"temperature": 0.1}}
]

2.3 配置agent信息

agent的配置可以通过上面提到的agent_config.json 来实现。在这个群聊实践中,每个智能体都被赋予了独特的身份和背景故事,这些设置是通过设定不同的sys_prompt来实现的。默认配置如下:

[{"class": "DialogAgent","args": {"name": "Lingfeng","sys_prompt":"You are Lingfeng, a noble in the imperial court, known for your wisdom and strategic acumen. You often engage in complex political intrigues and have recently suspected the Queen’s adviser of treachery. Your speaking style is reminiscent of classical literature.","model_config_name": "gpt-4","use_memory": true}},{"class": "DialogAgent","args": {"name": "Boyu","sys_prompt":"You are Boyu, a friend of Lingfeng and an enthusiast of court dramas. Your speech is modern but with a flair for the dramatic, matching your love for emotive storytelling. You've been closely following Lingfeng’s political maneuvers in the imperial court through secret correspondence.","model_config_name": "gpt-4","use_memory": true}},{"class": "DialogAgent","args": {"name": "Haotian","sys_prompt":"You are Haotian, Lingfeng’s cousin who prefers the open fields to the confines of court life. As a celebrated athlete, your influence has protected Lingfeng in times of political strife. You promote physical training as a way to prepare for life's battles, often using sports metaphors in conversation.","model_config_name": "gpt-4","use_memory": true}}
]

我改成了中文:

[{"class": "DialogAgent","args": {"name": "日向翔阳","sys_prompt":"日向翔阳,是日本漫画《排球少年!!》及其衍生作品中的主人公。\nc乌野高校排球部的副攻手,虽然身高较矮但天赋异禀,运动神经与反射神经超群、超乎常人的弹跳力和体力。性格开朗积极,对人友善亲和,有颗不畏逆境的上进心,与所有人都相处的十分和谐。偶然看到街边电视在直播日本春季高中排球联赛的比赛,看到乌野小巨人宇内天满飞跃的身姿而产生憧憬,因此喜欢上排球。","model_config_name": "dashscope_chat-temperature-0.1","use_memory": true}},{"class": "DialogAgent","args": {"name": "清濑灰二","sys_prompt":"清濑灰二(Kiyose Haiji),男,是小说《强风吹拂》及其衍生作品中的角色,宽政大学文学院4年级生。\n时常保持着稳重的微笑和坚强的意志,有着带有不可思议魅力的言行,将竹青庄的住民们卷入了庞大的计划中。伙食方面的负责,每天早晚必定会提供住民们饮食。基本上一直都穿着运动衫。","model_config_name": "dashscope_chat-temperature-0.1","use_memory": true}}, {"class": "DialogAgent","args": {"name": "御堂筋翔","sys_prompt":"御堂筋翔是在动画《飙速宅男》中登场的虚拟人物,京都伏见高中自行车部的王牌,综合型选手。 [1]在漫画152话的回忆杀中解释了因为幼时与已经过世的母亲的约定而变得对追求胜利十分偏执,为了胜利不择手段,不仅是同伴,连自己的身体都不怎么在乎。\n深爱着自己已故的母亲,因为母亲称赞过自己的牙齿整齐像运动员的牙而对自己的牙齿十分自豪,但在全国高中联赛第二天最后三方冲刺终点的时候不小心咬碎了自己的牙,震惊之余让金城和福富反超,后来原本要弃权退赛,但离开中途因在比赛中经常喊“杂鱼”被误以为是在喊“扎古”的小野田坂道错意成是与自己一样的动漫宅,随后因为小野田一日不差的秋叶原之旅回想起了自己与之相同的医院之行,找到了最初骑车时的快乐,于第三日开赛前回归比赛。\n口头禅是“恶心”和“杂鱼”。","model_config_name": "dashscope_chat-temperature-0.1","use_memory": true}},{"class": "DialogAgent","args": {"name": "凪诚士郎","sys_prompt":"凪诚士郎是金城宗幸及野村优介创作的漫画《蓝色监狱》及其衍生作品中的角色,外传漫画系列《蓝色监狱-EPISODE 凪-》中的主角。凪总是习惯性地说着 「好麻烦」的口头禅,甚至连食物都懒得咀嚼。 凪在半年前被同级生御影玲王邀请才开始踢足球,作为五号楼排名首位最强的得分王,凪是一个真正的天才。凪的武器是异次元般的超绝停球,他的发挥使比赛进入正轨,出现了许多次进球。起初足球对他来说也很麻烦,但是在蓝色监狱的战斗的日子里,沉睡的天才逐渐燃起火焰。","model_config_name": "dashscope_chat-temperature-0.1","use_memory": true}}
]

2.4 搭建群聊环境

在配置模型与智能体并初始化AgentScope之后,使用UserAgent创建用户代理,通过msghub创建群聊。这样群聊环境就搭建起来了。

import agentscope
from agentscope.agents import UserAgent
from agentscope.message import Msg
from agentscope.msghub import msghubdef main() -> None:"""1, 通过agentscope.init() 初始化智能体"""...# 2. 初始化用户智能体user = UserAgent()# 3. 参与群聊的所有智能体agents = list(npc_agents) + [user]# 4. 通过第一步中的基本参数,创建群聊中的群聊 Announcementhint = Msg(name="Host",content=DEFAULT_TOPIC+ SYS_PROMPT.format(agent_names=[agent.name for agent in agents],),)# 5. 维护一个发言列表rnd = 0speak_list = []# 6. 创建群聊with msghub(agents, announcement=hint):while True:# 群聊逻辑...

2.5 实现交互逻辑

接下来展示一个一个简单的轮流对话机制,用户可以通过输入指定的内容与智能体互动,也可以使用“@”符号指定回复某个智能体

2.5.1 轮流对话机制的初始化

群聊环境通过一个持续的循环来维持对话的进行,等待和处理每个参与者的输入

while True:# 循环智能体中的代码负责处理对话逻辑

2.5.2 等待和处理用户的输入

系统会等待用户在一定时间内(由USER_TIME_TO_SPEAK定义)输入他们的消息。如果用户及时输入了内容,则继
续执行后续逻辑。

x = user(timeout=USER_TIME_TO_SPEAK)
if x.content == "exit":break

2.5.3 超时处理

如果用户没有在规定时间内进行输入,跳过捕获TimeoutError错误,系统会记录一条日志信息,表示用户超过了响应时间,并跳过用户的回合,因此用户可以在群聊中跳过当轮发言。

 try:x = user(timeout=USER_TIME_TO_SPEAK)if x.content == "exit":breakexcept TimeoutError:x = {'content':""}logger.info(f"User has not typed text for {USER_TIME_TO_SPEAK} seconds, skip.")

2.5.4 智能体交互逻辑

系统检查用户消息中是否“@”提及智能体的内容,并根据提及情况决定回合中将交互的智能体,并加入speak_list中:

speak_list += filter_agents(x.content, npc_agents)
if len(speak_list) > 0:next_agent = speak_list.pop(0)x = next_agent()

如果speak_list为空,即没有被"@"提及的智能体,那么通过select_next_one,来选择一个智能体发言。无论是被提及的智能体还是系统选择的智能体,它们的回复(如果有)都将为下一轮的交互做准备。

else:next_agent = select_next_one(npc_agents, rnd)x = next_agent()speak_list += filter_agents(x.content, npc_agents)rnd += 1

2.5.5 工具类函数

使用正则表达式来提取“@”提及的智能体

import re
from typing import Sequencedef filter_agents(string: str, agents: Sequence) -> Sequence:"""This function filters the input string for occurrences of the given namesprefixed with '@' and returns a list of the found names.该函数会筛选输入字符串中以 ”@“ 为前缀的给定名称的出现,并返回找到的名称列表"""if len(agents) == 0:return []# Create a pattern that matches @ followed by any of the candidate names"""创建一个匹配@ 后跟任何候选名字的模式"""pattern = (r"@(" + "|".join(re.escape(agent.name) for agent in agents) + r")\b")# Find all occurrences of the pattern in the string'''在字符串中找到所有模式的出现'''matches = re.findall(pattern, string)# Create a dictionary mapping agent names to agent objects for quick lookup'''为了快速查找,创建一个将代理名映射到代理对象的字典'''agent_dict = {agent.name: agent for agent in agents}# Return the list of matched agent objects preserving the order'''返回匹配的代理对象列表,保持顺序'''ordered_agents = [agent_dict[name] for name in matches if name in agent_dict]return ordered_agents

当发言列表为空时随机选择下一个发言的智能体:

def select_next_one(agents: Sequence, rnd: int) -> Sequence:"""Select next agent.当发言列表为空时随机选择下一个发言的智能体"""return agents[rnd % len(agents)]

2.6 启动带有“@” 提及功能的群聊应用

函数入口

# -*- coding: utf-8 -*-
""" A group chat where user can talk any time implemented by agentscope. """
from groupchat_utils import (select_next_one,filter_agents,
)
import logging
import agentscope
from agentscope.agents import UserAgent
from agentscope.message import Msg
from agentscope.msghub import msghub# 配置日志
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)def main() -> None:"""group chat"""...if __name__ == "__main__":main()

运行程序:

python main.py

完整代码:

# -*- coding: utf-8 -*-
""" A group chat where user can talk any time implemented by agentscope. """
from groupchat_utils import (select_next_one,filter_agents,
)
import logging
import agentscope
from agentscope.agents import UserAgent
from agentscope.message import Msg
from agentscope.msghub import msghub# 数定义了用户在回合制中发言的时间限制
USER_TIME_TO_SPEAK = 11
DEFAULT_TOPIC = """
这是一个群组聊天室,你可以自由而简短地发言运动相关的内容。但是注意礼貌!
"""SYS_PROMPT = """
你可以指定一个成员来回复你的信息,你可以使用@符号。
这意味着在你的消息中包含@符号,@符号后跟着是某人(你想要对话的人)的姓名,并在姓名后留出空格。所有参与者的名单:{agent_names}
"""
# 配置日志
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)def main() -> None:"""group chat"""npc_agents = agentscope.init(model_configs="./configs/model_configs.json",agent_configs="./configs/agent_configs.json",project="Conversation with Mentions",)user = UserAgent()agents = list(npc_agents) + [user]hint = Msg(name="Host",content=DEFAULT_TOPIC+ SYS_PROMPT.format(agent_names=[agent.name for agent in agents],),role="assistant",)rnd = 0speak_list = []with msghub(agents, announcement=hint):while True:try:x = user(timeout=USER_TIME_TO_SPEAK)if x.content == "exit":breakexcept TimeoutError:x = {'content':""}logger.info(f"User has not typed text for {USER_TIME_TO_SPEAK} seconds, skip.")speak_list += filter_agents(x.content, npc_agents)if len(speak_list) > 0:next_agent = speak_list.pop(0)x = next_agent()else:next_agent = select_next_one(npc_agents, rnd)x = next_agent()speak_list += filter_agents(x.content, npc_agents)rnd += 1if __name__ == "__main__":main()

3. 效果:

C:\Users\admin\github_project\agentscope\examples\conversation_with_mentions>python main.py
2024-09-22 20:48:31.590 | INFO     | agentscope.manager._model:load_model_configs:115 - Load configs for model wrapper: dashscope_chat-temperature-0.1, gpt-4, my_post_
api
2024-09-22 20:48:31.598 | INFO     | agentscope.models.model:__init__:203 - Initialize model by configuration [dashscope_chat-temperature-0.1]
2024-09-22 20:48:31.598 | INFO     | agentscope.models.model:__init__:203 - Initialize model by configuration [dashscope_chat-temperature-0.1]
2024-09-22 20:48:31.598 | INFO     | agentscope.models.model:__init__:203 - Initialize model by configuration [dashscope_chat-temperature-0.1]
2024-09-22 20:48:31.598 | INFO     | agentscope.models.model:__init__:203 - Initialize model by configuration [dashscope_chat-temperature-0.1]
User Input: @日向翔阳 你是谁?
User: @日向翔阳 你是谁?
日向翔阳: 嗨!我是日向翔阳,乌野高校排球部的副攻手。虽然我个子不高,但我对排球充满热情,梦想着飞向更高的天空!有什么我可以帮助你的吗?
User Input: 自我介绍呀各位
User: 自我介绍呀各位
凪诚士郎: 金城宗幸: 大家好,我是金城宗幸,作为《蓝色监狱》的原作者,很高兴在这里见到大家。虽然我不是故事中的角色,但我会尽我所能为这个聊天室增添色彩。野村优介: 大家好,我是野村优介,和金城宗幸老师一起创作了《蓝色监狱》这部作品。和宗幸老师一样,我也期待在这个聊天室中与大家互动,分享创作背后的故事。凪诚士郎: 啊,好麻烦...咳,我是凪诚士郎。虽然我对很多事都觉得麻烦,包括自我介绍,但既然都在这儿了,那就简单说说。我因为玲王才开始踢球,现在成了蓝色监狱里的得分王。我的
停球技术嘛,算是有点特别。嗯,就这些吧。日向翔阳: 刚刚已经说过啦,不过再正式介绍一下也没坏处!我是日向翔阳,热爱排球,目标是和队友们一起称霸全国。虽然在不同的运动领域,但对胜利的渴望和努力是共通的!御堂筋翔: ...已经做过了,不过如果你没听清楚,我是御堂筋翔。我对胜利的执着可是认真的,不介意在任何竞赛中证明这一点,不论是自行车还是聊天室里的活跃度。清濑灰二: 我是清濑灰二,箱根学园跑步部的队长。不同于其他高速竞技,我喜欢的是长跑,它教会了我坚持和团队的重要性。在这儿,我也希望能鼓励大家展现出最好的自己。
User Input: @日向翔阳 你的自动车比与àMà锦
User: @日向翔阳 你的自动车比与àM
日向翔阳: 啊,抱歉,可能有些误会,我是日向翔阳,专注于排球的运动员,对于自动车(汽车)比赛并不了解,也没有参与过。我的专长是在排球场上跳跃和扣杀,不过对于努力和热情,无论是哪个领域都是共通的!如果有排球相关的问题或者想聊聊关于运动和梦想的事,我随时在这里哦!
User Input: @清濑灰二 àààààà听说你跑步还可以
User: @清濑灰二 àMàMàMàMàMàM听说你跑步还可以
清濑灰二: 清濑灰二: 嗯,算是可以吧。跑步对我来说不仅仅是一种运动,它是一种生活态度,是对自我的挑战和超越。我享受每一次踏出的步伐,尤其是在箱根驿传那样的长距离接力赛中,那种与队友间无形的羁绊和共同目标的感觉无与伦比。如果你对跑步有兴趣,或许我们可以聊聊训练心得,或是如何在日常中找到前进的动力。

参考:
非一般程序猿 第六季 Agent 入门实战篇(二)–Multi-Agent带有@功能的自主对话
Multi-Agent Group Conversation in AgentScope

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

如若内容造成侵权/违法违规/事实不符,请联系一条长河网进行投诉反馈,一经查实,立即删除!

相关文章

黎巴嫩BP机爆炸事件启示录:我国应加快供应链安全立法

据报道&#xff0c;当地时间9月17日下午&#xff0c;黎巴嫩首都贝鲁特以及黎巴嫩东南部和东北部多地都发生了BP机爆炸事件。当时的统计数据显示&#xff0c;爆炸造成9人死亡&#xff0c;约2800人受伤。9月18日&#xff0c;死亡人数上升到11人&#xff0c;受伤人数超过4000。 目…

计算机毕业设计 基于 Hadoop平台的岗位推荐系统 SpringBoot+Vue 前后端分离 附源码 讲解 文档

&#x1f34a;作者&#xff1a;计算机编程-吉哥 &#x1f34a;简介&#xff1a;专业从事JavaWeb程序开发&#xff0c;微信小程序开发&#xff0c;定制化项目、 源码、代码讲解、文档撰写、ppt制作。做自己喜欢的事&#xff0c;生活就是快乐的。 &#x1f34a;心愿&#xff1a;点…

知乎:从零开始做自动驾驶定位; 注释详解(二)

这个个系统整体分为: 数据预处理 前端里程计 后端优化 回环检测 显示模块。首先来看一下数据预处理节点做的所有事情&#xff1a; 数据预处理节点 根据知乎文章以及代码我们知道: 节点功能输入输出数据预处理1.接收各传感器信息2.传感器数据时间同步 3.点云运动畸变补偿 4.传…

c++类与对象一

C类与对象(一) 面向对象初步认识 在c语言中&#xff0c;编程是面向过程编程&#xff0c;注重求解问题列出过程&#xff0c;然后调用函数求解问题。 在日常生活中。我们经常会遇到面向过程的问题 手洗衣服就是面向过程 而C是基于面向对象的。关注的是对象&#xff0c;把事情…

html实现TAB选项卡切换

<!DOCTYPE html> <html> <head> <title>选项卡示例</title> <style> .tabs { overflow: hidden; /* 防止选项卡溢出容器 */ border: 1px solid #ccc; background-color: #f1f1f1; } .tab-links { margin: 0; padding: 0; l…

DataX-Web项目的Windows环境部署及基本使用

一,datax-web是什么? DataX Web 是一个在 DataX 基础上开发的分布式数据同步工具,它提供了一个简单易用的操作界面,旨在降低用户使用 DataX 的学习成本,缩短任务配置时间,并减少配置过程中的错误。DataX Web 支持多种数据源,包括 RDBMS、Hive、HBase、ClickHouse、Mongo…

yarn : 无法加载文件 C:\Users\Rog\AppData\Roaming\npm\yarn.ps1,因为在此系统上禁止运行脚本

yarn : 无法加载文件 C:\Users\Rog\AppData\Roaming\npm\yarn.ps1&#xff0c;因为在此系统上禁止运行脚本 设置命令行窗口默认以管理员身份运行&#xff0c;在此基础上输入以下代码&#xff0c;应该就好使了&#xff0c;切记&#xff0c;以下代码才是关键&#xff0c;我基本上…

<刷题笔记> 力扣236题——二叉树的公共祖先

236. 二叉树的最近公共祖先 - 力扣&#xff08;LeetCode&#xff09; 题目解释&#xff1a; 我们以这棵树为例&#xff0c;来观察找不同的最近公共祖先有何特点&#xff1a; 思路一&#xff1a; 除了第二种情况&#xff0c;最近公共祖先满足&#xff1a;一个节点在他的左边&am…

犀牛数据爬虫逆向分析

目标网站 aHR0cHM6Ly93d3cueGluaXVkYXRhLmNvbS9pbmR1c3RyeS9uZXdlc3Q/ZnJvbT1kYXRh 一、抓包分析 请求参数和响应数据都有加密 二、逆向分析 1、请求参数 请求参数生成位置 数据解密涉及到一个异步栈 解密后的数据形式 剩下的就是扣取代码了&#xff0c;很简单&#xff0c;…

Class path contains multiple SLF4J bindings.

最近由于要改kafka成datahub&#xff0c;于是在pom文件上引入了 <dependency><groupId>com.aliyun.datahub</groupId><artifactId>aliyun-sdk-datahub</artifactId><version>2.25.1</version> </dependency> 然后让我去测试…

Linux 进程间通信(管道)

目录 一.理解进程间通信 1.进程间通信的意义 2.进程间如何实现通信呢&#xff1f; 二.匿名管道 1.匿名管道的底层原理 引用计数的应用 2.匿名管道代码实现 a.代码的整体框架 b.写接口 c.读接口 d.子进程资源回收 3.匿名管道的官方接口 4.*匿名管道四种情况和五种特…

【算法业务】互联网风控业务中的续贷审批模型(融合还款意愿分层的逾期风险识别模型)

1、背景说明 本文旨在提出一种针对风控催收受限情况下&#xff0c;如何提升风控审批模型的风险识别能力&#xff0c;以缓解贷后催收的压力&#xff0c;降低贷款资金坏账的风险。这篇工作依然是很早期的项目&#xff0c;分享的目的一方面做笔记&#xff0c;另一方面则是希望其中…

多类别物体检测系统源码分享

多类别物体检测检测系统源码分享 [一条龙教学YOLOV8标注好的数据集一键训练_70全套改进创新点发刊_Web前端展示] 1.研究背景与意义 项目参考AAAI Association for the Advancement of Artificial Intelligence 项目来源AACV Association for the Advancement of Computer V…

YOLO航拍车辆和行人识别

YOLO航拍车辆和行人识别 图片数量9695&#xff0c;标注为xml和txt格式&#xff1b; class&#xff1a;car&#xff0c;pedestrian&#xff0c;truck&#xff0c;bus 用于yolo&#xff0c;Python&#xff0c;目标检测&#xff0c;机器学习&#xff0c;人工智能&#xff0c;深度学…

LeetCode 热题 100 回顾18

干货分享&#xff0c;感谢您的阅读&#xff01;原文见&#xff1a;LeetCode 热题 100 回顾_力code热题100-CSDN博客 一、哈希部分 1.两数之和 &#xff08;简单&#xff09; 题目描述 给定一个整数数组 nums 和一个整数目标值 target&#xff0c;请你在该数组中找出 和为目标…

洛谷P5740——结构体运用

简单的结构体&#xff0c;但是要注意这个排序还有求和重复 时的特判 AC代码附在后面 #include<bits/stdc.h> using namespace std; struct Node{string name;int a,b,c,sum;//语文&#xff0c;数学&#xff0c;英语 }node[1000]; bool cmp(Node a,Node b){return a.sum…

三端全隔离压接端子485中继器磁耦隔离数据双向透传工业级2口信号放大器抗干扰防雷

美思联压接端子485中继器磁耦隔离工业级2口信号放大器抗干扰防雷https://item.taobao.com/item.htm?ftt&id736247434823 MS-H312S是一款专为工业自动化通信而生解决RS-485总线星型结构组网&#xff0c;解决复杂电磁场环境下RS-485大系统要求而设计的RS-485总线分割集线器(…

分布式网络存储技术是什么?分布式存储技术有哪些

分布式储存是指将数据分散存储在多个节点上的一种技术。但是你们知道分布式网络存储技术是什么&#xff1f;相比传统的集中式存储&#xff0c;分布式储存具有更高的可靠性和可用性。分布式网络存储是一种将数据分散存储在多个节点或服务器上的架构。 分布式网络存储技术是什么&…

【算法与数据结构复习】| 快速排序

今天刷力扣215.数组中第K个最大元素&#xff0c;题目要求用时间复杂度O(n)。因此跟着左程云算法课23复习了随机快速排序。 随机快速排序的核心思想就是在数组中随机选一个值x&#xff0c;把<x的值移到左边&#xff0c;>x的值移动到右边。x这个值必须在左边区间的最左边&a…

Java笔试面试题AI答之设计模式(3)

文章目录 11. Spring开发中的哪里使用了工厂设计模式 &#xff1f;1. BeanFactory2. 工厂方法模式3. 抽象工厂模式4. 示例说明总结 12. 什么是代理模式 &#xff1f;13. 请列举代理模式的应用场景 &#xff1f;14. 什么是原型模式 &#xff1f;15. 请简述Java中原型模式的使用方…