Skip to content

Commit 0949c39

Browse files
committed
Minor fixes after LiteLLM merge
1 parent 6d28e23 commit 0949c39

File tree

12 files changed

+61
-89
lines changed

12 files changed

+61
-89
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
**/THIRD_PARTY_LICENSES.txt
99
sbin/**
1010
**/*.bak
11+
**/*.delete
1112
**/tmp/**
1213
**/temp/**
1314
**/chatbot_graph.png

opentofu/locals.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Housekeeping
66
locals {
77
compartment_ocid = var.compartment_ocid != "" ? var.compartment_ocid : var.tenancy_ocid
8-
label_prefix = var.label_prefix != "" ? lower(var.label_prefix) : lower(substr(random_pet.label.id, 0, 12))
8+
label_prefix = var.label_prefix != "" ? substr(lower(var.label_prefix), 0, 12) : substr(lower(random_pet.label.id), 0, 12)
99
}
1010

1111

src/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ENV TOKENIZERS_PARALLELISM=true \
1111
RUNUSER=oracleai
1212

1313
RUN microdnf --nodocs -y update && \
14-
microdnf --nodocs -y install python3.11 python3.11-pip && \
14+
microdnf --nodocs -y install python3.11 python3.11-pip sqlcl && \
1515
microdnf clean all && \
1616
python3.11 -m venv --symlinks --upgrade-deps /opt/.venv && \
1717
groupadd $RUNUSER && \

src/client/content/config/tabs/databases.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@
2222
#####################################################
2323
# Functions
2424
#####################################################
25-
def get_databases(validate: bool = False, force: bool = False) -> None:
25+
def get_databases(force: bool = False) -> None:
2626
"""Get Databases from API Server"""
2727
if force or "database_configs" not in state or not state.database_configs:
2828
try:
2929
logger.info("Refreshing state.database_configs")
3030
# Validation will be done on currently configured client database
3131
# validation includes new vector_stores, etc.
32-
if validate:
33-
client_database = state.client_settings.get("database", {}).get("alias", {})
34-
_ = api_call.get(endpoint=f"v1/databases/{client_database}")
32+
client_database = state.client_settings.get("database", {}).get("alias", {})
33+
_ = api_call.get(endpoint=f"v1/databases/{client_database}")
34+
35+
# Update state
3536
state.database_configs = api_call.get(endpoint="v1/databases")
3637
except api_call.ApiError as ex:
3738
logger.error("Unable to populate state.database_configs: %s", ex)
@@ -66,7 +67,7 @@ def patch_database(name: str, supplied: dict, connected: bool) -> bool:
6667
def drop_vs(vs: dict) -> None:
6768
"""Drop a Vector Storage Table"""
6869
api_call.delete(endpoint=f"v1/embed/{vs['vector_store']}")
69-
get_databases(validate=True, force=True)
70+
get_databases(force=True)
7071

7172

7273
def select_ai_profile() -> None:

src/client/content/config/tabs/settings.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
This script allows importing/exporting configurations using Streamlit (`st`).
66
"""
7-
# spell-checker:ignore streamlit, mvnw, obaas, ollama
7+
# spell-checker:ignore streamlit mvnw obaas ollama vllm
88

99
import time
1010
import os
@@ -159,7 +159,7 @@ def spring_ai_conf_check(ll_model: dict, embed_model: dict) -> str:
159159

160160
ll_provider = ll_model.get("provider", "")
161161
embed_provider = embed_model.get("provider", "")
162-
logger.info(f"llm chat:{ll_provider} - embeddings:{embed_provider}")
162+
logger.info("llm chat: %s - embeddings: %s", ll_provider, embed_provider)
163163
if all("hosted_vllm" in p for p in (ll_provider, embed_provider)):
164164
return "hosted_vllm"
165165
if all("openai" in p for p in (ll_provider, embed_provider)):
@@ -345,8 +345,8 @@ def display_settings():
345345
embed_config = {}
346346
spring_ai_conf = spring_ai_conf_check(ll_config, embed_config)
347347

348-
logger.info(f"config found:{spring_ai_conf}")
349-
348+
logger.info("config found: %s", spring_ai_conf)
349+
350350
if spring_ai_conf == "hybrid":
351351
st.markdown(f"""
352352
The current configuration combination of embedding and language models
@@ -365,15 +365,14 @@ def display_settings():
365365
disabled=spring_ai_conf == "hybrid",
366366
)
367367
with col_centre:
368-
if (spring_ai_conf != "hosted_vllm"):
368+
if spring_ai_conf != "hosted_vllm":
369369
st.download_button(
370370
label="Download SpringAI",
371371
data=spring_ai_zip(spring_ai_conf, ll_config, embed_config), # Generate zip on the fly
372372
file_name="spring_ai.zip", # Zip file name
373373
mime="application/zip", # Mime type for zip file
374374
disabled=spring_ai_conf == "hybrid",
375375
)
376-
377376

378377

379378
if __name__ == "__main__":

src/client/content/tools/tabs/split_embed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def display_split_embed() -> None:
391391
)
392392
st.success(f"Vector Store Populated: {response['message']}", icon="✅")
393393
# Refresh database_configs state to reflect new vector stores
394-
get_databases(validate=True, force=True)
394+
get_databases(force=True)
395395
except api_call.ApiError as ex:
396396
st.error(ex, icon="🚨")
397397

src/common/logging_config.py

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
55
Default Logging Configuration
66
"""
7+
# pylint: disable=too-few-public-methods
78
# spell-checker:ignore levelname inotify openai httpcore fsevents litellm
89

910
import os
11+
import asyncio
1012
import logging
1113
from logging.config import dictConfig
1214
from common._version import __version__
@@ -20,6 +22,30 @@ def filter(self, record):
2022
return True
2123

2224

25+
class PrettifyCancelledError(logging.Filter):
26+
"""Filter that keeps the log but removes the traceback and replaces the message."""
27+
28+
def _contains_cancelled(self, exc: BaseException) -> bool:
29+
if isinstance(exc, asyncio.CancelledError):
30+
return True
31+
if hasattr(exc, "exceptions") and isinstance(exc, BaseExceptionGroup): # type: ignore[name-defined]
32+
return any(self._contains_cancelled(e) for e in exc.exceptions) # type: ignore[attr-defined]
33+
return False
34+
35+
def filter(self, record: logging.LogRecord) -> bool:
36+
exc_info = record.__dict__.get("exc_info")
37+
if not exc_info:
38+
return True
39+
_, exc, _ = exc_info
40+
if exc and self._contains_cancelled(exc):
41+
# Strip the traceback and make it pretty
42+
record.exc_info = None
43+
record.msg = "Shutdown cancelled — graceful timeout exceeded."
44+
record.levelno = logging.WARNING
45+
record.levelname = logging.getLevelName(logging.WARNING)
46+
return True
47+
48+
2349
# Standard formatter
2450
FORMATTER = {
2551
"format": "%(asctime)s (v%(__version__)s) - %(levelname)-8s - (%(name)s): %(message)s",
@@ -33,9 +59,8 @@ def filter(self, record):
3359
"standard": FORMATTER,
3460
},
3561
"filters": {
36-
"version_filter": {
37-
"()": VersionFilter,
38-
},
62+
"version_filter": {"()": VersionFilter},
63+
"prettify_cancelled": {"()": PrettifyCancelledError},
3964
},
4065
"handlers": {
4166
"default": {
@@ -56,13 +81,19 @@ def filter(self, record):
5681
"level": LOG_LEVEL,
5782
"handlers": ["default"],
5883
"propagate": False,
84+
"filters": ["prettify_cancelled"],
5985
},
6086
"uvicorn.access": {
6187
"level": LOG_LEVEL,
6288
"handlers": ["default"],
6389
"propagate": False,
6490
},
65-
"asyncio": {"level": LOG_LEVEL, "handlers": ["default"], "propagate": False},
91+
"asyncio": {
92+
"level": LOG_LEVEL,
93+
"handlers": ["default"],
94+
"propagate": False,
95+
"filters": ["prettify_cancelled"],
96+
},
6697
"watchdog.observers.inotify_buffer": {"level": "INFO", "handlers": ["default"], "propagate": False},
6798
"PIL": {"level": "INFO", "handlers": ["default"], "propagate": False},
6899
"fsevents": {"level": "INFO", "handlers": ["default"], "propagate": False},

src/pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@ dependencies = [
1717
"langchain-core==0.3.75",
1818
"httpx==0.28.1",
1919
"oracledb~=3.1",
20-
"plotly==6.2.0",
20+
"plotly==6.3.0",
2121
]
2222

2323
[project.optional-dependencies]
2424
# Server component dependencies
2525
server = [
2626
"bokeh==3.8.0",
2727
"evaluate==0.4.5",
28-
"fastapi==0.116.1",
2928
"faiss-cpu==1.12.0",
29+
"fastapi==0.116.1",
30+
"fastmcp==2.12.0",
3031
"giskard==2.18.0",
3132
"langchain-anthropic==0.3.19",
3233
"langchain-azure-ai==0.1.5",
@@ -39,12 +40,13 @@ server = [
3940
"langchain-groq==0.3.7",
4041
"langchain-huggingface==0.3.1",
4142
"langchain-mistralai==0.2.11",
43+
"langchain-mcp-adapters==0.1.9",
4244
"langchain-ollama==0.3.7",
4345
"langchain-openai==0.3.32",
4446
"langchain-perplexity==0.1.2",
4547
"langchain-xai==0.2.5",
4648
"langgraph==0.6.6",
47-
"litellm==1.76.1",
49+
"litellm==1.76.1",
4850
"llama-index==0.13.3",
4951
"lxml==6.0.0",
5052
"matplotlib==3.10.6",

src/server/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ENV RUNUSER=oracleai
1212
ENV PATH=/opt/.venv/bin:$PATH
1313

1414
RUN microdnf --nodocs -y update && \
15-
microdnf --nodocs -y install python3.11 python3.11-pip && \
15+
microdnf --nodocs -y install python3.11 python3.11-pip sqlcl && \
1616
microdnf clean all && \
1717
python3.11 -m venv --symlinks --upgrade-deps /opt/.venv && \
1818
groupadd $RUNUSER && \

src/server/api/core/databases.py

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -51,65 +51,3 @@ def delete_database(name: DatabaseNameType) -> None:
5151
"""Remove database from database objects"""
5252
database_objects = bootstrap.DATABASE_OBJECTS
5353
bootstrap.DATABASE_OBJECTS = [d for d in database_objects if d.name != name]
54-
55-
56-
# for db in database_objects:
57-
# if name and db.name != name:
58-
# continue
59-
# if validate:
60-
# try:
61-
# db_conn = connect(db)
62-
# db.vector_stores = get_vs(db_conn)
63-
# db.selectai = selectai_enabled(db_conn)
64-
# if db.selectai:
65-
# db.selectai_profiles = get_selectai_profiles(db_conn)
66-
# except Exception as ex:
67-
# logger.debug("Skipping Database %s - exception: %s", db.name, str(ex))
68-
# db.connected = False
69-
# if name:
70-
# return db # Return the matched, connected DB immediately
71-
72-
# if name:
73-
# # If we got here with a `name` then we didn't find it
74-
# raise ValueError(f"{name} not found")
75-
76-
# return database_objects
77-
78-
79-
# create_database
80-
81-
82-
# delete_database
83-
84-
85-
# def get_databases(
86-
# name: Optional[DatabaseNameType] = None, validate: bool = True
87-
# ) -> Union[list[Database], Database, None]:
88-
# """
89-
# Return all Database objects if `name` is not provided,
90-
# or the single Database if `name` is provided and successfully connected.
91-
# If a `name` is provided and not found, raise exception
92-
# """
93-
# database_objects = bootstrap.DATABASE_OBJECTS
94-
95-
# for db in database_objects:
96-
# if name and db.name != name:
97-
# continue
98-
# if validate:
99-
# try:
100-
# db_conn = connect(db)
101-
# db.vector_stores = get_vs(db_conn)
102-
# db.selectai = selectai_enabled(db_conn)
103-
# if db.selectai:
104-
# db.selectai_profiles = get_selectai_profiles(db_conn)
105-
# except Exception as ex:
106-
# logger.debug("Skipping Database %s - exception: %s", db.name, str(ex))
107-
# db.connected = False
108-
# if name:
109-
# return db # Return the matched, connected DB immediately
110-
111-
# if name:
112-
# # If we got here with a `name` then we didn't find it
113-
# raise ValueError(f"{name} not found")
114-
115-
# return database_objects

0 commit comments

Comments
 (0)