Отдельно разберём TaskGroup, который пришел на замену gather в Python 3.11.
Ключевые отличия
▫️create_task() возвращает объект asyncio.Task, у которого есть соответствюущие методы управления. То есть у нас больше контроля
▫️это контекстный менеджер, который гарантирует что все таски будут остановлены по выходу из контекста
▫️ошибка автоматически отменяет незавершенные задачи,
▫️except* передает нам ExceptionGroup, в котором каждую ошибку можно обработать отдельно
import asyncio
import random
async def do_it() -> str:
if random.random() < 0.1:
raise ValueError('Oops')
delay = random.uniform(0.5, 1.5)
await asyncio.sleep(delay)
return delay
async def main():
try:
async with asyncio.TaskGroup() as tg:
for _ in range(10):
tasks.append(tg.create_task(do_it()))
for t in tasks:
print(t.result())
except *ValueError as e:
for err in e.exceptions:
print(err)
asyncio.run(main())
Рекомендую изучить страницу Coroutines and Tasks из документации, где представлено больше интересных примеров и механизмов
- таймауты
- отмена задач
- создание задач из другого потока
#async
🚀 AI TRENDS | Tether Launches QVAC SDK for Cross-Platform AI Development
Tether has introduced the QVAC SDK, a unified software development kit designed to enable developers to build, run, and fine-tune AI applications directly on any device. According to Foresight News, this SDK ensures consistency across different environments.
Applications developed using the QVAC SDK can seamlessly operate on platforms such as iOS, Android, Windows, macOS, and Linux. The same codebase can function across all supported environments without the need for platform-specific branches, rewrites, or conditional logic.
The QVAC SDK is built on QVAC Fabric, a branch of llama.cpp, offering broad compatibility with the llama.cpp model ecosystem for text generation, embedding, and multimodal workloads.
#AI#SDK#CrossPlatform#MachineLearning#LlamaCpp#SoftwareDevelopment#Multimodal#QVAC
#python#agents#generative_ai_tools#llamacpp#llm#onnx#openvino#parsing#retrieval_augmented_generation#small_specialized_models
llmware is a powerful, easy-to-use platform that helps you build AI applications using small, specialized language models designed for business tasks like question-answering, summarization, and data extraction. It supports private, secure deployment on your own machines without needing expensive GPUs, making it cost-effective and safe for enterprise use. You can organize and search your documents, run smart queries, and combine knowledge with AI to get accurate answers quickly. It also offers many ready-to-use models and examples, plus tools for building chatbots and agents that automate complex workflows. This helps you save time, improve accuracy, and securely leverage AI for your business needs[1][3][5].
https://github.com/llmware-ai/llmware