Skip to content

Commit 1a89f97

Browse files
committed
fix: promise reject missing code
1 parent cf5f2e2 commit 1a89f97

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/server/api/memobase_server/controllers/modal/chat/organize.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from .types import MergeAddResult, PROMPTS, AddProfile
44
from ....prompts.profile_init_utils import get_specific_subtopics
55
from ....prompts.utils import parse_string_into_subtopics, attribute_unify
6-
from ....models.utils import Promise
6+
from ....models.utils import Promise, CODE
77
from ....models.response import ProfileData
88
from ....env import CONFIG, TRACE_LOG, ProfileConfig, ContanstTable
99
from ....llms import llm_complete
@@ -41,7 +41,9 @@ async def organize_profiles(
4141
)
4242
if not all([p.ok() for p in ps]):
4343
errmsg = "\n".join([p.msg() for p in ps if not p.ok()])
44-
return Promise.reject(f"Failed to organize profiles: {errmsg}")
44+
return Promise.reject(
45+
CODE.INTERNAL_SERVER_ERROR, f"Failed to organize profiles: {errmsg}"
46+
)
4547

4648
delete_profile_ids = []
4749
for gs in need_to_organize_topics.values():
@@ -113,7 +115,8 @@ async def organize_profiles_by_topic(
113115
]
114116
if len(reorganized_profiles) == 0:
115117
return Promise.reject(
116-
"Failed to organize profiles, left profiles is 0 so maybe it's the LLM error"
118+
CODE.SERVER_PARSE_ERROR,
119+
"Failed to organize profiles, left profiles is 0 so maybe it's the LLM error",
117120
)
118121
# forcing the number of subtopics to be less than max_profile_subtopics // 2 + 1
119122
reorganized_profiles = reorganized_profiles[: CONFIG.max_profile_subtopics // 2 + 1]

src/server/api/memobase_server/controllers/modal/chat/summary.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import asyncio
2-
from ....models.utils import Promise
2+
from ....models.utils import Promise, CODE
33
from ....env import CONFIG, TRACE_LOG
44
from ....utils import get_blob_str, get_encoded_tokens, truncate_string
55
from ....llms import llm_complete
@@ -20,7 +20,9 @@ async def re_summary(
2020
update_tasks = [summary_memo(user_id, project_id, up) for up in update_profile]
2121
ps = await asyncio.gather(*update_tasks)
2222
if not all([p.ok() for p in ps]):
23-
return Promise.reject("Failed to re-summary profiles")
23+
return Promise.reject(
24+
CODE.INTERNAL_SERVER_ERROR, "Failed to re-summary profiles"
25+
)
2426
return Promise.resolve(None)
2527

2628

0 commit comments

Comments
 (0)