-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
test: add API and dashboard integration tests #5362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,7 +1,9 @@ | ||||||
| from astrbot.core.star import Context, Star, StarTools | ||||||
| from astrbot.core.star.base import Star | ||||||
|
||||||
| from astrbot.core.star.base import Star | |
| from astrbot.core.star import Star |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看起来需要同步?
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -760,17 +760,23 @@ async def _handle_webchat( | |||||
| if not user_prompt or not chatui_session_id or not session or session.display_name: | ||||||
| return | ||||||
|
|
||||||
| llm_resp = await prov.text_chat( | ||||||
| system_prompt=( | ||||||
| "You are a conversation title generator. " | ||||||
| "Generate a concise title in the same language as the user’s input, " | ||||||
| "no more than 10 words, capturing only the core topic." | ||||||
| "If the input is a greeting, small talk, or has no clear topic, " | ||||||
| "(e.g., “hi”, “hello”, “haha”), return <None>. " | ||||||
| "Output only the title itself or <None>, with no explanations." | ||||||
| ), | ||||||
| prompt=f"Generate a concise title for the following user query:\n{user_prompt}", | ||||||
| ) | ||||||
| try: | ||||||
| llm_resp = await prov.text_chat( | ||||||
| system_prompt=( | ||||||
| "You are a conversation title generator. " | ||||||
| "Generate a concise title in the same language as the user’s input, " | ||||||
| "no more than 10 words, capturing only the core topic." | ||||||
| "If the input is a greeting, small talk, or has no clear topic, " | ||||||
| "(e.g., “hi”, “hello”, “haha”), return <None>. " | ||||||
| "Output only the title itself or <None>, with no explanations." | ||||||
| ), | ||||||
| prompt=f"Generate a concise title for the following user query:\n{user_prompt}", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The conversation title generation logic in To remediate this, use delimiters to wrap the user input and update the system prompt to only consider the content within those delimiters. Additionally, ensure the output is sanitized before storage and rendering.
Suggested change
|
||||||
| ) | ||||||
| except Exception: | ||||||
| logger.exception( | ||||||
| "Failed to generate webchat title for session %s", chatui_session_id | ||||||
| ) | ||||||
| return | ||||||
| if llm_resp and llm_resp.completion_text: | ||||||
| title = llm_resp.completion_text.strip() | ||||||
| if not title or "<None>" in title: | ||||||
|
|
@@ -813,7 +819,7 @@ def _apply_sandbox_tools( | |||||
| req.func_tool.add_tool(PYTHON_TOOL) | ||||||
| req.func_tool.add_tool(FILE_UPLOAD_TOOL) | ||||||
| req.func_tool.add_tool(FILE_DOWNLOAD_TOOL) | ||||||
| req.system_prompt += f"\n{SANDBOX_MODE_PROMPT}\n" | ||||||
| req.system_prompt = f"{req.system_prompt or ''}\n{SANDBOX_MODE_PROMPT}\n" | ||||||
|
|
||||||
|
|
||||||
| def _proactive_cron_job_tools(req: ProviderRequest) -> None: | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,22 @@ | ||
| from .manager import CronJobManager | ||
| """Cron package exports. | ||
| Keep `CronJobManager` import-compatible while avoiding hard import failure when | ||
| `apscheduler` is partially mocked in test environments. | ||
| """ | ||
|
|
||
| try: | ||
| from .manager import CronJobManager | ||
| except ModuleNotFoundError as exc: | ||
| if not (exc.name and exc.name.startswith("apscheduler")): | ||
| raise | ||
|
|
||
| _IMPORT_ERROR = exc | ||
|
|
||
| class CronJobManager: | ||
| def __init__(self, *args, **kwargs) -> None: | ||
| raise ModuleNotFoundError( | ||
| "CronJobManager requires a complete `apscheduler` installation." | ||
| ) from _IMPORT_ERROR | ||
|
|
||
|
|
||
| __all__ = ["CronJobManager"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import error:
astrbot.core.star.basemodule does not exist. The Star class is defined inastrbot.core.star.__init__.py, not in a separatebase.pyfile. This import should be changed tofrom astrbot.core.star import Star.