Недавно делал быстрый прототип асинхронного приложения в котором требовалось вызывать много синхронного кода. Да, я знаю, что это не лучший дизайн, но нужно было быстрое решение на один процесс и без очередей. Поэтому я выполнял код в потоках.
Выглядело это примерно так:
from fastapi.concurrency import run_in_threadpool
async def execute(data: DataRequest) -> DataResponse:
try:
result = await run_in_threadpool(sync_function, data)
return DataResponse(data=result)
except Exception as e:
return DataResponse(
error=str(e),
success=False,
)
В общем работает нормально. Для всех вызовов под капотом используется общий тредпул, всё работает предсказуемо.
Но потребовалось изменить количество запускаемых в пуле потоков (по умолчанию создается 40 воркеров).
Так как дело происходит с FastAPI, делается это через lifespan используя настройки anyio:
import anyio
@asynccontextmanager
async def lifespan(app: FastAPI):
limiter = anyio.to_thread.current_default_thread_limiter()
limiter.total_tokens = 100
yield
# если вдруг нужно вернуть обратно
limiter.total_tokens = 40
Зачем менять количество воркеров?
- уменьшить, если оперативки мало (один тред занимает ~8мб)
- увеличить чтобы выдержать нагрузку
Если есть предложения получше при тех же вводных - предлагайте😉
#async
Раз уж девелоперы OpenAI не спешат с созданием сборника ChatGPT-плагинов — этим занялись любители.
Самодельный список не только вместил все доступные на сегодня ChatGPT-моды, но и полезные руководства с примерами промтов.
Всем поклонникам ChatGPT — сюда.
OpenAI Community | #plugins
Большой набор пресетов для моушн-дизайна в Blender: https://blendermarket.com/products/motion-animate---speed-up-motion-graphics?ref=110
#Blender#Plugins#3D
#other#awesome#chartjs#charts#integrations#plugins#resources
Chart.js is a flexible JavaScript library for creating interactive charts with extensive customization options. You can use it with popular frameworks like React, Vue, and Angular through dedicated adapters, and extend its functionality with plugins for styling, features, and data handling. The library supports three major versions—v2 (April 2016), v3 (April 2021), and v4 (November 2022)—each with different plugin compatibility. This means you can choose the version that best fits your project needs and find compatible extensions for charts, animations, zooming, data labels, and more. Whether you need basic charts or advanced visualizations with custom interactions, Chart.js provides the tools to build professional data displays efficiently.
https://github.com/chartjs/awesome
#cmake#audio#ios#linux#macos#plugins#sdk#vst3#win32
VST 3 is an improved version of the VST audio plug-in interface. It offers several benefits, including better performance by only processing audio when needed, dynamic input/output configurations, and precise automation. Users can also enjoy a more organized interface and support for advanced audio features like 3D sound. These improvements make it easier for developers to create plugins and for users to work with them in digital audio workstations (DAWs), enhancing overall audio production efficiency.
https://github.com/steinbergmedia/vst3sdk
#typescript#ai#anthropic#artifacts#assistant_api#aws#azure#chatgpt#chatgpt_clone#claude#clone#dall_e_3#deepseek#gemini#google#librechat#o1#openai#plugins#vision#webui
LibreChat is a free, open-source AI chatbot platform that lets you use many AI models like OpenAI, Anthropic, and AWS in one place. It offers advanced features such as secure code execution in multiple programming languages, AI assistants that can handle files and tools without coding, and the ability to generate images and diagrams directly in chat. You can search conversations easily, manage multiple chat threads, and customize the interface to fit your needs. LibreChat supports multiple languages, speech input/output, and secure multi-user access. It can be deployed locally or on the cloud, giving you flexibility and control over your AI experience. This means you get a powerful, customizable AI assistant without needing to pay for ChatGPT Plus or rely on a single provider[1][3][5].
https://github.com/danny-avila/LibreChat