协程在多个模型流式输出中的使用实例

python 协程
python 生成器的作用
协程在多个模型流式输出中的使用实例

继续学习:
https://www.cnblogs.com/traditional/p/17398542.html
https://blog.csdn.net/m0_51180924/article/details/124612738

fastapi 并发

使用 fastapi api 的形式处理任务,每个任务使用协程的方式,处理多个流式输出。
该方式支持多个 fastapi 并发请求。

服务端

import json
from fastapi import FastAPI, Query, Path
import uvicorn
from starlette.requests import Request
from sse_starlette import EventSourceResponseimport asyncio
from asyncio import Queueapp = FastAPI()@app.get("/v1/models")
async def get_models():data = {"data": [{"id": "Qwen1.5-7B",						# openai 支持模型id"object": "model",					    # openai 支持模型类别"owned_by": "organization-owner",	    # openai 支持模型所有者"permission": []						# openai 支持模型权限,暂时不支持},{"id": "chatglm3-6b","object": "model","owned_by": "organization-owner","permission": []}],"object": "list"							# data 类型}return dataasync def output_data(text: str, model: str):output = ""for idx, word in enumerate(text):output += wordchunk = {"id": None,"choices": [{"delta": {"content": f"{model} {idx} {output}","function_call": None, 					# OpenAI返回,未知"role": "assistant",					# OpenAI系统消息角色"tool_calls": None						# OpenAI返回,未知},"finish_reason": "length",					# OpenAI停止码"index": 0,								    # OpenAI返回,未知"logprobs": None							# OpenAI返回,未知}],"created": 1715238637, 						    # 时间戳"model": model,							        # OpenAI模型id"object": "chat.completion.chunk",				# OpenAI消息类型"system_fingerprint": None						# OpenAI返回,未知}data = json.dumps(chunk, ensure_ascii=False)yield dataawait asyncio.sleep(1)@app.post("/v1/chat/completions")
async def flush_stream(request: Request):models = ["chatglm3", "qwen"]async def async_generate(index:int, model: str, queue: Queue):text = "这是一个流式输出他会将每个字挨个的输出哈哈!!!"if model == "chatglm3":text = "我是chatglm3的流式输出嘿嘿!!!"items_data = output_data(text=text, model=model)async for item_data in items_data:# print(f"generate### {model} {item_data}")# yield item_dataqueue.put_nowait((index, item_data))queue.put_nowait((index, None))async def async_consumer(queue: Queue, indices: list, timeout: float):indices = set(indices)finished = set()while indices != finished:try:index, response = await asyncio.wait_for(queue.get(), timeout)if response is None:finished.add(index)print("consumer queue indices finished", indices, finished)yield (index, response)except TimeoutError:breakasync def async_process(models: list):### 1. 支持多个模型的流式输出queue = Queue()tasks = [asyncio.create_task(async_generate(index=index, model=model, queue=queue))for index, model in enumerate(models)]print("###################", tasks)all_text = [dict() for _ in range(len(models))]async for index, response in async_consumer(queue=queue, indices=list(range(len(tasks))), timeout=10):if response is not None:all_text[index] = responseprint(f"thread00000_master###{all_text}")res_text = json.dumps(all_text)+"\n"yield res_textprint(f"thread00000_master ENDENDENDEND")# async def async_process(models: list):#     ### 2.支持单个模型的流式输出#     text = "这是一个流式输出他会将每个字挨个的输出哈哈!!!"#     items_data = output_data(text=text, model=models[0])#     async for item_data in items_data:#         yield item_datareturn EventSourceResponse(async_process(models), media_type="text/event-stream")# return EventSourceResponse(async_process(models), media_type="text/plain")if __name__ == '__main__':uvicorn.run(app, host="0.0.0.0", port=8080)

运行:

> python.exe .\main.py
INFO:     Started server process [12872]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
INFO:     127.0.0.1:64346 - "POST /v1/chat/completions HTTP/1.1" 200 OK
process ####### ['{"id": null, "choices": [{"delta": {"content": "chatglm3 0 我", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "chatglm3", "object": "chat.completion.chunk", "system_fingerprint": null}', {}]
process ####### ['{"id": null, "choices": [{"delta": {"content": "chatglm3 0 我", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "chatglm3", "object": "chat.completion.chunk", "system_fingerprint": null}', '{"id": null, "choices": [{"delta": {"content": "qwen 0 这", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "qwen", "object": "chat.completion.chunk", "system_fingerprint": null}']
......
process ####### ['{"id": null, "choices": [{"delta": {"content": "chatglm3 19 我是chatglm3的流式输出嘿嘿!!!", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "chatglm3", "object": "chat.completion.chunk", "system_fingerprint": null}', '{"id": null, "choices": [{"delta": {"content": "qwen 23 这是一个流式输出他会将每个字挨个的输出哈哈!!!", "function_call": null, "role": "assistant", 
"tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "qwen", "object": "chat.completion.chunk", "system_fingerprint": null}']
consumer queue indices finished {0, 1} {0, 1}
process END END

客户端

from openai import OpenAIclient = OpenAI(api_key="EMPTY",base_url="http://127.0.0.1:8080/v1/")
response = client.chat.completions.create(model="EMPTY",messages=[# {"role": "system", "content": "You are a helpful assistant."},{"role": "user", "content": "你好"}# {"role": "user", "content": "谁是特朗普"},# {"role": "assistant", "content": "特朗普是美国前总统"},# {"role": "user", "content": "特朗普多大年纪了"},],functions=None,temperature=1,top_p=0,max_tokens=20,stream=True,)print("#####", response)
ret_text = ""
for part in response:# print("\n33333", type(part), part)print("\n33333", type(part), part[0])print("33333", type(part), part[1])

运行:

> python.exe .\stream.py
##### <openai.Stream object at 0x0000024D1C322590>33333 <class 'list'> {"id": null, "choices": [{"delta": {"content": "chatglm3 0 我", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "chatglm3", "object": "chat.completion.chunk", "system_fingerprint": null}
33333 <class 'list'> ChatCompletionChunk(id=None, choices=None, created=None, model=None, object=None, service_tier=None, system_fingerprint=None, usage=None)        33333 <class 'list'> {"id": null, "choices": [{"delta": {"content": "chatglm3 0 我", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "chatglm3", "object": "chat.completion.chunk", "system_fingerprint": null}
33333 <class 'list'> {"id": null, "choices": [{"delta": {"content": "qwen 0 这", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "qwen", "object": "chat.completion.chunk", "system_fingerprint": null}
......33333 <class 'list'> {"id": null, "choices": [{"delta": {"content": "chatglm3 19 我是chatglm3的流式输出嘿嘿!!!", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "chatglm3", "object": "chat.completion.chunk", "system_fingerprint": null}
33333 <class 'list'> {"id": null, "choices": [{"delta": {"content": "qwen 23 这是一个流式输出他会将每个字挨个的输出哈哈!!!", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "qwen", "object": "chat.completion.chunk", "system_fingerprint": null}

多线程执行任务

开启多个线程执行任务,每个任务使用协程的方式,处理多个流式输出。

服务端

import json
from fastapi import FastAPI, Query, Path
import uvicorn
from starlette.requests import Request
from sse_starlette import EventSourceResponseimport asyncio
from asyncio import Queueimport time
from threading import Threadapp = FastAPI()@app.get("/v1/models")
async def get_models():......async def output_data(text: str, model: str):output = ""for idx, word in enumerate(text):output += wordchunk = {"id": None,"choices": [{"delta": {"content": f"{model} {idx} {output}","function_call": None, 					# OpenAI返回,未知"role": "assistant",					# OpenAI系统消息角色"tool_calls": None						# OpenAI返回,未知},"finish_reason": "length",					# OpenAI停止码"index": 0,								    # OpenAI返回,未知"logprobs": None							# OpenAI返回,未知}],"created": 1715238637, 						    # 时间戳"model": model,							        # OpenAI模型id"object": "chat.completion.chunk",				# OpenAI消息类型"system_fingerprint": None						# OpenAI返回,未知}data = json.dumps(chunk, ensure_ascii=False)yield dataawait asyncio.sleep(1)@app.post("/v1/chat/completions")
async def flush_stream(request: Request):......async def async_task(task_name: str, models: list):async def task_generate(task_name: str, model: str):text = f"这是{model}模型的流式输出他会将每个字挨个的输出哈哈!!!"# if model == "chatglm3":#     text = "我是chatglm3的流式输出嘿嘿!!!"items_data = output_data(text=text, model=model)output = ""async for item_data in items_data:print(f"{task_name}### {model} {item_data}")# yield item_data# queue.put_nowait((index, item_data))output = item_data# queue.put_nowait((index, None))return output# results = await asyncio.gather(task_generate("chatglm3"), task_generate("qwen1.5"))results = await asyncio.gather(*[task_generate(task_name=task_name, model=model)for model in models])print(f"{task_name} ENDENDENDEND {results}")def task_thread(thread_name: str):print("另外开始一个子线程做任务啦", thread_name)models = ["model11111", "model22222"]# 1. 只执行一次任务# asyncio.run(async_task(thread_name, models))# 2. 可以执行多此任务count = 0flag = Truewhile True:# 执行任务if flag:task_name = f"{thread_name}_task"asyncio.run(async_task(task_name, models))flag = False# 没有任务等待time.sleep(1)print(f"{thread_name} count:{count}")count+=1print("子线程任务结束啦", thread_name)if __name__ == '__main__':# 1. 批量线程创建thread_names = ["thread11111", "thread22222", "thread33333"]threads = [Thread(target=task_thread, args=(thread_name,)).start()for thread_name in thread_names]# 2. 逐个线程创建# t1 = Thread(target=task, args=("task11111",))# t1.start()# time.sleep(1)# t2 = Thread(target=task, args=("task22222",))# t2.start()uvicorn.run(app, host="0.0.0.0", port=8080)

运行:

> python.exe .\main.py
另外开始一个子线程做任务啦 thread11111
另外开始一个子线程做任务啦 thread22222
另外开始一个子线程做任务啦 thread33333
thread22222_task### model11111 {"id": null, "choices": [{"delta": {"content": "model11111 0 这", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model11111", "object": "chat.completion.chunk", "system_fingerprint": null}
thread33333_task### model11111 {"id": null, "choices": [{"delta": {"content": "model11111 0 这", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model11111", "object": "chat.completion.chunk", "system_fingerprint": null}
thread33333_task### model22222 {"id": null, "choices": [{"delta": {"content": "model22222 0 这", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model22222", "object": "chat.completion.chunk", "system_fingerprint": null}
thread22222_task### model22222 {"id": null, "choices": [{"delta": {"content": "model22222 0 这", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model22222", "object": "chat.completion.chunk", "system_fingerprint": null}
thread11111_task### model11111 {"id": null, "choices": [{"delta": {"content": "model11111 0 这", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model11111", "object": "chat.completion.chunk", "system_fingerprint": null}
thread11111_task### model22222 {"id": null, "choices": [{"delta": {"content": "model22222 0 这", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model22222", "object": "chat.completion.chunk", "system_fingerprint": null}
INFO:     Started server process [19308]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
thread33333_task### model11111 {"id": null, "choices": [{"delta": {"content": "model11111 1 这是", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model11111", "object": "chat.completion.chunk", "system_fingerprint": null}       
thread22222_task### model11111 {"id": null, "choices": [{"delta": {"content": "model11111 1 这是", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model11111", "object": "chat.completion.chunk", "system_fingerprint": null}       
thread33333_task### model22222 {"id": null, "choices": [{"delta": {"content": "model22222 1 这是", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model22222", "object": "chat.completion.chunk", "system_fingerprint": null}       
thread22222_task### model22222 {"id": null, "choices": [{"delta": {"content": "model22222 1 这是", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model22222", "object": "chat.completion.chunk", "system_fingerprint": null}       
thread11111_task### model11111 {"id": null, "choices": [{"delta": {"content": "model11111 1 这是", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model11111", "object": "chat.completion.chunk", "system_fingerprint": null}       
thread11111_task### model22222 {"id": null, "choices": [{"delta": {"content": "model22222 1 这是", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model22222", "object": "chat.completion.chunk", "system_fingerprint": null}       
thread22222_task### model11111 {"id": null, "choices": [{"delta": {"content": "model11111 2 这是m", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model11111", "object": "chat.completion.chunk", "system_fingerprint": null}      
thread33333_task### model11111 {"id": null, "choices": [{"delta": {"content": "model11111 2 这是m", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model11111", "object": "chat.completion.chunk", "system_fingerprint": null}      
thread22222_task### model22222 {"id": null, "choices": [{"delta": {"content": "model22222 2 这是m", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model22222", "object": "chat.completion.chunk", "system_fingerprint": null}      
thread33333_task### model22222 {"id": null, "choices": [{"delta": {"content": "model22222 2 这是m", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model22222", "object": "chat.completion.chunk", "system_fingerprint": null}
......
thread22222_task### model22222 {"id": null, "choices": [{"delta": {"content": "model22222 34 这是model22222模型的流式输出他会将每个字挨个的输出哈哈!!!", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model22222", "object": "chat.completion.chunk", "system_fingerprint": null}
thread33333_task### model11111 {"id": null, "choices": [{"delta": {"content": "model11111 34 这是model11111模型的流式输出他会将每个字挨个的输出哈哈!!!", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model11111", "object": "chat.completion.chunk", "system_fingerprint": null}
thread11111_task### model11111 {"id": null, "choices": [{"delta": {"content": "model11111 34 这是model11111模型的流式输出他会将每个字挨个的输出哈哈!!!", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model11111", "object": "chat.completion.chunk", "system_fingerprint": null}
thread11111_task### model22222 {"id": null, "choices": [{"delta": {"content": "model22222 34 这是model22222模型的流式输出他会将每个字挨个的输出哈哈!!!", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model22222", "object": "chat.completion.chunk", "system_fingerprint": null}
thread33333_task### model22222 {"id": null, "choices": [{"delta": {"content": "model22222 34 这是model22222模型的流式输出他会将每个字挨个的输出哈哈!!!", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model22222", "object": "chat.completion.chunk", "system_fingerprint": null
thread22222_task ENDENDENDEND ['{"id": null, "choices": [{"delta": {"content": "model11111 34 这是model11111模型的流式输出他会将每个字挨个的输出哈哈!!!", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model11111", "object": "chat.completion.chunk", "system_fingerprint": null}', '{"id": null, "choices": [{"delta": {"content": "model22222 34 这是model22222模型的流式输出他会将每个字挨个的输出哈
哈!!!", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model22222", "object": "chat.completion.chunk", "system_fingerprint": null}']
thread11111_task ENDENDENDEND ['{"id": null, "choices": [{"delta": {"content": "model11111 34 这是model11111模型的流式输出他会将每个字挨个的输出哈哈!!!", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model11111", "object": "chat.completion.chunk", "system_fingerprint": null}', '{"id": null, "choices": [{"delta": {"content": "model22222 34 这是model22222模型的流式输出他会将每个字挨个的输出哈
哈!!!", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model22222", "object": "chat.completion.chunk", "system_fingerprint": null}']
thread33333_task ENDENDENDEND ['{"id": null, "choices": [{"delta": {"content": "model11111 34 这是model11111模型的流式输出他会将每个字挨个的输出哈哈!!!", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model11111", "object": "chat.completion.chunk", "system_fingerprint": null}', '{"id": null, "choices": [{"delta": {"content": "model22222 34 这是model22222模型的流式输出他会将每个字挨个的输出哈
哈!!!", "function_call": null, "role": "assistant", "tool_calls": null}, "finish_reason": "length", "index": 0, "logprobs": null}], "created": 1715238637, "model": "model22222", "object": "chat.completion.chunk", "system_fingerprint": null}']

Ctrl+C 终止多线程

demo

import threading
import timedef thread_function(name, flag):while not flag.is_set():print(f"Thread {name} is running")time.sleep(1)print(f"Thread {name} is exiting")def signal_handler(signum, frame):print("\nYou pressed Ctrl+C! Exiting gracefully.")for flag in flags:  # Set the flags to terminate the threadsflag.set()for t in threads:t.join()  # Wait for the threads to finishexit()if __name__ == "__main__":import signalfrom threading import Event# Create flags to control the threadsflags = [Event() for _ in range(3)]# Start three threadsthreads = [threading.Thread(target=thread_function, args=('Thread-{}'.format(i), flags[i])) for i in range(3)]for t in threads:t.start()# Register the signal handlersignal.signal(signal.SIGINT, signal_handler)# Wait for keyboard interrupttry:while True:time.sleep(0.1)except KeyboardInterrupt:pass

运行:

> python.exe .\test.py
Thread Thread-0 is running
Thread Thread-1 is running
Thread Thread-2 is running
Thread Thread-2 is running
Thread Thread-1 is running
Thread Thread-0 is running
Thread Thread-1 is running
Thread Thread-2 is running
Thread Thread-0 is runningYou pressed Ctrl+C! Exiting gracefully.		# 此时执行了 Ctrl+C
Thread Thread-0 is exiting
Thread Thread-2 is exiting
Thread Thread-1 is exiting

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

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

相关文章

LVGL移植教程(超详细)——基于GD32F303X系列MCU

版本&#xff1a;LVGL Kernel V8.3.0&#xff0c;运行压力测试Demo Stress首先放一张最终Stress Demo 运行图&#xff1a; 一、准备 1. GD32 Keil工程 准备任意一个屏幕可以正常显示的GD32工程&#xff1a; 2. LVGL源码 最新版现在已经是V9.2了&#xff0c;这里我选择了…

XQT_UI 组件|03 |加载组件 XQtLoading

XQtLoading 使用文档 简介 XQtLoading 是一个自定义的加载动画组件&#xff0c;旨在为用户提供可配置的旋转花瓣动画效果。它可以在应用程序中用于指示加载状态&#xff0c;提升用户体验。 特征 可配置性&#xff1a;用户可以根据需求调整旋转周期、缩放周期、最大/最小缩放…

Bi-LSTM-CRF实现中文命名实体识别工具(TensorFlow)

项目源码获取方式见文章末尾&#xff01; 回复暗号&#xff1a;13&#xff0c;免费获取600多个深度学习项目资料&#xff0c;快来加入社群一起学习吧。 **《------往期经典推荐------》**项目名称 1.【MobileNetV2实现实时口罩检测tensorflow】 2.【卫星图像道路检测DeepLabV3P…

关于嵌入式学习的一些短浅经验

一、写在前面 感谢在 10.23&#xff0c;各位大佬对我进行的模拟面试&#xff0c;我也发现了我对知识的不熟练的部分&#xff0c;比如 IPC 方法和线程同步方法的知识。模拟面试第四期-已经拿到大厂 OFFER 的研究生大佬-LINUX 卷到飞起_哔哩哔哩_bilibili 然后&#xff0c;沈阳…

uniapp+uniCloud前端独立开发全栈项目Vue3版本学习路线,轻松开发H5、微信小程序、APP

概述 嗨&#xff0c;大家好&#xff0c;我是爱搞知识的咸虾米&#xff0c;这个学习路线是uniappuniCloud生态开发微信小程序、H5、APP等实战项目&#xff0c;从零基础开始到各种类型的项目案例&#xff0c;使用比较新的vue3语法糖版本&#xff0c;通过前端的技术可以轻松开发上…

微信小程序——消息订阅

首先用到的就是wx.requestSubscribeMessage接口。 注意&#xff1a;用户发生点击行为或者发起支付回调后&#xff0c;才可以调起订阅消息界面 requestSubscribeMessage() {uni.requestSubscribeMessage({tmplIds: [],//需要订阅的消息模板的id的集合&#xff0c;一次调用最多可…

Docker 常用命令全解析:提升对雷池社区版的使用经验

Docker 常用命令解析 Docker 是一个开源的容器化平台&#xff0c;允许开发者将应用及其依赖打包到一个可移植的容器中。以下是一些常用的 Docker 命令及其解析&#xff0c;帮助您更好地使用 Docker。 1. Docker 基础命令 查看 Docker 版本 docker --version查看 Docker 运行…

向量检索学习记录

1、Faiss Faiss是一个用于高效相似搜索和密集向量聚类的库&#xff1b;&#xff08;支持单个/多个GPU&#xff09;官方文档&#xff1a;Home facebookresearch/faiss Wiki GitHub 安装&#xff08;如果编译有问题&#xff0c;有些选项需要关下&#xff0c;比如GPU, Python&a…

从 Hadoop 迁移到数据 Lakehouse 的架构师指南

从 Hadoop 到数据湖仓一体架构的演变代表了数据基础架构的重大飞跃。虽然 Hadoop 曾经以其强大的批处理能力统治着大数据领域&#xff0c;但如今的组织正在寻求更敏捷、更具成本效益和现代化的解决方案。尤其是当他们越来越多地开始实施 AI 计划时。根本没有办法让 Hadoop 为 A…

【福建医科大学附属第一医院-注册安全分析报告】

前言 由于网站注册入口容易被黑客攻击&#xff0c;存在如下安全问题&#xff1a; 暴力破解密码&#xff0c;造成用户信息泄露短信盗刷的安全问题&#xff0c;影响业务及导致用户投诉带来经济损失&#xff0c;尤其是后付费客户&#xff0c;风险巨大&#xff0c;造成亏损无底洞 …

微信机器人自动回复了解下

现在使用微信来做私域营销和维护客户的非常多&#xff0c;在工作上会频繁地遭遇客户提出的相同问题&#xff0c;当我们的好友数量众多时&#xff0c;手动逐个回复可能会耗费大量的时间。 幸运的是&#xff0c;多微管理系统的自动回复功能为我们带来了福音。帮助咱们解决这一难…

原创作品——GIS和监控软件设计

这套数据可视化大屏软件UI设计旨在提供一个直观、高​‌‌效且易于理解的界面&#xff0c;用于展示和分析大量的能源数据和信息。以下是关于该系统UI设计的详细介绍&#xff1a; 整体布局与设计风格&#xff1a; 界面以蓝色调为主&#xff0c;代表冷静、专业和科技的氛围。 布…

VisualStudio2022配置2D图形库SFML

文章目录 1. 下载安装SFML库2. 创建C项目并配置SFML配置include目录和库目录链接SFML库配置动态链接库 3. 测试 1. 下载安装SFML库 SFML&#xff08;Simple and Fast Multimedia Library&#xff09;C库&#xff0c;适合2D游戏和图形界面&#xff0c;提供了以下模块&#xff1…

通过conda install -c nvidia cuda=“11.3.0“ 安装低版本的cuda,但是却安装了高版本的12.4.0

问题 直接通过 conda install -c nvidia cuda"11.3.0"安装得到的却是高版本的 不清楚原理 解决方法 不过我们可以分个安装 runtime toolkit 和 nvcc 安装指定版本的 cudatoolkit 和 nvcc conda install -c nvidia cuda-cudart"11.3.58" conda instal…

电机学习-SVPWM合成原理

一、核心理论 SVPWM 算法的理论基础是平均值等效原理 &#xff0c;即在一个开关周 T s T_s Ts​内通过对基本电压矢量加以组合&#xff0c;使其平均值与给定电压矢量相等。 引用于《现代永磁同步电机控制原理及MATLAB仿真》 二、合成原理 在扇区 I 为例&#xff1a; 矢量 U o…

【实用知识】Spring Boot 优雅捕捉异常的几种姿势

&#x1f449;博主介绍&#xff1a; 博主从事应用安全和大数据领域&#xff0c;有8年研发经验&#xff0c;5年面试官经验&#xff0c;Java技术专家&#xff0c;WEB架构师&#xff0c;阿里云专家博主&#xff0c;华为云云享专家&#xff0c;51CTO 专家博主 ⛪️ 个人社区&#x…

【损害和风险评估&坑洼】路面坑洼检测系统源码&数据集全套:改进yolo11-DCNV3

改进yolo11-DLKA等200全套创新点大全&#xff1a;路面坑洼检测系统源码&#xff06;数据集全套 1.图片效果展示 项目来源 人工智能促进会 2024.10.24 注意&#xff1a;由于项目一直在更新迭代&#xff0c;上面“1.图片效果展示”和“2.视频效果展示”展示的系统图片或者视频可…

【OpenAI】第五节(图像生成)利用 OpenAI 的 DALL·E 实现自动化图像生成:从文本到图像的完整教程

引言 OpenAI 推出的 DALLE 工具因其能够生成令人惊叹的艺术作品而备受瞩目。DALLE 不仅能够生成静态图像&#xff0c;还能根据用户的需求进行风格化处理&#xff0c;创造出独特的艺术作品。通过 OpenAI 的 API&#xff0c;你可以轻松将 DALLE 的强大功能集成到你的 Python 程序…

单反相机内存卡误删照片怎么办?别急,这里有恢复方法

在摄影的世界里&#xff0c;单反相机无疑是众多摄影爱好者与专业摄影师的首选工具。它不仅能够捕捉细腻丰富的画面细节&#xff0c;还提供了高度的操作灵活性和可扩展性。然而&#xff0c;在使用单反相机的过程中&#xff0c;我们难免会遇到一些技术上的困扰&#xff0c;其中之…

【网络面试篇】三次握⼿、四次挥手综述

目录 一、三次握手 1. 过程描述 2. 为什么不是四次握手&#xff1f;为什么不能两次握手&#xff1f; 二、四次挥手 1. 过程描述 2. 为什么是四次挥手&#xff1f; 一、三次握手 1. 过程描述 ① 客户端 向 服务器 发送 SYN 报文、初始化序列号 ISN&#xff08;seqx&…