mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-13 21:05:19 +00:00
refac
This commit is contained in:
parent
5e6e25f8c8
commit
6e4a2f18e1
2 changed files with 12 additions and 4 deletions
|
|
@ -222,10 +222,11 @@ class PersistentConfig(Generic[T]):
|
||||||
|
|
||||||
|
|
||||||
class AppConfig:
|
class AppConfig:
|
||||||
_state: dict[str, PersistentConfig]
|
|
||||||
_redis: Union[redis.Redis, redis.cluster.RedisCluster] = None
|
_redis: Union[redis.Redis, redis.cluster.RedisCluster] = None
|
||||||
_redis_key_prefix: str
|
_redis_key_prefix: str
|
||||||
|
|
||||||
|
_state: dict[str, PersistentConfig]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
redis_url: Optional[str] = None,
|
redis_url: Optional[str] = None,
|
||||||
|
|
@ -233,9 +234,8 @@ class AppConfig:
|
||||||
redis_cluster: Optional[bool] = False,
|
redis_cluster: Optional[bool] = False,
|
||||||
redis_key_prefix: str = "open-webui",
|
redis_key_prefix: str = "open-webui",
|
||||||
):
|
):
|
||||||
super().__setattr__("_state", {})
|
|
||||||
super().__setattr__("_redis_key_prefix", redis_key_prefix)
|
|
||||||
if redis_url:
|
if redis_url:
|
||||||
|
super().__setattr__("_redis_key_prefix", redis_key_prefix)
|
||||||
super().__setattr__(
|
super().__setattr__(
|
||||||
"_redis",
|
"_redis",
|
||||||
get_redis_connection(
|
get_redis_connection(
|
||||||
|
|
@ -246,6 +246,8 @@ class AppConfig:
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
super().__setattr__("_state", {})
|
||||||
|
|
||||||
def __setattr__(self, key, value):
|
def __setattr__(self, key, value):
|
||||||
if isinstance(value, PersistentConfig):
|
if isinstance(value, PersistentConfig):
|
||||||
self._state[key] = value
|
self._state[key] = value
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,13 @@ def query_doc_with_hybrid_search(
|
||||||
hybrid_bm25_weight: float,
|
hybrid_bm25_weight: float,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
try:
|
try:
|
||||||
if not collection_result.documents[0]:
|
if (
|
||||||
|
not collection_result
|
||||||
|
or not hasattr(collection_result, "documents")
|
||||||
|
or not collection_result.documents
|
||||||
|
or len(collection_result.documents) == 0
|
||||||
|
or not collection_result.documents[0]
|
||||||
|
):
|
||||||
log.warning(f"query_doc_with_hybrid_search:no_docs {collection_name}")
|
log.warning(f"query_doc_with_hybrid_search:no_docs {collection_name}")
|
||||||
return {"documents": [], "metadatas": [], "distances": []}
|
return {"documents": [], "metadatas": [], "distances": []}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue