Skip to content

Commit

Permalink
turn self route using env (#121)
Browse files Browse the repository at this point in the history
* turn self route using env

* add SELF_ROUTE_ENABLED to env.example

---------

Co-authored-by: Saisakul Chernbumroong <[email protected]>
  • Loading branch information
saisakul and Saisakul Chernbumroong authored Feb 26, 2025
1 parent 9bf3b6d commit 9d45501
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,5 @@ REDBOX_API_KEY = myapi
# AUTHBROKER_CLIENT_SECRET=REPLACE_WITH_GITLAB_SECRET
# AUTHBROKER_URL=https://sso.trade.gov.uk

ENABLE_METADATA_EXTRACTION = True
ENABLE_METADATA_EXTRACTION = True
SELF_ROUTE_ENABLED = False
7 changes: 6 additions & 1 deletion redbox-core/redbox/models/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from typing import Annotated, Literal, NotRequired, Required, TypedDict, get_args, get_origin
from uuid import UUID, uuid4

import environ
from dotenv import load_dotenv
from langchain_core.documents import Document
from langchain_core.messages import AnyMessage
from langgraph.graph.message import add_messages
Expand All @@ -14,6 +16,9 @@
from redbox.models import prompts
from redbox.models.settings import ChatLLMBackend

load_dotenv()
env = environ.Env()


class ChainChatMessage(TypedDict):
role: Literal["user", "ai", "system"]
Expand All @@ -29,7 +34,7 @@ class AISettings(BaseModel):

# Prompts and LangGraph settings
max_document_tokens: int = 1_000_000
self_route_enabled: bool = False
self_route_enabled: bool = env.bool("SELF_ROUTE_ENABLED", default=False)
map_max_concurrency: int = 128
stuff_chunk_context_ratio: float = 0.75
recursion_limit: int = 50
Expand Down

0 comments on commit 9d45501

Please sign in to comment.