zrb 1.15.3__py3-none-any.whl → 2.0.0a4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of zrb might be problematic. Click here for more details.
- zrb/__init__.py +118 -133
- zrb/attr/type.py +10 -7
- zrb/builtin/__init__.py +55 -1
- zrb/builtin/git.py +12 -1
- zrb/builtin/group.py +31 -15
- zrb/builtin/llm/chat.py +147 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/add_entity_util.py +7 -7
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/add_module_util.py +5 -5
- zrb/builtin/project/add/fastapp/fastapp_util.py +1 -1
- zrb/builtin/searxng/config/settings.yml +5671 -0
- zrb/builtin/searxng/start.py +21 -0
- zrb/builtin/shell/autocomplete/bash.py +4 -3
- zrb/builtin/shell/autocomplete/zsh.py +4 -3
- zrb/callback/callback.py +8 -1
- zrb/cmd/cmd_result.py +2 -1
- zrb/config/config.py +555 -169
- zrb/config/helper.py +84 -0
- zrb/config/web_auth_config.py +50 -35
- zrb/context/any_shared_context.py +20 -3
- zrb/context/context.py +39 -5
- zrb/context/print_fn.py +13 -0
- zrb/context/shared_context.py +17 -8
- zrb/group/any_group.py +3 -3
- zrb/group/group.py +3 -3
- zrb/input/any_input.py +5 -1
- zrb/input/base_input.py +18 -6
- zrb/input/option_input.py +41 -1
- zrb/input/text_input.py +7 -24
- zrb/llm/agent/__init__.py +9 -0
- zrb/llm/agent/agent.py +215 -0
- zrb/llm/agent/summarizer.py +20 -0
- zrb/llm/app/__init__.py +10 -0
- zrb/llm/app/completion.py +281 -0
- zrb/llm/app/confirmation/allow_tool.py +66 -0
- zrb/llm/app/confirmation/handler.py +178 -0
- zrb/llm/app/confirmation/replace_confirmation.py +77 -0
- zrb/llm/app/keybinding.py +34 -0
- zrb/llm/app/layout.py +117 -0
- zrb/llm/app/lexer.py +155 -0
- zrb/llm/app/redirection.py +28 -0
- zrb/llm/app/style.py +16 -0
- zrb/llm/app/ui.py +733 -0
- zrb/llm/config/__init__.py +4 -0
- zrb/llm/config/config.py +122 -0
- zrb/llm/config/limiter.py +247 -0
- zrb/llm/history_manager/__init__.py +4 -0
- zrb/llm/history_manager/any_history_manager.py +23 -0
- zrb/llm/history_manager/file_history_manager.py +91 -0
- zrb/llm/history_processor/summarizer.py +108 -0
- zrb/llm/note/__init__.py +3 -0
- zrb/llm/note/manager.py +122 -0
- zrb/llm/prompt/__init__.py +29 -0
- zrb/llm/prompt/claude_compatibility.py +92 -0
- zrb/llm/prompt/compose.py +55 -0
- zrb/llm/prompt/default.py +51 -0
- zrb/llm/prompt/markdown/file_extractor.md +112 -0
- zrb/llm/prompt/markdown/mandate.md +23 -0
- zrb/llm/prompt/markdown/persona.md +3 -0
- zrb/llm/prompt/markdown/repo_extractor.md +112 -0
- zrb/llm/prompt/markdown/repo_summarizer.md +29 -0
- zrb/llm/prompt/markdown/summarizer.md +21 -0
- zrb/llm/prompt/note.py +41 -0
- zrb/llm/prompt/system_context.py +46 -0
- zrb/llm/prompt/zrb.py +41 -0
- zrb/llm/skill/__init__.py +3 -0
- zrb/llm/skill/manager.py +86 -0
- zrb/llm/task/__init__.py +4 -0
- zrb/llm/task/llm_chat_task.py +316 -0
- zrb/llm/task/llm_task.py +245 -0
- zrb/llm/tool/__init__.py +39 -0
- zrb/llm/tool/bash.py +75 -0
- zrb/llm/tool/code.py +266 -0
- zrb/llm/tool/file.py +419 -0
- zrb/llm/tool/note.py +70 -0
- zrb/{builtin/llm → llm}/tool/rag.py +33 -37
- zrb/llm/tool/search/brave.py +53 -0
- zrb/llm/tool/search/searxng.py +47 -0
- zrb/llm/tool/search/serpapi.py +47 -0
- zrb/llm/tool/skill.py +19 -0
- zrb/llm/tool/sub_agent.py +70 -0
- zrb/llm/tool/web.py +97 -0
- zrb/llm/tool/zrb_task.py +66 -0
- zrb/llm/util/attachment.py +101 -0
- zrb/llm/util/prompt.py +104 -0
- zrb/llm/util/stream_response.py +178 -0
- zrb/runner/cli.py +21 -20
- zrb/runner/common_util.py +24 -19
- zrb/runner/web_route/task_input_api_route.py +5 -5
- zrb/runner/web_util/user.py +7 -3
- zrb/session/any_session.py +12 -9
- zrb/session/session.py +38 -17
- zrb/task/any_task.py +24 -3
- zrb/task/base/context.py +42 -22
- zrb/task/base/execution.py +67 -55
- zrb/task/base/lifecycle.py +14 -7
- zrb/task/base/monitoring.py +12 -7
- zrb/task/base_task.py +113 -50
- zrb/task/base_trigger.py +16 -6
- zrb/task/cmd_task.py +6 -0
- zrb/task/http_check.py +11 -5
- zrb/task/make_task.py +5 -3
- zrb/task/rsync_task.py +30 -10
- zrb/task/scaffolder.py +7 -4
- zrb/task/scheduler.py +7 -4
- zrb/task/tcp_check.py +6 -4
- zrb/util/ascii_art/art/bee.txt +17 -0
- zrb/util/ascii_art/art/cat.txt +9 -0
- zrb/util/ascii_art/art/ghost.txt +16 -0
- zrb/util/ascii_art/art/panda.txt +17 -0
- zrb/util/ascii_art/art/rose.txt +14 -0
- zrb/util/ascii_art/art/unicorn.txt +15 -0
- zrb/util/ascii_art/banner.py +92 -0
- zrb/util/attr.py +54 -39
- zrb/util/cli/markdown.py +32 -0
- zrb/util/cli/text.py +30 -0
- zrb/util/cmd/command.py +33 -10
- zrb/util/file.py +61 -33
- zrb/util/git.py +2 -2
- zrb/util/{llm/prompt.py → markdown.py} +2 -3
- zrb/util/match.py +78 -0
- zrb/util/run.py +3 -3
- zrb/util/string/conversion.py +1 -1
- zrb/util/truncate.py +23 -0
- zrb/util/yaml.py +204 -0
- zrb/xcom/xcom.py +10 -0
- {zrb-1.15.3.dist-info → zrb-2.0.0a4.dist-info}/METADATA +41 -27
- {zrb-1.15.3.dist-info → zrb-2.0.0a4.dist-info}/RECORD +129 -131
- {zrb-1.15.3.dist-info → zrb-2.0.0a4.dist-info}/WHEEL +1 -1
- zrb/attr/__init__.py +0 -0
- zrb/builtin/llm/chat_session.py +0 -311
- zrb/builtin/llm/history.py +0 -71
- zrb/builtin/llm/input.py +0 -27
- zrb/builtin/llm/llm_ask.py +0 -187
- zrb/builtin/llm/previous-session.js +0 -21
- zrb/builtin/llm/tool/__init__.py +0 -0
- zrb/builtin/llm/tool/api.py +0 -71
- zrb/builtin/llm/tool/cli.py +0 -38
- zrb/builtin/llm/tool/code.py +0 -254
- zrb/builtin/llm/tool/file.py +0 -626
- zrb/builtin/llm/tool/sub_agent.py +0 -137
- zrb/builtin/llm/tool/web.py +0 -195
- zrb/builtin/project/__init__.py +0 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/__init__.py +0 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/app_template/module/my_module/service/__init__.py +0 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/common/__init__.py +0 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/__init__.py +0 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/__init__.py +0 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/permission/__init__.py +0 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/role/__init__.py +0 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/user/__init__.py +0 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/schema/__init__.py +0 -0
- zrb/builtin/project/create/__init__.py +0 -0
- zrb/builtin/shell/__init__.py +0 -0
- zrb/builtin/shell/autocomplete/__init__.py +0 -0
- zrb/callback/__init__.py +0 -0
- zrb/cmd/__init__.py +0 -0
- zrb/config/default_prompt/file_extractor_system_prompt.md +0 -12
- zrb/config/default_prompt/interactive_system_prompt.md +0 -35
- zrb/config/default_prompt/persona.md +0 -1
- zrb/config/default_prompt/repo_extractor_system_prompt.md +0 -112
- zrb/config/default_prompt/repo_summarizer_system_prompt.md +0 -10
- zrb/config/default_prompt/summarization_prompt.md +0 -16
- zrb/config/default_prompt/system_prompt.md +0 -32
- zrb/config/llm_config.py +0 -243
- zrb/config/llm_context/config.py +0 -129
- zrb/config/llm_context/config_parser.py +0 -46
- zrb/config/llm_rate_limitter.py +0 -137
- zrb/content_transformer/__init__.py +0 -0
- zrb/context/__init__.py +0 -0
- zrb/dot_dict/__init__.py +0 -0
- zrb/env/__init__.py +0 -0
- zrb/group/__init__.py +0 -0
- zrb/input/__init__.py +0 -0
- zrb/runner/__init__.py +0 -0
- zrb/runner/web_route/__init__.py +0 -0
- zrb/runner/web_route/home_page/__init__.py +0 -0
- zrb/session/__init__.py +0 -0
- zrb/session_state_log/__init__.py +0 -0
- zrb/session_state_logger/__init__.py +0 -0
- zrb/task/__init__.py +0 -0
- zrb/task/base/__init__.py +0 -0
- zrb/task/llm/__init__.py +0 -0
- zrb/task/llm/agent.py +0 -243
- zrb/task/llm/config.py +0 -103
- zrb/task/llm/conversation_history.py +0 -128
- zrb/task/llm/conversation_history_model.py +0 -242
- zrb/task/llm/default_workflow/coding.md +0 -24
- zrb/task/llm/default_workflow/copywriting.md +0 -17
- zrb/task/llm/default_workflow/researching.md +0 -18
- zrb/task/llm/error.py +0 -95
- zrb/task/llm/history_summarization.py +0 -216
- zrb/task/llm/print_node.py +0 -101
- zrb/task/llm/prompt.py +0 -325
- zrb/task/llm/tool_wrapper.py +0 -220
- zrb/task/llm/typing.py +0 -3
- zrb/task/llm_task.py +0 -341
- zrb/task_status/__init__.py +0 -0
- zrb/util/__init__.py +0 -0
- zrb/util/cli/__init__.py +0 -0
- zrb/util/cmd/__init__.py +0 -0
- zrb/util/codemod/__init__.py +0 -0
- zrb/util/string/__init__.py +0 -0
- zrb/xcom/__init__.py +0 -0
- {zrb-1.15.3.dist-info → zrb-2.0.0a4.dist-info}/entry_points.txt +0 -0
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
from collections.abc import Callable
|
|
3
|
-
from textwrap import dedent
|
|
4
|
-
from typing import TYPE_CHECKING, Any, Coroutine
|
|
5
|
-
|
|
6
|
-
from zrb.context.any_context import AnyContext
|
|
7
|
-
from zrb.task.llm.agent import create_agent_instance, run_agent_iteration
|
|
8
|
-
from zrb.task.llm.config import get_model, get_model_settings
|
|
9
|
-
from zrb.task.llm.prompt import get_system_and_user_prompt
|
|
10
|
-
|
|
11
|
-
if TYPE_CHECKING:
|
|
12
|
-
from pydantic_ai import Agent, Tool
|
|
13
|
-
from pydantic_ai.models import Model
|
|
14
|
-
from pydantic_ai.settings import ModelSettings
|
|
15
|
-
from pydantic_ai.toolsets import AbstractToolset
|
|
16
|
-
|
|
17
|
-
ToolOrCallable = Tool | Callable
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def create_sub_agent_tool(
|
|
21
|
-
tool_name: str,
|
|
22
|
-
tool_description: str,
|
|
23
|
-
system_prompt: str | None = None,
|
|
24
|
-
model: "str | Model | None" = None,
|
|
25
|
-
model_settings: "ModelSettings | None" = None,
|
|
26
|
-
tools: "list[ToolOrCallable]" = [],
|
|
27
|
-
toolsets: list["AbstractToolset[Agent]"] = [],
|
|
28
|
-
is_yolo_mode: bool | None = None,
|
|
29
|
-
) -> Callable[[AnyContext, str], Coroutine[Any, Any, str]]:
|
|
30
|
-
"""
|
|
31
|
-
Creates a "tool that is another AI agent," capable of handling complex,
|
|
32
|
-
multi-step sub-tasks.
|
|
33
|
-
|
|
34
|
-
This powerful factory function generates a tool that, when used, spins up
|
|
35
|
-
a temporary, specialized AI agent. This "sub-agent" has its own system
|
|
36
|
-
prompt, tools, and context, allowing it to focus exclusively on
|
|
37
|
-
accomplishing the task it's given without being distracted by the main
|
|
38
|
-
conversation.
|
|
39
|
-
|
|
40
|
-
This is ideal for delegating complex tasks like analyzing a file or a
|
|
41
|
-
repository.
|
|
42
|
-
|
|
43
|
-
Args:
|
|
44
|
-
tool_name (str): The name for the generated sub-agent tool.
|
|
45
|
-
tool_description (str): A clear description of the sub-agent's purpose
|
|
46
|
-
and when to use it.
|
|
47
|
-
system_prompt (str, optional): The system prompt that will guide the
|
|
48
|
-
sub-agent's behavior.
|
|
49
|
-
model (str | Model, optional): The language model the sub-agent will
|
|
50
|
-
use.
|
|
51
|
-
model_settings (ModelSettings, optional): Specific settings for the
|
|
52
|
-
sub-agent's model.
|
|
53
|
-
tools (list, optional): A list of tools that will be exclusively
|
|
54
|
-
available to the sub-agent.
|
|
55
|
-
toolsets (list, optional): A list of Toolset for the sub-agent.
|
|
56
|
-
|
|
57
|
-
Returns:
|
|
58
|
-
Callable: An asynchronous function that serves as the sub-agent tool.
|
|
59
|
-
When called, it runs the sub-agent with a given query and returns
|
|
60
|
-
its final result.
|
|
61
|
-
"""
|
|
62
|
-
|
|
63
|
-
async def run_sub_agent(ctx: AnyContext, query: str) -> str:
|
|
64
|
-
"""
|
|
65
|
-
Runs the sub-agent with the given query.
|
|
66
|
-
"""
|
|
67
|
-
# Resolve parameters, falling back to llm_config defaults if None
|
|
68
|
-
resolved_model = get_model(
|
|
69
|
-
ctx=ctx,
|
|
70
|
-
model_attr=model,
|
|
71
|
-
render_model=True, # Assuming we always want to render model string attributes
|
|
72
|
-
model_base_url_attr=None,
|
|
73
|
-
# Sub-agent tool doesn't have separate base_url/api_key params
|
|
74
|
-
render_model_base_url=False,
|
|
75
|
-
model_api_key_attr=None,
|
|
76
|
-
render_model_api_key=False,
|
|
77
|
-
)
|
|
78
|
-
resolved_model_settings = get_model_settings(
|
|
79
|
-
ctx=ctx,
|
|
80
|
-
model_settings_attr=model_settings,
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
if system_prompt is None:
|
|
84
|
-
resolved_system_prompt, query = get_system_and_user_prompt(
|
|
85
|
-
ctx=ctx,
|
|
86
|
-
user_message=query,
|
|
87
|
-
persona_attr=None,
|
|
88
|
-
system_prompt_attr=None,
|
|
89
|
-
special_instruction_prompt_attr=None,
|
|
90
|
-
)
|
|
91
|
-
else:
|
|
92
|
-
resolved_system_prompt = system_prompt
|
|
93
|
-
# Create the sub-agent instance
|
|
94
|
-
sub_agent_agent = create_agent_instance(
|
|
95
|
-
ctx=ctx,
|
|
96
|
-
model=resolved_model,
|
|
97
|
-
system_prompt=resolved_system_prompt,
|
|
98
|
-
model_settings=resolved_model_settings,
|
|
99
|
-
tools=tools,
|
|
100
|
-
toolsets=toolsets,
|
|
101
|
-
is_yolo_mode=is_yolo_mode,
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
sub_agent_run = None
|
|
105
|
-
# Run the sub-agent iteration
|
|
106
|
-
# Start with an empty history for the sub-agent
|
|
107
|
-
sub_agent_run = await run_agent_iteration(
|
|
108
|
-
ctx=ctx,
|
|
109
|
-
agent=sub_agent_agent,
|
|
110
|
-
user_prompt=query,
|
|
111
|
-
attachments=[],
|
|
112
|
-
history_list=[],
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
# Return the sub-agent's final message content
|
|
116
|
-
if sub_agent_run and sub_agent_run.result:
|
|
117
|
-
# Return the final message content as a string
|
|
118
|
-
return json.dumps({"result": sub_agent_run.result.output})
|
|
119
|
-
else:
|
|
120
|
-
ctx.log_warning("Sub-agent run did not produce a result.")
|
|
121
|
-
return "Sub-agent failed to produce a result."
|
|
122
|
-
|
|
123
|
-
# Set the name and docstring for the callable function
|
|
124
|
-
run_sub_agent.__name__ = tool_name
|
|
125
|
-
run_sub_agent.__doc__ = dedent(
|
|
126
|
-
f"""
|
|
127
|
-
{tool_description}
|
|
128
|
-
|
|
129
|
-
Args:
|
|
130
|
-
query (str): The query or task for the sub-agent.
|
|
131
|
-
|
|
132
|
-
Returns:
|
|
133
|
-
str: The final response or result from the sub-agent.
|
|
134
|
-
"""
|
|
135
|
-
).strip()
|
|
136
|
-
|
|
137
|
-
return run_sub_agent
|
zrb/builtin/llm/tool/web.py
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
from collections.abc import Callable
|
|
3
|
-
from urllib.parse import urljoin
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
async def open_web_page(url: str) -> str:
|
|
7
|
-
"""
|
|
8
|
-
Fetches, parses, and converts the content of a web page to Markdown.
|
|
9
|
-
|
|
10
|
-
This tool "reads" a web page by fetching its content, stripping away
|
|
11
|
-
non-essential elements like scripts and styles, and then converting the
|
|
12
|
-
cleaned HTML into Markdown format. This preserves the semantic structure
|
|
13
|
-
of the content (headings, lists, etc.) while removing clutter. It also
|
|
14
|
-
extracts all hyperlinks and resolves them to absolute URLs.
|
|
15
|
-
|
|
16
|
-
Args:
|
|
17
|
-
url (str): The full URL of the web page to open (e.g.,
|
|
18
|
-
"https://example.com/article").
|
|
19
|
-
|
|
20
|
-
Returns:
|
|
21
|
-
str: A JSON object containing the page's content in Markdown format
|
|
22
|
-
and a list of all absolute links found on the page.
|
|
23
|
-
"""
|
|
24
|
-
html_content, links = await _fetch_page_content(url)
|
|
25
|
-
markdown_content = _convert_html_to_markdown(html_content)
|
|
26
|
-
return json.dumps({"content": markdown_content, "links_on_page": links})
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def create_search_internet_tool(serp_api_key: str) -> Callable[[str, int], str]:
|
|
30
|
-
"""
|
|
31
|
-
Creates a tool that searches the internet using the SerpAPI Google Search
|
|
32
|
-
API.
|
|
33
|
-
|
|
34
|
-
This factory returns a function that can be used to find information on the
|
|
35
|
-
web. The generated tool is the primary way to answer general knowledge
|
|
36
|
-
questions or to find information on topics you are unfamiliar with.
|
|
37
|
-
|
|
38
|
-
Args:
|
|
39
|
-
serp_api_key (str): The API key for SerpAPI.
|
|
40
|
-
|
|
41
|
-
Returns:
|
|
42
|
-
Callable: A function that takes a search query and returns a list of
|
|
43
|
-
search results.
|
|
44
|
-
"""
|
|
45
|
-
|
|
46
|
-
def search_internet(query: str, num_results: int = 10) -> str:
|
|
47
|
-
"""
|
|
48
|
-
Performs an internet search using Google and returns a summary of the results.
|
|
49
|
-
|
|
50
|
-
Use this tool to find information on the web, answer general knowledge questions, or research topics.
|
|
51
|
-
|
|
52
|
-
Args:
|
|
53
|
-
query (str): The search query.
|
|
54
|
-
num_results (int, optional): The desired number of search results. Defaults to 10.
|
|
55
|
-
|
|
56
|
-
Returns:
|
|
57
|
-
str: A formatted string summarizing the search results, including titles, links, and snippets.
|
|
58
|
-
"""
|
|
59
|
-
import requests
|
|
60
|
-
|
|
61
|
-
response = requests.get(
|
|
62
|
-
"https://serpapi.com/search",
|
|
63
|
-
headers={
|
|
64
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
|
|
65
|
-
},
|
|
66
|
-
params={
|
|
67
|
-
"q": query,
|
|
68
|
-
"num": num_results,
|
|
69
|
-
"hl": "en",
|
|
70
|
-
"safe": "off",
|
|
71
|
-
"api_key": serp_api_key,
|
|
72
|
-
},
|
|
73
|
-
)
|
|
74
|
-
if response.status_code != 200:
|
|
75
|
-
raise Exception(
|
|
76
|
-
f"Error: Unable to retrieve search results (status code: {response.status_code})"
|
|
77
|
-
)
|
|
78
|
-
return response.json()
|
|
79
|
-
|
|
80
|
-
return search_internet
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def search_wikipedia(query: str) -> str:
|
|
84
|
-
"""
|
|
85
|
-
Searches for articles on Wikipedia.
|
|
86
|
-
|
|
87
|
-
This is a specialized search tool for querying Wikipedia. It's best for
|
|
88
|
-
when the user is asking for definitions, historical information, or
|
|
89
|
-
biographical details that are likely to be found on an encyclopedia.
|
|
90
|
-
|
|
91
|
-
Args:
|
|
92
|
-
query (str): The search term or question.
|
|
93
|
-
|
|
94
|
-
Returns:
|
|
95
|
-
str: The raw JSON response from the Wikipedia API, containing a list of
|
|
96
|
-
search results.
|
|
97
|
-
"""
|
|
98
|
-
import requests
|
|
99
|
-
|
|
100
|
-
params = {"action": "query", "list": "search", "srsearch": query, "format": "json"}
|
|
101
|
-
response = requests.get("https://en.wikipedia.org/w/api.php", params=params)
|
|
102
|
-
return response.json()
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
def search_arxiv(query: str, num_results: int = 10) -> str:
|
|
106
|
-
"""
|
|
107
|
-
Searches for academic papers and preprints on ArXiv.
|
|
108
|
-
|
|
109
|
-
Use this tool when the user's query is scientific or technical in nature
|
|
110
|
-
and they are likely looking for research papers, articles, or academic
|
|
111
|
-
publications.
|
|
112
|
-
|
|
113
|
-
Args:
|
|
114
|
-
query (str): The search query, which can include keywords, author
|
|
115
|
-
names, or titles.
|
|
116
|
-
num_results (int, optional): The maximum number of results to return.
|
|
117
|
-
Defaults to 10.
|
|
118
|
-
|
|
119
|
-
Returns:
|
|
120
|
-
str: The raw XML response from the ArXiv API, containing a list of
|
|
121
|
-
matching papers.
|
|
122
|
-
"""
|
|
123
|
-
import requests
|
|
124
|
-
|
|
125
|
-
params = {"search_query": f"all:{query}", "start": 0, "max_results": num_results}
|
|
126
|
-
response = requests.get("http://export.arxiv.org/api/query", params=params)
|
|
127
|
-
return response.content
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
async def _fetch_page_content(url: str) -> tuple[str, list[str]]:
|
|
131
|
-
"""Fetches the HTML content and all absolute links from a URL."""
|
|
132
|
-
user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
|
|
133
|
-
try:
|
|
134
|
-
from playwright.async_api import async_playwright
|
|
135
|
-
|
|
136
|
-
async with async_playwright() as p:
|
|
137
|
-
browser = await p.chromium.launch(headless=True)
|
|
138
|
-
page = await browser.new_page()
|
|
139
|
-
await page.set_extra_http_headers({"User-Agent": user_agent})
|
|
140
|
-
try:
|
|
141
|
-
await page.goto(url, wait_until="networkidle", timeout=30000)
|
|
142
|
-
await page.wait_for_load_state("domcontentloaded")
|
|
143
|
-
content = await page.content()
|
|
144
|
-
links = await page.eval_on_selector_all(
|
|
145
|
-
"a[href]",
|
|
146
|
-
"""
|
|
147
|
-
(elements, baseUrl) => elements.map(el => {
|
|
148
|
-
const href = el.getAttribute('href');
|
|
149
|
-
if (!href || href.startsWith('#')) return null;
|
|
150
|
-
try {
|
|
151
|
-
return new URL(href, baseUrl).href;
|
|
152
|
-
} catch (e) {
|
|
153
|
-
return null;
|
|
154
|
-
}
|
|
155
|
-
}).filter(href => href !== null)
|
|
156
|
-
""",
|
|
157
|
-
url,
|
|
158
|
-
)
|
|
159
|
-
return content, links
|
|
160
|
-
# return json.dumps({"content": content, "links": links})
|
|
161
|
-
finally:
|
|
162
|
-
await browser.close()
|
|
163
|
-
except Exception:
|
|
164
|
-
import requests
|
|
165
|
-
from bs4 import BeautifulSoup
|
|
166
|
-
|
|
167
|
-
response = requests.get(url, headers={"User-Agent": user_agent})
|
|
168
|
-
if response.status_code != 200:
|
|
169
|
-
raise Exception(
|
|
170
|
-
f"Unable to retrieve page content. Status code: {response.status_code}"
|
|
171
|
-
)
|
|
172
|
-
content = response.text
|
|
173
|
-
soup = BeautifulSoup(content, "html.parser")
|
|
174
|
-
links = [
|
|
175
|
-
urljoin(url, a["href"])
|
|
176
|
-
for a in soup.find_all("a", href=True)
|
|
177
|
-
if not a["href"].startswith("#")
|
|
178
|
-
]
|
|
179
|
-
return content, links
|
|
180
|
-
# return json.dumps({"content": content, "links": links})
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
def _convert_html_to_markdown(html_text: str) -> str:
|
|
184
|
-
"""Converts HTML content to a clean Markdown representation."""
|
|
185
|
-
from bs4 import BeautifulSoup
|
|
186
|
-
from markdownify import markdownify as md
|
|
187
|
-
|
|
188
|
-
soup = BeautifulSoup(html_text, "html.parser")
|
|
189
|
-
# Remove non-content tags
|
|
190
|
-
for tag in soup(
|
|
191
|
-
["script", "link", "meta", "style", "header", "footer", "nav", "aside"]
|
|
192
|
-
):
|
|
193
|
-
tag.decompose()
|
|
194
|
-
# Convert the cleaned HTML to Markdown
|
|
195
|
-
return md(str(soup))
|
zrb/builtin/project/__init__.py
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/__init__.py
DELETED
|
File without changes
|
|
File without changes
|
zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/role/__init__.py
DELETED
|
File without changes
|
zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/user/__init__.py
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
zrb/builtin/shell/__init__.py
DELETED
|
File without changes
|
|
File without changes
|
zrb/callback/__init__.py
DELETED
|
File without changes
|
zrb/cmd/__init__.py
DELETED
|
File without changes
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
You are an intelligent code and configuration analysis agent.
|
|
2
|
-
Your primary goal is to extract key information from the provided file(s) that is directly relevant to the main assistant's objective.
|
|
3
|
-
|
|
4
|
-
Analyze the file content and determine its type (e.g., Python script, YAML configuration, Dockerfile, Markdown documentation).
|
|
5
|
-
Based on the file type, extract the most important information in a structured markdown format.
|
|
6
|
-
|
|
7
|
-
- For source code (e.g., .py, .js, .go): Extract key components like classes, functions, important variables, and their purposes.
|
|
8
|
-
- For configuration files (e.g., .yaml, .toml, .json): Extract the main configuration sections, keys, and their values.
|
|
9
|
-
- For infrastructure files (e.g., Dockerfile, .tf): Extract resources, settings, and commands.
|
|
10
|
-
- For documentation (e.g., .md): Extract headings, summaries, code blocks, and links.
|
|
11
|
-
|
|
12
|
-
Focus on quality and relevance over quantity. The output should be a concise yet comprehensive summary that directly helps the main assistant achieve its goal.
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
You are an expert interactive AI agent. You MUST follow this workflow for this interactive session. Respond in GitHub-flavored Markdown.
|
|
2
|
-
|
|
3
|
-
# Core Principles
|
|
4
|
-
- **Be Tool-Centric:** Do not describe what you are about to do. When a decision is made, call the tool directly. Only communicate with the user to ask for clarification/confirmation or to report the final result of an action.
|
|
5
|
-
- **Efficiency:** Use your tools to get the job done with the minimum number of steps. Combine commands where possible.
|
|
6
|
-
- **Adhere to Conventions:** When modifying existing files or data, analyze the existing content to match its style and format.
|
|
7
|
-
|
|
8
|
-
# Interactive Workflow
|
|
9
|
-
1. **Clarify and Plan:** Understand the user's goal.
|
|
10
|
-
* If a request is **ambiguous**, ask clarifying questions.
|
|
11
|
-
* For **complex tasks**, briefly state your plan and proceed.
|
|
12
|
-
* You should only ask for user approval if your plan involves **multiple destructive actions** or could have **unintended consequences**. For straightforward creative or low-risk destructive tasks (e.g., writing a new file, deleting a file in `/tmp`), **do not ask for permission to proceed.**
|
|
13
|
-
|
|
14
|
-
2. **Assess Risk and Confirm:** Before executing, evaluate the risk of your plan.
|
|
15
|
-
* **Read-only or new file creation:** Proceed directly.
|
|
16
|
-
* **Destructive actions (modifying or deleting existing files):** For low-risk destructive actions, proceed directly. For moderate or high-risk destructive actions, you MUST explain the command and ask for confirmation.
|
|
17
|
-
* **High-risk actions (e.g., operating on critical system paths):** Refuse and explain the danger.
|
|
18
|
-
|
|
19
|
-
3. **Execute and Verify (The E+V Loop):**
|
|
20
|
-
* Execute the action.
|
|
21
|
-
* **CRITICAL:** Immediately after execution, you MUST use a tool to verify the outcome (e.g., after `write_file`, use `read_file`; after `rm`, use `ls` to confirm absence).
|
|
22
|
-
|
|
23
|
-
4. **Handle Errors (The Debugging Loop):**
|
|
24
|
-
* If an action fails, you MUST NOT give up. You MUST enter a persistent debugging loop until the error is resolved.
|
|
25
|
-
1. **Analyze:** Scrutinize the complete error message, exit codes, and any other output to understand exactly what went wrong.
|
|
26
|
-
2. **Hypothesize:** State a clear, specific hypothesis about the root cause. For example, "The operation failed because the file path was incorrect," "The command failed because a required argument was missing," or "The test failed because the code has a logical error."
|
|
27
|
-
3. **Strategize and Correct:** Formulate a new action that directly addresses the hypothesis. Do not simply repeat the failed action. Your correction strategy MUST be logical and informed by the analysis. For example:
|
|
28
|
-
* If a path is wrong, take action to discover the correct path.
|
|
29
|
-
* If a command is malformed, correct its syntax or arguments.
|
|
30
|
-
* If an operation failed due to invalid state (e.g., unexpected file content, a logical bug in code), take action to inspect the current state and then formulate a targeted fix.
|
|
31
|
-
4. **Execute** the corrected action.
|
|
32
|
-
* **CRITICAL:** Do not ask the user for help or report the failure until you have exhausted all reasonable attempts to fix it yourself. If the user provides a vague follow-up like "try again," you MUST use the context of the previous failure to inform your next action, not just repeat the failed command.
|
|
33
|
-
|
|
34
|
-
5. **Report Results:**
|
|
35
|
-
* Provide a concise summary of the action taken and explicitly state how you verified it.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
You are a helpful and efficient AI agent.
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
You are an expert code and configuration analysis agent. Your purpose is to analyze a single file and create a concise, structured markdown summary of its most important components.
|
|
2
|
-
|
|
3
|
-
### Instructions
|
|
4
|
-
|
|
5
|
-
1. **Analyze File Content**: Determine the file's type (e.g., Python, Dockerfile, YAML, Markdown).
|
|
6
|
-
2. **Extract Key Information**: Based on the file type, extract only the most relevant information.
|
|
7
|
-
* **Source Code** (`.py`, `.js`, `.go`): Extract classes, functions, key variables, and their purpose.
|
|
8
|
-
* **Configuration** (`.yaml`, `.toml`, `.json`): Extract main sections, keys, and values.
|
|
9
|
-
* **Infrastructure** (`Dockerfile`, `.tf`): Extract resources, settings, and commands.
|
|
10
|
-
* **Documentation** (`.md`): Extract headings, summaries, and code blocks.
|
|
11
|
-
3. **Format Output**: Present the summary in structured markdown.
|
|
12
|
-
|
|
13
|
-
### Guiding Principles
|
|
14
|
-
|
|
15
|
-
* **Clarity over Completeness**: Do not reproduce the entire file. Capture its essence.
|
|
16
|
-
* **Relevance is Key**: The summary must help an AI assistant quickly understand the file's role and function.
|
|
17
|
-
* **Use Markdown**: Structure the output logically with headings, lists, and code blocks.
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
### Examples
|
|
22
|
-
|
|
23
|
-
Here are examples of the expected output.
|
|
24
|
-
|
|
25
|
-
#### Example 1: Python Source File (`database.py`)
|
|
26
|
-
|
|
27
|
-
**Input File:**
|
|
28
|
-
```python
|
|
29
|
-
# src/database.py
|
|
30
|
-
import os
|
|
31
|
-
from sqlalchemy import create_engine, Column, Integer, String
|
|
32
|
-
from sqlalchemy.ext.declarative import declarative_base
|
|
33
|
-
from sqlalchemy.orm import sessionmaker
|
|
34
|
-
|
|
35
|
-
DATABASE_URL = os.getenv("DATABASE_URL", "sqlite:///./test.db")
|
|
36
|
-
|
|
37
|
-
engine = create_engine(DATABASE_URL)
|
|
38
|
-
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
|
39
|
-
Base = declarative_base()
|
|
40
|
-
|
|
41
|
-
class User(Base):
|
|
42
|
-
__tablename__ = "users"
|
|
43
|
-
id = Column(Integer, primary_key=True, index=True)
|
|
44
|
-
username = Column(String, unique=True, index=True)
|
|
45
|
-
email = Column(String, unique=True, index=True)
|
|
46
|
-
|
|
47
|
-
def get_db():
|
|
48
|
-
db = SessionLocal()
|
|
49
|
-
try:
|
|
50
|
-
yield db
|
|
51
|
-
finally:
|
|
52
|
-
db.close()
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
**Expected Markdown Output:**
|
|
56
|
-
```markdown
|
|
57
|
-
### File Summary: `src/database.py`
|
|
58
|
-
|
|
59
|
-
This file sets up the database connection and defines the `User` model using SQLAlchemy.
|
|
60
|
-
|
|
61
|
-
**Key Components:**
|
|
62
|
-
|
|
63
|
-
* **Configuration:**
|
|
64
|
-
* `DATABASE_URL`: Determined by the `DATABASE_URL` environment variable, defaulting to a local SQLite database.
|
|
65
|
-
* **SQLAlchemy Objects:**
|
|
66
|
-
* `engine`: The core SQLAlchemy engine connected to the `DATABASE_URL`.
|
|
67
|
-
* `SessionLocal`: A factory for creating new database sessions.
|
|
68
|
-
* `Base`: The declarative base for ORM models.
|
|
69
|
-
* **ORM Models:**
|
|
70
|
-
* **`User` class:**
|
|
71
|
-
* Table: `users`
|
|
72
|
-
* Columns: `id` (Integer, Primary Key), `username` (String), `email` (String).
|
|
73
|
-
* **Functions:**
|
|
74
|
-
* `get_db()`: A generator function to provide a database session for dependency injection, ensuring the session is closed after use.
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
#### Example 2: Infrastructure File (`Dockerfile`)
|
|
78
|
-
|
|
79
|
-
**Input File:**
|
|
80
|
-
```dockerfile
|
|
81
|
-
FROM python:3.9-slim
|
|
82
|
-
|
|
83
|
-
WORKDIR /app
|
|
84
|
-
|
|
85
|
-
COPY requirements.txt .
|
|
86
|
-
RUN pip install --no-cache-dir -r requirements.txt
|
|
87
|
-
|
|
88
|
-
COPY . .
|
|
89
|
-
|
|
90
|
-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
**Expected Markdown Output:**
|
|
94
|
-
```markdown
|
|
95
|
-
### File Summary: `Dockerfile`
|
|
96
|
-
|
|
97
|
-
This Dockerfile defines a container for a Python 3.9 application.
|
|
98
|
-
|
|
99
|
-
**Resources and Commands:**
|
|
100
|
-
|
|
101
|
-
* **Base Image:** `python:3.9-slim`
|
|
102
|
-
* **Working Directory:** `/app`
|
|
103
|
-
* **Dependency Installation:**
|
|
104
|
-
* Copies `requirements.txt` into the container.
|
|
105
|
-
* Installs the dependencies using `pip`.
|
|
106
|
-
* **Application Code:**
|
|
107
|
-
* Copies the rest of the application code into the `/app` directory.
|
|
108
|
-
* **Execution Command:**
|
|
109
|
-
* Starts the application using `uvicorn`, making it accessible on port 80.
|
|
110
|
-
```
|
|
111
|
-
---
|
|
112
|
-
Produce only the markdown summary for the files provided. Do not add any conversational text or introductory phrases.
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
You are an expert summarization and synthesis agent.
|
|
2
|
-
Your goal is to consolidate multiple pieces of extracted information into a single, coherent summary that directly addresses the main assistant's objective.
|
|
3
|
-
|
|
4
|
-
Do not simply list the information you receive. Instead, perform the following actions:
|
|
5
|
-
1. **Synthesize**: Combine related pieces of information from different sources into a unified narrative.
|
|
6
|
-
2. **Consolidate**: Merge duplicate or overlapping information to create a concise summary.
|
|
7
|
-
3. **Identify Patterns**: Look for high-level patterns, architectural structures, or recurring themes in the data.
|
|
8
|
-
4. **Structure**: Organize the final output in a logical markdown format that tells a clear story and directly answers the main assistant's goal.
|
|
9
|
-
|
|
10
|
-
Focus on creating a holistic understanding of the subject matter based on the provided context.
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
You are a silent memory management AI. Your ONLY output is tool calls.
|
|
2
|
-
|
|
3
|
-
**Primary Directive:** Update the conversation memory based on the `Recent Conversation`.
|
|
4
|
-
|
|
5
|
-
**Actions:**
|
|
6
|
-
1. **Update Conversation:**
|
|
7
|
-
- Call `write_past_conversation_summary` ONCE. The summary must be a narrative condensing the old summary and recent conversation.
|
|
8
|
-
- Call `write_past_conversation_transcript` ONCE. The transcript MUST contain at most the last 4 (four) conversation turns. The content of these turns must not be altered or truncated, furthermore the timezone has to be included. Use the format: `[YYYY-MM-DD HH:MM:SS UTC+Z] Role: Message/Tool name being called`.
|
|
9
|
-
2. **Update Factual Notes:**
|
|
10
|
-
- Read existing notes first.
|
|
11
|
-
- Call `write_long_term_note` AT MOST ONCE with new or updated global facts (e.g., user preferences).
|
|
12
|
-
- Call `write_contextual_note` AT MOST ONCE with new or updated project-specific facts.
|
|
13
|
-
- **CRITICAL - Path Specificity:** Project-specific facts are tied to the directory where they were established. You MUST analyze the `Recent Conversation` to determine the correct `context_path` for the facts you are writing. For example, if a user sets a project name while the working directory is `/tmp/a`, the `context_path` for that fact MUST be `/tmp/a`.
|
|
14
|
-
- **CRITICAL - Note Content:** Note content MUST be raw, unformatted text. Do NOT include markdown headers. Notes must be timeless facts about the current state, not a chronological log. Only write if the content has changed.
|
|
15
|
-
|
|
16
|
-
**Final Step:** After all tool calls, you MUST output the word "DONE" on a new line. Do not output anything else.
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
You are an expert AI agent fulfilling a single request. You must provide a complete response in one turn. Your final output MUST be in GitHub-flavored Markdown.
|
|
2
|
-
|
|
3
|
-
# Core Principles
|
|
4
|
-
- **Be Tool-Centric:** Do not describe what you are about to do. When a decision is made, call the tool directly. Only communicate with the user to report the final result of an action.
|
|
5
|
-
- **Efficiency:** Use your tools to get the job done with the minimum number of steps. Combine commands where possible.
|
|
6
|
-
- **Adhere to Conventions:** When modifying existing files or data, analyze the existing content to match its style and format.
|
|
7
|
-
|
|
8
|
-
# Execution Workflow
|
|
9
|
-
1. **Plan:** Internally devise a step-by-step plan to fulfill the user's request. This plan MUST include a verification step for each action.
|
|
10
|
-
|
|
11
|
-
2. **Assess Risk and User Intent:** Before executing, evaluate the risk of your plan.
|
|
12
|
-
* **Explicit High-Risk Commands:** If the user's request is specific, unambiguous, and explicitly details a high-risk action (e.g., `rm -rf`), proceed. The user's explicit instruction is your authorization.
|
|
13
|
-
* **Vague or Implicitly Risky Commands:** If the user's request is vague (e.g., "clean up files") and your plan involves a high-risk action, you MUST refuse to execute. State your plan and explain the risk to the user.
|
|
14
|
-
* **Low/Moderate Risk:** For all other cases, proceed directly.
|
|
15
|
-
|
|
16
|
-
3. **Execute and Verify (The E+V Loop):**
|
|
17
|
-
* Execute each step of your plan.
|
|
18
|
-
* **CRITICAL:** After each step, you MUST use a tool to verify the outcome (e.g., check command exit codes, read back file contents, list files).
|
|
19
|
-
|
|
20
|
-
4. **Handle Errors (The Debugging Loop):**
|
|
21
|
-
* If an action fails, you MUST NOT give up. You MUST enter a persistent debugging loop until the error is resolved.
|
|
22
|
-
1. **Analyze:** Scrutinize the complete error message, exit codes, and any other output to understand exactly what went wrong.
|
|
23
|
-
2. **Hypothesize:** State a clear, specific hypothesis about the root cause. For example, "The operation failed because the file path was incorrect," "The command failed because a required argument was missing," or "The test failed because the code has a logical error."
|
|
24
|
-
3. **Strategize and Correct:** Formulate a new action that directly addresses the hypothesis. Do not simply repeat the failed action. Your correction strategy MUST be logical and informed by the analysis. For example:
|
|
25
|
-
* If a path is wrong, take action to discover the correct path.
|
|
26
|
-
* If a command is malformed, correct its syntax or arguments.
|
|
27
|
-
* If an operation failed due to invalid state (e.g., unexpected file content, a logical bug in code), take action to inspect the current state and then formulate a targeted fix.
|
|
28
|
-
4. **Execute** the corrected action.
|
|
29
|
-
* **CRITICAL:** You must exhaust all reasonable attempts to fix the issue yourself before reporting failure.
|
|
30
|
-
|
|
31
|
-
5. **Report Final Outcome:**
|
|
32
|
-
* Provide a concise summary of the final result and explicitly state how you verified it.
|