Три способа выполнить множество задач с asyncio
Функция для примера:
async def do_it(n):
await asyncio.sleep(random.uniform(0.5, 1))
return n
1. Последовательный вызов
async def main():
for i in range(100):
result = await do_it(i)
Такой вызов имеет смысл только тогда, когда результат одной задачи требуется для вызова следующей.
Если они независимы, то это антипаттерн, так как аналогичен простому синхронному вызову по очереди.
2. Упорядоченный результат
async def main():
tasks = [do_it(i) for i in range(100)]
results = await asyncio.gather(*tasks)
Выполняет корутины конкурентно и возвращает результат в виде списка.
Полезен когда требуется получить результаты в том же порядке в котором задачи отправлены.
3. Результат по мере готовности
tasks = [asyncio.create_task(do_it(i)) for i in range(100)]
for cor in asyncio.as_completed(tasks):
result = await cor
Так же выполняет корутины конкурентно, но не гарантирует порядок. Результат возвращается по мере готовности, каждый отдельно.
Полезен когда нужно обработать любой ответ как можно скорее.
#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