Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/leettools/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from leettools.cli.options_common import common_options
from leettools.cli.parser import parser_cli
from leettools.cli.query import query_cli
from leettools.cli.strategy import strat_cli
from leettools.common import exceptions
from leettools.common.logging import logger
from leettools.context_manager import Context
Expand Down Expand Up @@ -71,6 +72,7 @@ def _list_all_commands(subcommand: click.Command, layer: int) -> None:
run.add_command(parser_cli.parser)
run.add_command(chunker_cli.chunker)
run.add_command(flow_cli.flow)
run.add_command(strat_cli.strategy)


def _add_extension_cli(context: Context):
Expand Down
4 changes: 2 additions & 2 deletions src/leettools/cli/kb/kb_add_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ def add_search(
flow_option.FLOW_OPTION_SEARCH_MAX_RESULTS: max_results,
flow_option.FLOW_OPTION_OUTPUT_LANGUAGE: output_language,
flow_option.FLOW_OPTION_SEARCH_LANGUAGE: search_language,
flow_option.FLOW_OPTION_SUMMARIZING_MODEL: "gpt-4o-mini",
flow_option.FLOW_OPTION_WRITING_MODEL: "gpt-4o-mini",
flow_option.FLOW_OPTION_SUMMARIZING_MODEL: None,
flow_option.FLOW_OPTION_WRITING_MODEL: None,
},
display_logger=None,
)
Expand Down
Empty file.
14 changes: 14 additions & 0 deletions src/leettools/cli/strategy/strat_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import click

from .strat_list import list


@click.group()
def strategy():
"""
Manage the strategies.
"""
pass


strategy.add_command(list)
63 changes: 63 additions & 0 deletions src/leettools/cli/strategy/strat_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
from typing import Optional

import click

from leettools.cli.options_common import common_options
from leettools.common import exceptions
from leettools.core.schemas.user import User


@click.command(help="List all strategies.")
@click.option(
"-u",
"--user",
"username",
default=None,
required=False,
help="The username to list strategies for. If not provided, lists all strategies.",
)
@common_options
def list(
username: Optional[str],
active_only: bool = True,
json_output: bool = False,
indent: Optional[int] = None,
**kwargs,
) -> None:
"""
List strategies in the database.

Args:
username: Optional username to filter strategies by user
active_only: If True, only show active strategies
json_output: If True, output in JSON format
indent: Number of spaces for JSON indentation
**kwargs: Additional keyword arguments from common options
"""
from leettools.context_manager import ContextManager

context = ContextManager().get_context()
context.is_svc = False
context.name = f"{context.EDS_CLI_CONTEXT_PREFIX}_strategy_list"

user_store = context.get_user_store()
strategy_store = context.get_strategy_store()

if username is None:
user = User.get_admin_user()
else:
user = user_store.get_user_by_name(username)
if user is None:
raise exceptions.EntityNotFoundException(
entity_name=username, entity_type="User"
)

strategies = strategy_store.list_active_strategies_for_user(user)
for strategy in strategies:
if json_output:
click.echo(strategy.model_dump_json(indent=indent))
else:
click.echo(
f"User: {user.username}\tStrategy: {strategy.strategy_name}\t"
f"ID: {strategy.strategy_id}\tStatus: {strategy.strategy_status}"
)
2 changes: 1 addition & 1 deletion src/leettools/core/consts/retriever_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def supported_retriever(region: Optional[str] = "all") -> List[str]:

if region.lower() == "cn":
return [
RetrieverType.BAIDU.value,
RetrieverType.GOOGLE.value,
RetrieverType.BING.value,
RetrieverType.LOCAL.value,
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"strategy_name": "default",
"strategy_description": "Default strategy using system default settings",
"rewrite": "default",
"rewrite_options": {"model_name": "gpt-4o-mini"}
"strategy_description": "Default strategy using system default settings"
}
2 changes: 2 additions & 0 deletions src/leettools/svc/api/v1/routers/settings_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ async def get_suggested_model_names() -> Dict[str, str]:
"gpt-4": "OpenAI GPT-4",
"gpt-4o": "OpenAI GPT-4o",
"gpt-4o-mini": "OpenAI GPT-4o Mini",
"deepseek-chat": "DeepSeek Chat",
"deepseek-reasoner": "DeepSeek Reasoner",
}

@self.get("/supported_web_retriever", response_model=List[str])
Expand Down
Loading