/
man4j
/
agent-server
Обзор
Документация
Войти
/
man4j
/
agent-server
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/agent_server/chat/prompt_cache.py
27 строк
869 B
Vladimir
initial
18 апр 2026, 19:36
18 апр 2026, 19:36
a95f341
Код
Авторство
О чём код?
from chainlit.types import ThreadDict from agent_server.chat.session import get_thread_system_prompts, set_thread_system_prompts from agent_server.chat.thread_metadata import get_thread_id def get_thread_prompt_cache() -> dict[str, str]: cache = get_thread_system_prompts() if not isinstance(cache, dict): cache = {} set_thread_system_prompts(cache) return cache def cache_system_prompt_for_thread(thread_id: str | None, system_prompt: str) -> None: if not thread_id or not system_prompt: return cache = get_thread_prompt_cache() cache[thread_id] = system_prompt set_thread_system_prompts(cache) def get_cached_system_prompt_for_thread(thread: ThreadDict | None) -> str | None: thread_id = get_thread_id(thread) if not thread_id: return None return get_thread_prompt_cache().get(thread_id)