akseljoonas HF Staff commited on
Commit
7b4e2da
·
1 Parent(s): 7473699

optional deps and main prints

Browse files
Files changed (5) hide show
  1. README.md +4 -3
  2. agent/main.py +3 -3
  3. agent/tools/github_find_examples.py +41 -43
  4. pyproject.toml +27 -14
  5. uv.lock +0 -0
README.md CHANGED
@@ -11,9 +11,11 @@ An MLE agent CLI with MCP (Model Context Protocol) integration and built-in tool
11
  # Clone the repository
12
  git clone git@github.com:huggingface/hf_agent.git
13
  cd hf-agent
 
14
 
15
- # Install dependencies (using uv)
16
- uv sync
 
17
  ```
18
 
19
  ### Interactive CLI
@@ -21,7 +23,6 @@ uv sync
21
  ```bash
22
  uv run python -m agent.main
23
  ```
24
-
25
  This starts an interactive chat session with the agent. Type your messages and the agent will respond, using tools as needed.
26
 
27
  The agent will automatically discover and register all tools from configured MCP servers.
 
11
  # Clone the repository
12
  git clone git@github.com:huggingface/hf_agent.git
13
  cd hf-agent
14
+ ```
15
 
16
+ #### Install recommended dependencies
17
+ ```bash
18
+ uv sync --extra agent # or uv sync --extra all
19
  ```
20
 
21
  ### Interactive CLI
 
23
  ```bash
24
  uv run python -m agent.main
25
  ```
 
26
  This starts an interactive chat session with the agent. Type your messages and the agent will respond, using tools as needed.
27
 
28
  The agent will automatically discover and register all tools from configured MCP servers.
agent/main.py CHANGED
@@ -327,6 +327,8 @@ async def main():
327
  print(f"{Colors.YELLOW} {banner}{Colors.RESET}")
328
  print("Type your messages below. Type 'exit', 'quit', or '/quit' to end.\n")
329
  print(format_separator())
 
 
330
 
331
  # Create queues for communication
332
  submission_queue = asyncio.Queue()
@@ -342,7 +344,7 @@ async def main():
342
  config = load_config(config_path)
343
 
344
  # Create tool router
345
- print(f"Config: {config.mcpServers}")
346
  tool_router = ToolRouter(config.mcpServers)
347
 
348
  # Create prompt session for input
@@ -368,8 +370,6 @@ async def main():
368
  )
369
  )
370
 
371
- # Wait for agent to initialize
372
- print("Initializing agent...")
373
  await ready_event.wait()
374
 
375
  submission_id = 0
 
327
  print(f"{Colors.YELLOW} {banner}{Colors.RESET}")
328
  print("Type your messages below. Type 'exit', 'quit', or '/quit' to end.\n")
329
  print(format_separator())
330
+ # Wait for agent to initialize
331
+ print("Initializing agent...")
332
 
333
  # Create queues for communication
334
  submission_queue = asyncio.Queue()
 
344
  config = load_config(config_path)
345
 
346
  # Create tool router
347
+ print(f"Loading MCP servers: {', '.join(config.mcpServers.keys())}")
348
  tool_router = ToolRouter(config.mcpServers)
349
 
350
  # Create prompt session for input
 
370
  )
371
  )
372
 
 
 
373
  await ready_event.wait()
374
 
375
  submission_id = 0
agent/tools/github_find_examples.py CHANGED
@@ -404,49 +404,47 @@ def find_examples(
404
  # Tool specification
405
  GITHUB_FIND_EXAMPLES_TOOL_SPEC = {
406
  "name": "github_find_examples",
407
- "description": (
408
- "Discover best practices, reusable scripts, tutorials, and demos for usinga specific library or framework. This is an important step before implementing anything ML related.",
409
- "Use together with github_read_file tool.\n\n"
410
- "## When to use this tool\n\n"
411
- "- ALWAYS before implementing any training/inference/benchmarking or other ML related code or answering how-to question.\n"
412
- "- When exploring a new repository and need to understand how to use it\n"
413
- "## How it works\n\n"
414
- "1. Fetches all (examples, tutorials, demos, notebooks, scripts, etc.) from the repository\n"
415
- "2. If keyword provided, scores found files against the keyword using fuzzy matching\n"
416
- "3. Returns best matches sorted by relevance score\n"
417
- "## Examples\n\n"
418
- "<example>\n"
419
- "// ML Workflow Step: Find GRPO/SFT/DPO/RLOO etc training examples\n"
420
- "// Task: Starting GRPO fine-tuning project, need reference implementations\n"
421
- "{\n"
422
- " keyword: 'grpo',\n"
423
- " repo: 'trl',\n"
424
- " org: 'huggingface'\n"
425
- "}\n"
426
- "// Returns: examples/scripts/grpo_agent.py, examples/scripts/grpo_vlm.py\n"
427
- "// Next step: Use github_read_file to study the implementation\n"
428
- "</example>\n\n"
429
- "<example>\n"
430
- "// ML Workflow Step: Discover all training examples in TRL\n"
431
- "// Task: Exploring available training methods before choosing approach\n"
432
- "{\n"
433
- " repo: 'trl',\n"
434
- " org: 'huggingface',\n"
435
- " max_results: 20\n"
436
- "}\n"
437
- "// Lists all example scripts: PPO, DPO, GRPO, reward modeling, etc.\n"
438
- "</example>\n\n"
439
- "<example>\n"
440
- "// ML Workflow Step: Find LoRA fine-tuning examples\n"
441
- "// Task: Learning parameter-efficient fine-tuning with PEFT\n"
442
- "{\n"
443
- " keyword: 'lora',\n"
444
- " repo: 'peft',\n"
445
- " org: 'huggingface'\n"
446
- "}\n"
447
- "// Discovers LoRA configuration and training examples\n"
448
- "</example>",
449
- ),
450
  "parameters": {
451
  "type": "object",
452
  "properties": {
 
404
  # Tool specification
405
  GITHUB_FIND_EXAMPLES_TOOL_SPEC = {
406
  "name": "github_find_examples",
407
+ "description": "Discover best practices, reusable scripts, tutorials, and demos for using a specific library or framework. This is an important step before implementing anything ML related. "
408
+ "Use together with github_read_file tool.\n\n"
409
+ "## When to use this tool\n\n"
410
+ "- ALWAYS before implementing any training/inference/benchmarking or other ML related code or answering how-to question.\n"
411
+ "- When exploring a new repository and need to understand how to use it\n"
412
+ "## How it works\n\n"
413
+ "1. Fetches all (examples, tutorials, demos, notebooks, scripts, etc.) from the repository\n"
414
+ "2. If keyword provided, scores found files against the keyword using fuzzy matching\n"
415
+ "3. Returns best matches sorted by relevance score\n"
416
+ "## Examples\n\n"
417
+ "<example>\n"
418
+ "// ML Workflow Step: Find GRPO/SFT/DPO/RLOO etc training examples\n"
419
+ "// Task: Starting GRPO fine-tuning project, need reference implementations\n"
420
+ "{\n"
421
+ " keyword: 'grpo',\n"
422
+ " repo: 'trl',\n"
423
+ " org: 'huggingface'\n"
424
+ "}\n"
425
+ "// Returns: examples/scripts/grpo_agent.py, examples/scripts/grpo_vlm.py\n"
426
+ "// Next step: Use github_read_file to study the implementation\n"
427
+ "</example>\n\n"
428
+ "<example>\n"
429
+ "// ML Workflow Step: Discover all training examples in TRL\n"
430
+ "// Task: Exploring available training methods before choosing approach\n"
431
+ "{\n"
432
+ " repo: 'trl',\n"
433
+ " org: 'huggingface',\n"
434
+ " max_results: 20\n"
435
+ "}\n"
436
+ "// Lists all example scripts: PPO, DPO, GRPO, reward modeling, etc.\n"
437
+ "</example>\n\n"
438
+ "<example>\n"
439
+ "// ML Workflow Step: Find LoRA fine-tuning examples\n"
440
+ "// Task: Learning parameter-efficient fine-tuning with PEFT\n"
441
+ "{\n"
442
+ " keyword: 'lora',\n"
443
+ " repo: 'peft',\n"
444
+ " org: 'huggingface'\n"
445
+ "}\n"
446
+ "// Discovers LoRA configuration and training examples\n"
447
+ "</example>",
 
 
448
  "parameters": {
449
  "type": "object",
450
  "properties": {
pyproject.toml CHANGED
@@ -5,26 +5,39 @@ description = "Add your description here"
5
  readme = "README.md"
6
  requires-python = ">=3.12"
7
  dependencies = [
8
- "numpy>=1.24.0",
9
- "requests>=2.32.5",
10
  "pydantic>=2.12.3",
11
- "litellm>=1.0.0",
12
- "tenacity>=8.0.0",
13
- "pandas>=2.3.3",
14
  "python-dotenv>=1.2.1",
15
- "datasets>=4.3.0",
 
 
 
 
 
 
16
  "huggingface-hub>=1.0.1",
17
  "fastmcp>=2.4.0",
18
- "inspect-ai>=0.3.149",
19
- "lmnr[all]>=0.7.23",
20
- "transformers>=2.3.0",
21
- "torch>=2.9.1",
22
- "pytest>=9.0.2",
23
  "prompt-toolkit>=3.0.0",
24
- "ipykernel>=7.1.0",
25
- "ipywidgets>=8.1.8",
26
  "thefuzz>=0.22.1",
27
  "nbconvert>=7.16.6",
28
  "nbformat>=5.10.4",
29
- "markitdown[all,docx,outlook,pdf,pptx,xls,xlsx]>=0.1.4",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  ]
 
5
  readme = "README.md"
6
  requires-python = ">=3.12"
7
  dependencies = [
8
+ # Core dependencies (always required)
 
9
  "pydantic>=2.12.3",
 
 
 
10
  "python-dotenv>=1.2.1",
11
+ ]
12
+
13
+ [project.optional-dependencies]
14
+ # Agent runtime dependencies
15
+ agent = [
16
+ "requests>=2.32.5",
17
+ "litellm>=1.0.0",
18
  "huggingface-hub>=1.0.1",
19
  "fastmcp>=2.4.0",
20
+ "lmnr>=0.7.23", # Note: Using base package to avoid torch/transformers from [all] extra
 
 
 
 
21
  "prompt-toolkit>=3.0.0",
 
 
22
  "thefuzz>=0.22.1",
23
  "nbconvert>=7.16.6",
24
  "nbformat>=5.10.4",
25
+ ]
26
+
27
+ # Evaluation/benchmarking dependencies
28
+ eval = [
29
+ "inspect-ai>=0.3.149",
30
+ "pandas>=2.3.3",
31
+ "datasets>=4.3.0",
32
+ "tenacity>=8.0.0",
33
+ ]
34
+
35
+ # Development and testing dependencies
36
+ dev = [
37
+ "pytest>=9.0.2",
38
+ ]
39
+
40
+ # All dependencies (agent + eval + dev)
41
+ all = [
42
+ "hf-agent[agent,eval,dev]",
43
  ]
uv.lock CHANGED
The diff for this file is too large to render. See raw diff