-
Notifications
You must be signed in to change notification settings - Fork 50
MCP and WebUI #218
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
MCP and WebUI #218
Changes from 104 commits
4f118ea
a0ac09b
767be68
26977a8
1fb8552
f594790
f781653
60f909d
c6cfb26
8af2796
5ec6eb3
fb3b623
5ba97e6
29fbc11
10a3137
42e7c9e
2ad93c0
b6dfe4d
fc4bbdc
671a989
a422eca
912f6c1
a25aefd
51ea3c9
0d13ba7
b6dfbc2
d803fe0
edca00f
3f694d8
762c0bc
c2b48da
bbeeef9
5fdd7e0
be1ad3a
763c7cf
a35fd88
b6c9372
4a1e86c
3f3a4da
e76e34c
3ef321e
39c093d
2513d2b
9968d7d
b044c85
4b7fa4e
d2b2e0c
0de398a
5aa5949
bab3a2f
267bb1b
23f00d9
4961b8d
55baf26
8f113c7
9ff32f7
4bc4ec6
5b443ac
743cdaf
d2823a7
c61ed8b
56eaeff
cb1b9fe
39cd5e2
da90812
643c81b
e70d481
46f07c7
49e78de
021aa75
9b2f7c0
ab93e49
dd08184
22a9076
f8a3580
b52b59d
4fa9340
bbedd34
e11a18d
dfe814d
efa4f3c
a4261c5
b9cc607
26583ea
aa6ba72
d39e8ef
c176c52
b5302ae
3914d9b
0b6d2ba
037e421
540ed38
7106091
a50d037
e761943
fa01f22
916785e
88019c3
60dea63
ad3688d
54b319d
725f9ce
15aef0f
d9be53b
1591cfa
b2cf938
eedb74f
55de094
01cf8f7
c8b34d4
af048e4
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 |
|---|---|---|
|
|
@@ -70,7 +70,7 @@ You can select the LLM provider, model, and credentials to use. If using Bedrock | |
| ### CLI | ||
|
|
||
| ```bash | ||
| mlzero -i INPUT_DATA_FOLDER [-o OUTPUT_DIR] [-c CONFIG_PATH] [-n MAX_ITERATIONS] [--need-user-input] [-u INITIAL_USER_INPUT] [-e EXTRACT_TO] [-v VERBOSITY_LEVEL] | ||
| mlzero -i INPUT_DATA_FOLDER [-o OUTPUT_DIR] [-c CONFIG_PATH] [-n MAX_ITERATIONS] [--ENABLE-PER-ITERATION-INSTRUCTION] [--INITIAL-INSTRUCTION] [-e EXTRACT_TO] [-v VERBOSITY_LEVEL] | ||
|
||
| ``` | ||
|
|
||
| #### Required Arguments | ||
|
|
@@ -89,10 +89,10 @@ mlzero -i INPUT_DATA_FOLDER [-o OUTPUT_DIR] [-c CONFIG_PATH] [-n MAX_ITERATIONS] | |
| - `-n, --max-iterations`: | ||
| Maximum number of iterations. Default is `5`. | ||
|
|
||
| - `--need-user-input`: | ||
| - `--enable-per-iteration-instruction`: | ||
| Whether to prompt user input at each iteration. Defaults to `False`. | ||
|
|
||
| - `-u, --user-input`: | ||
| - `--initial-instruction`: | ||
| Initial user input to use in the first iteration. Optional. | ||
|
|
||
| - `-e, --extract-to`: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,24 @@ | ||
| #!/usr/bin/env python3 | ||
| from __future__ import annotations | ||
|
|
||
| from pathlib import Path | ||
| import multiprocessing.resource_tracker | ||
|
|
||
| import typer | ||
|
|
||
| from autogluon.assistant.coding_agent import run_agent | ||
| def _noop(*args, **kwargs): | ||
| pass | ||
|
|
||
| from .. import __file__ as assistant_file | ||
|
|
||
| multiprocessing.resource_tracker.register = _noop | ||
| multiprocessing.resource_tracker.unregister = _noop | ||
| multiprocessing.resource_tracker.ensure_running = _noop | ||
|
|
||
| from pathlib import Path # noqa: E402 | ||
|
|
||
| import typer # noqa: E402 | ||
|
||
|
|
||
| from autogluon.assistant.coding_agent import run_agent # noqa: E402 | ||
|
|
||
| from .. import __file__ as assistant_file # noqa: E402 | ||
|
|
||
| PACKAGE_ROOT = Path(assistant_file).parent | ||
|
||
| DEFAULT_CONFIG_PATH = PACKAGE_ROOT / "configs" / "default.yaml" | ||
|
|
@@ -31,14 +42,39 @@ def main( | |
| "--config", | ||
| help=f"YAML config file (default: {DEFAULT_CONFIG_PATH})", | ||
| ), | ||
| max_iterations: int = typer.Option(5, "-n", "--max-iterations", help="Max iteration count"), | ||
| need_user_input: bool = typer.Option(False, "--need-user-input", help="Whether to prompt user each iteration"), | ||
| initial_user_input: str | None = typer.Option(None, "-u", "--user-input", help="Initial user input"), | ||
| max_iterations: int = typer.Option( | ||
| 5, | ||
| "-n", | ||
| "--max-iterations", | ||
| help="Max iteration count. If the task hasn’t succeeded after this many iterations, it will terminate.", | ||
| ), | ||
| need_user_input: bool = typer.Option( | ||
| False, | ||
| "--enable-per-iteration-instruction", | ||
| help="If enabled, you can provide a prompt for the next iteration at each iteration", | ||
|
||
| ), | ||
| initial_user_input: str | None = typer.Option( | ||
| None, "--initial-instruction", help="You can provide the initial instruction here." | ||
| ), | ||
| extract_archives_to: str | None = typer.Option( | ||
| None, "-e", "--extract-to", help="Directory in which to unpack any archives" | ||
| None, | ||
| "-e", | ||
| "--extract-to", | ||
| help="Copy input data to specified directory and automatically extract all .zip archives. ", | ||
| ), | ||
| # === Logging parameters === | ||
| verbosity: int = typer.Option(1, "-v", "--verbosity", help="Verbosity level (0–4)"), | ||
| verbosity: int = typer.Option( | ||
| 1, | ||
| "-v", | ||
| "--verbosity", | ||
| help=( | ||
| "-v 0: Only includes error messages\n" | ||
| "-v 1: Contains key essential information\n" | ||
| "-v 2: Includes brief information plus detailed information such as file save locations\n" | ||
| "-v 3: Includes info-level information plus all model training related information\n" | ||
| "-v 4: Includes full debug information" | ||
| ), | ||
| ), | ||
| ): | ||
| """ | ||
| mlzero: a CLI for running the AutoMLAgent pipeline. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
|
|
||
| from omegaconf import OmegaConf | ||
|
|
||
| from .managers import Manager | ||
| # from .managers import Manager | ||
|
||
| from .rich_logging import configure_logging | ||
| from .utils import extract_archives | ||
|
|
||
|
|
@@ -45,6 +45,7 @@ def run_agent( | |
| output_dir.mkdir(parents=False, exist_ok=True) | ||
|
|
||
| configure_logging(verbosity=verbosity, output_dir=output_dir) | ||
| from .managers import Manager | ||
|
|
||
| if extract_archives_to is not None: | ||
| if extract_archives_to and extract_archives_to != input_data_folder: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,13 @@ | ||
| import contextlib | ||
| import io | ||
| import logging | ||
| import os | ||
| import pickle | ||
| from pathlib import Path | ||
| from typing import Dict, List, Optional, Tuple | ||
|
|
||
| os.environ["TRANSFORMERS_NO_ADVISORY_WARNINGS"] = "true" | ||
|
|
||
| import faiss | ||
| import numpy as np | ||
| from FlagEmbedding import FlagAutoModel | ||
|
|
@@ -32,6 +37,10 @@ def __del__(self): | |
| """Cleanup method to properly close the embedding model.""" | ||
| self.cleanup() | ||
|
|
||
| def __log_wrapper(self, input): | ||
|
||
| with contextlib.redirect_stderr(io.StringIO()): | ||
| return self.model.encode(input) | ||
|
|
||
| def cleanup(self): | ||
| """Cleanup the embedding model to avoid multiprocessing issues.""" | ||
| if self.model is not None: | ||
|
|
@@ -41,6 +50,8 @@ def cleanup(self): | |
| self.model.close() | ||
| elif hasattr(self.model, "stop_multi_process_pool"): | ||
| self.model.stop_multi_process_pool() | ||
| else: | ||
| del self.model | ||
| except Exception as e: | ||
| logger.debug(f"Error during model cleanup: {e}") | ||
| finally: | ||
|
|
@@ -141,7 +152,7 @@ def _build_tool_index(self, tool_name: str, tutorial_type: str) -> Tuple[faiss.I | |
|
|
||
| for i in range(0, len(summaries), batch_size): | ||
| batch_summaries = summaries[i : i + batch_size] | ||
| batch_embeddings = self.model.encode(batch_summaries) | ||
| batch_embeddings = self.__log_wrapper(batch_summaries) | ||
|
|
||
| # Ensure proper format | ||
| if not isinstance(batch_embeddings, np.ndarray): | ||
|
|
@@ -316,7 +327,7 @@ def search(self, query: str, tool_name: str, condensed: bool = False, top_k: int | |
| return [] | ||
|
|
||
| # Generate query embedding | ||
| query_embedding = self.model.encode([query]) | ||
| query_embedding = self.__log_wrapper([query]) | ||
|
|
||
| # Ensure proper data type and memory layout | ||
| if not isinstance(query_embedding, np.ndarray): | ||
|
|
||
This file was deleted.
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.
EOF