Files
ai-agent-server/app/utils/PER_REQ_CONFIG_MODIFIER.py
T
2026-03-31 16:57:56 +08:00

19 lines
334 B
Python

import uuid
def next_thread_id():
return str(uuid.uuid4())
async def PER_REQ_CONFIG_MODIFIER(config, request):
body = await request.json()
return {
"configurable": {
"thread_id":
body
.get("config", {})
.get("configurable", {})
.get("thread_id", None) or next_thread_id()
}
}