Skip to content

Commit 142612e

Browse files
authored
Cognition UI Facelift (#174)
* New fields * Update porject icon * helper func
1 parent bf78bce commit 142612e

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

cognition_objects/project.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import List, Optional, Dict, Any, Iterable
22
from ..business_objects import general, team_resource, user
33
from ..cognition_objects import consumption_log, consumption_summary
4-
from ..session import session, request_id_ctx_var
4+
from ..session import session
55
from ..models import CognitionProject, TeamMember, TeamResource
66
from .. import enums
77
from datetime import datetime
@@ -214,6 +214,7 @@ def update(
214214
macro_config: Optional[Dict[str, Any]] = None,
215215
llm_config: Optional[Dict[str, Any]] = None,
216216
tokenizer: Optional[str] = None,
217+
icon: Optional[str] = None,
217218
with_commit: bool = True,
218219
) -> CognitionProject:
219220
project: CognitionProject = get(project_id)
@@ -285,6 +286,8 @@ def update(
285286
flag_modified(project, "operator_routing_config")
286287
if tokenizer is not None:
287288
project.tokenizer = tokenizer
289+
if icon is not None:
290+
project.icon = icon
288291
general.flush_or_commit(with_commit)
289292
return project
290293

models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ class User(Base):
226226
created_at = Column(DateTime, default=sql.func.now())
227227
metadata_public = Column(JSON)
228228
sso_provider = Column(String)
229+
use_new_cognition_ui = Column(Boolean, default=True)
229230

230231

231232
class Team(Base):
@@ -1110,6 +1111,8 @@ class CognitionProject(Base):
11101111
# holds e.g. show, admin macro setting etc.
11111112
macro_config = Column(JSON)
11121113
tokenizer = Column(String)
1114+
# options from <SVGIcon/> component - only visible with new UI selected (user setting)
1115+
icon = Column(String, default="IconBolt")
11131116

11141117

11151118
class CognitionStrategy(Base):

util.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616

1717
CAMEL_CASE_PATTERN = compile(r"^([a-z]+[A-Z]?)*$")
1818

19+
STRING_TRUE_VALUES = {"true", "x", "1", "y"}
20+
21+
22+
def is_string_true_value(value: str) -> bool:
23+
return value.lower() in STRING_TRUE_VALUES
24+
1925

2026
def collect_engine_variables() -> Tuple[int, int, bool, bool]:
2127
# amount of simultaneous connections to the database
@@ -50,7 +56,7 @@ def collect_engine_variables() -> Tuple[int, int, bool, bool]:
5056
os_pool_use_lifo = os.getenv("POSTGRES_POOL_USE_LIFO")
5157
if os_pool_use_lifo:
5258
try:
53-
pool_use_lifo = os_pool_use_lifo.lower() in ["true", "x", "1", "y"]
59+
pool_use_lifo = is_string_true_value(os_pool_use_lifo)
5460
except ValueError:
5561
print(
5662
f"POSTGRES_POOL_USE_LIFO is not an boolean, using default {pool_use_lifo}",
@@ -64,7 +70,7 @@ def collect_engine_variables() -> Tuple[int, int, bool, bool]:
6470
os_pool_pre_ping = os.getenv("POSTGRES_POOL_PRE_PING")
6571
if os_pool_pre_ping:
6672
try:
67-
pool_pre_ping = os_pool_pre_ping.lower() in ["true", "x", "1", "y"]
73+
pool_pre_ping = is_string_true_value(os_pool_pre_ping)
6874
except ValueError:
6975
print(
7076
f"POSTGRES_POOL_PRE_PING is not an boolean, using default {pool_pre_ping}",

0 commit comments

Comments
 (0)