The previous implementation used asyncio.to_thread(llm.complete) to avoid blocking the event loop, but Chainlit's contextvars context is not reliably propagated across thread boundaries, causing the session to reset and clear the message history on each user submission. Changes: - Add llm.acomplete() using litellm.acompletion() (native coroutine) - Replace asyncio.to_thread() in on_message with await llm.acomplete() - Store the welcome message in state.messages so it is replayed on reconnect - Persist state to cl.user_session immediately after appending the user's message (before the LLM call) so reconnect detection has the latest history - Add pytest-asyncio dev dependency and asyncio_mode = "auto" config - Add 6 async tests for acomplete() in tests/test_llm.py https://claude.ai/code/session_01SUWzMzFvSfWiHXA2p6rPg9
35 lines
747 B
TOML
35 lines
747 B
TOML
[project]
|
|
name = "meister-eder"
|
|
version = "0.1.0"
|
|
description = "AI-powered conversational registration agent for Spielgruppe Pumuckl"
|
|
requires-python = ">=3.13"
|
|
dependencies = [
|
|
# LLM access — supports any provider (Anthropic, OpenAI, Gemini, …)
|
|
"litellm>=1.0.0",
|
|
# Configuration
|
|
"python-dotenv>=1.0.0",
|
|
# Registration schema validation
|
|
"jsonschema>=4.23.0",
|
|
"chainlit>=2.9.6",
|
|
]
|
|
|
|
[project.scripts]
|
|
meister-eder = "main:main"
|
|
|
|
[build-system]
|
|
requires = ["hatchling"]
|
|
build-backend = "hatchling.build"
|
|
|
|
[tool.hatch.build.targets.wheel]
|
|
packages = ["src"]
|
|
|
|
[tool.uv]
|
|
dev-dependencies = [
|
|
"pytest>=8.0.0",
|
|
"pytest-asyncio>=1.3.0",
|
|
"pytest-mock>=3.14.0",
|
|
]
|
|
|
|
[tool.pytest.ini_options]
|
|
asyncio_mode = "auto"
|