langchain 实现多智能体多轮对话

这里写目录标题

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

工具定义

import random
from typing import Annotated, Literal

from 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 graph
            goto=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 state
    response = 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, Image

display(Image(graph.get_graph().draw_mermaid_png()))

在这里插入图片描述

graph 运行

import uuid

thread_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/

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

pytorch生成对抗网络

人工智能例子汇总:AI常见的算法和例子-CSDN博客 生成对抗网络(GAN,Generative Adversarial Network)是一种深度学习模型,由两个神经网络组成:生成器(Generator)和判别器&#xff0…

ui-automator定位官网文档下载及使用

一、ui-automator定位官网文档简介及下载 AndroidUiAutomator:移动端特有的定位方式,uiautomator是java实现的,定位类型必须写成java类型 官方地址:https://developer.android.com/training/testing/ui-automator.html#ui-autom…

RabbitMQ持久化队列配置修改问题

文章目录 1.问题产生2.问题解决1.询问gpt2.独立思考 1.问题产生 我在给一个普通队列去绑定死信交换机和死信队列的时候,发现总是报错x-dead-letter-exchange的属性为none ERROR [PFTID:] [Module:defaultModule] org.springframework.amqp.rabbit.connection.Cach…

MySQL常用数据类型和表的操作

文章目录 (一)常用数据类型1.数值类2.字符串类型3.二进制类型4.日期类型 (二)表的操作1查看指定库中所有表2.创建表3.查看表结构和查看表的创建语句4.修改表5.删除表 (三)总代码 (一)常用数据类型 1.数值类 BIT([M]) 大小:bit M表示每个数的位数,取值范围为1~64,若…

OpenCV:图像轮廓

目录 简述 1. 什么是图像轮廓? 2. 查找图像轮廓 2.1 接口定义 2.2 参数说明 2.3 代码示例 2.4 运行结果 3. 绘制图像轮廓 3.1 接口定义 3.2 参数说明 3.3 代码示例 3.4 运行结果 4. 计算轮廓周长 5. 计算轮廓面积 6. 示例:计算图像轮廓的面…

C++哈希(链地址法)(二)详解

文章目录 1.开放地址法1.1key不能取模的问题1.1.1将字符串转为整型1.1.2将日期类转为整型 2.哈希函数2.1乘法散列法(了解)2.2全域散列法(了解) 3.处理哈希冲突3.1线性探测(挨着找)3.2二次探测(跳…

记6(人工神经网络

目录 1、M-P神经元2、感知机3、Delta法则4、前馈型神经网络(Feedforward Neural Networks)5、鸢尾花数据集——单层前馈型神经网络:6、多层神经网络:增加隐含层7、实现异或运算(01、10为1,00、11为0)8、线性…

增删改查(CRUD)操作

文章目录 MySQL系列:1.CRUD简介2.Create(创建)2.1单行数据全列插入2.2 单行数据指定插入2.3 多⾏数据指定列插⼊ 3.Retrieve(读取)3.1 Select查询3.1.1 全列查询3.1.2 指定列查询3.1.3 查询字段为表达式(都是临时表不会对原有表数据产生影响)…

python 语音识别

目录 一、语音识别 二、代码实践 2.1 使用vosk三方库 2.2 使用SpeechRecognition 2.3 使用Whisper 一、语音识别 今天识别了别人做的这个app,觉得虽然是个日记app 但是用来学英语也挺好的,能进行语音识别,然后矫正语法,自己说的时候 ,实在不知道怎么说可以先乱说,然…

openssl 生成证书 windows导入证书

初级代码游戏的专栏介绍与文章目录-CSDN博客 我的github:codetoys,所有代码都将会位于ctfc库中。已经放入库中我会指出在库中的位置。 这些代码大部分以Linux为目标但部分代码是纯C的,可以在任何平台上使用。 源码指引:github源…

深度学习编译器的演进:从计算图到跨硬件部署的自动化之路

第一章 问题的诞生——深度学习部署的硬件困境 1.1 计算图的理想化抽象 什么是计算图? 想象你正在组装乐高积木。每个积木块代表一个数学运算(如加法、乘法),积木之间的连接代表数据流动。深度学习框架正是用这种"积木拼接…

Agentic Automation:基于Agent的企业认知架构重构与数字化转型跃迁---我的AI经典战例

文章目录 Agent代理Agent组成 我在企业实战AI Agent企业痛点我构建的AI Agent App 项目开源 & 安装包下载 大家好,我是工程师令狐,今天想给大家讲解一下AI智能体,以及企业与AI智能体的结合,文章中我会列举自己在企业中Agent实…

论文阅读:Realistic Noise Synthesis with Diffusion Models

这篇文章是 2025 AAAI 的一篇工作,主要介绍的是用扩散模型实现对真实噪声的仿真模拟 Abstract 深度去噪模型需要大量来自现实世界的训练数据,而获取这些数据颇具挑战性。当前的噪声合成技术难以准确模拟复杂的噪声分布。我们提出一种新颖的逼真噪声合成…

Baklib揭示内容中台与人工智能技术的创新协同效应

内容概要 在当今信息爆炸的时代,内容的高效生产与分发已成为各行业竞争的关键。内容中台与人工智能技术的结合,为企业提供了一种新颖的解决方案,使得内容创造的流程更加智能化和高效化。 内容中台作为信息流动的核心,能够集中管…

Spring Boot 中的事件发布与监听:深入理解 ApplicationEventPublisher(附Demo)

目录 前言1. 基本知识2. Demo3. 实战代码 前言 🤟 找工作,来万码优才:👉 #小程序://万码优才/r6rqmzDaXpYkJZF 基本的Java知识推荐阅读: java框架 零基础从入门到精通的学习路线 附开源项目面经等(超全&am…

DeepSeek 第二弹:Janus-Pro 文生图模型

最近,DeepSeek 可谓是科技圈的焦点,还火出了圈外,掀起了一场全民创作热潮。大家纷纷借助 DeepSeek R1 挥洒才情,实现诗人、小说家的梦想。然而,就在这场文字狂欢之际,DeepSeek 又悄然推出了一款重磅产品——…

leetcode 2563. 统计公平数对的数目

题目如下 数据范围 显然数组长度最大可以到10的5次方n方的复杂度必然超时,阅读题目实际上就是寻找两个位置不同的数满足不等式即可(实际上i j无所谓是哪个 我们只要把位置小的想成i就行)。 按照上面的思路我们只需要排序数组然后从前往后遍历数组然后利用二分查找…

2024第十五届蓝桥杯网安赛道省赛题目--cc(CyberChef)/crypto

打开链接后是: 通过题目界面可以知道是AES加密,并且告诉我们key是gamelabgamelab,IV是gamelabgamelab,Mode是CBC模式,输入是flag,输出为Hex十六进制4da72144967f1c25e6273950bf29342aae635e2396ae17c80b1b…

【视频+图文详解】HTML基础4-html标签的基本使用

图文教程 html标签的基本使用 无序列表 作用&#xff1a;定义一个没有顺序的列表结构 由两个标签组成&#xff1a;<ul>以及<li>&#xff08;两个标签都属于容器级标签&#xff0c;其中ul只能嵌套li标签&#xff0c;但li标签能嵌套任何标签&#xff0c;甚至ul标…

Python-基于PyQt5,wordcloud,pillow,numpy,os,sys等的智能词云生成器

前言&#xff1a;日常生活中&#xff0c;我们有时后就会遇见这样的情形&#xff1a;我们需要将给定的数据进行可视化处理&#xff0c;同时保证呈现比较良好的量化效果。这时候我们可能就会用到词云图。词云图&#xff08;Word cloud&#xff09;又称文字云&#xff0c;是一种文…