Skip to content

Commit

Permalink
Allow langgraph's recursion_limit to be configured through env variab…
Browse files Browse the repository at this point in the history
…les (#118)
  • Loading branch information
StreetLamb authored Aug 14, 2024
1 parent 5920256 commit 8659bff
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ USERS_OPEN_REGISTRATION=False
MAX_UPLOAD_SIZE=50_000_000
# Sets the number of processes
MAX_WORKERS=1
# Controls LangGraph's recursion_limit configuration parameter. If empty, defaults to 25.
RECURSION_LIMIT=25

# llm provider keys. Add only to models that you want to use
OPENAI_API_KEY=
Expand Down
3 changes: 3 additions & 0 deletions backend/app/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,8 @@ def _enforce_non_default_secrets(self) -> Self:

MAX_UPLOAD_SIZE: int = 50_000_000

# LangGraph config
RECURSION_LIMIT: int = 25


settings = Settings() # type: ignore
2 changes: 1 addition & 1 deletion backend/app/core/graph/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ async def generator(

config: RunnableConfig = {
"configurable": {"thread_id": thread_id},
"recursion_limit": 25,
"recursion_limit": settings.RECURSION_LIMIT,
}
# Handle interrupt logic by orriding state
if interrupt and interrupt.decision == InterruptDecision.APPROVED:
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ services:
- DENSE_EMBEDDING_MODEL=${DENSE_EMBEDDING_MODEL?Variable not set}
- SPARSE_EMBEDDING_MODEL=${SPARSE_EMBEDDING_MODEL?Variable not set}
- MAX_UPLOAD_SIZE=${MAX_UPLOAD_SIZE}
- RECURSION_LIMIT=${RECURSION_LIMIT}
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
build:
Expand Down

0 comments on commit 8659bff

Please sign in to comment.