akseljoonas HF Staff commited on
Commit
856a2e4
Β·
1 Parent(s): 5fe810b

readme upt

Browse files
Files changed (1) hide show
  1. agent/README.md +16 -119
agent/README.md CHANGED
@@ -1,127 +1,24 @@
1
- # HF Agent
2
 
3
- AI Agent for working with Hugging Face models, datasets, and tools.
4
 
5
- ## Structure
6
 
7
- ```
8
- agent/
9
- β”œβ”€β”€ core/ # Core agent logic
10
- β”‚ β”œβ”€β”€ agent.py # Main agent implementation
11
- β”‚ β”œβ”€β”€ base.py # Base classes and interfaces
12
- β”‚ β”œβ”€β”€ planner.py # Task planning and decomposition
13
- β”‚ └── executor.py # Task execution engine
14
- β”‚
15
- β”œβ”€β”€ tools/ # Agent tools and actions
16
- β”‚ β”œβ”€β”€ base.py # Tool base class and registry
17
- β”‚ β”œβ”€β”€ search/ # Search tools (models, datasets, papers)
18
- β”‚ β”œβ”€β”€ generation/ # Generation tools (content, code, data)
19
- β”‚ β”œβ”€β”€ analysis/ # Analysis and evaluation tools
20
- β”‚ └── dataset_ops/ # Dataset operations
21
- β”‚
22
- β”œβ”€β”€ prompts/ # Prompt templates
23
- β”‚ β”œβ”€β”€ system/ # System prompts
24
- β”‚ β”œβ”€β”€ task/ # Task-specific prompts
25
- β”‚ └── few_shot/ # Few-shot examples
26
- β”‚
27
- β”œβ”€β”€ memory/ # Memory systems
28
- β”‚ β”œβ”€β”€ short_term/ # Conversational memory
29
- β”‚ └── long_term/ # Persistent knowledge
30
- β”‚
31
- β”œβ”€β”€ config/ # Configuration
32
- β”‚ β”œβ”€β”€ settings.py # Settings management
33
- β”‚ └── default_config.json
34
- β”‚
35
- β”œβ”€β”€ utils/ # Utilities
36
- β”‚ β”œβ”€β”€ logging.py # Logging setup
37
- β”‚ └── retry.py # Retry logic
38
- β”‚
39
- └── tests/ # Test suite
40
- β”œβ”€β”€ unit/ # Unit tests
41
- └── integration/ # Integration tests
42
- ```
43
-
44
- ## Key Components
45
-
46
- ### Core
47
- - **Agent**: Main orchestrator that coordinates planning, execution, and reflection
48
- - **Planner**: Breaks down complex tasks into actionable steps
49
- - **Executor**: Executes individual steps using available tools
50
-
51
- ### Tools
52
- - Modular tool system with base class and registry
53
- - Tools organized by category (search, generation, analysis, dataset ops)
54
- - Each tool can be registered and used by the agent
55
-
56
- ### Memory
57
- - **Short-term**: Manages conversation context and current task state
58
- - **Long-term**: Persistent storage for learned knowledge and past interactions
59
 
60
- ### Prompts
61
- - Template-based prompt management
62
- - System prompts for agent behavior
63
- - Task-specific prompts for different operations
64
- - Few-shot examples for learning
65
-
66
- ## Usage
67
-
68
- ```python
69
- from agent import Agent
70
- from agent.config import load_config
71
-
72
- # Load configuration
73
- config = load_config()
74
-
75
- # Create agent
76
- agent = Agent(config=config.model_dump())
77
-
78
- # Run a task
79
- result = await agent.run("Find the top 5 text generation models")
80
  ```
 
 
 
 
81
 
82
- ## Development
83
-
84
- ### Adding a New Tool
85
-
86
- 1. Create a new file in the appropriate `tools/` subdirectory
87
- 2. Inherit from `BaseTool`
88
- 3. Implement `execute()` and `_get_parameters()`
89
- 4. Register the tool with the agent
90
-
91
- ```python
92
- from agent.tools.base import BaseTool
93
-
94
- class MyTool(BaseTool):
95
- name = "my_tool"
96
- description = "Does something useful"
97
-
98
- async def execute(self, **kwargs):
99
- # Implementation
100
- pass
101
-
102
- def _get_parameters(self):
103
- return {
104
- "type": "object",
105
- "properties": {...}
106
- }
107
- ```
108
-
109
- ### Running Tests
110
-
111
- ```bash
112
- pytest agent/tests/
113
- ```
114
-
115
- ## Configuration
116
-
117
- Configure the agent via `config/default_config.json` or by passing a config dict:
118
 
119
- ```python
120
- config = {
121
- "model_name": "gpt-4",
122
- "temperature": 0.7,
123
- "max_iterations": 10,
124
- "reflection_enabled": True
125
- }
126
- agent = Agent(config=config)
127
  ```
 
1
+ # Agent
2
 
3
+ Async agent loop with LiteLLM.
4
 
5
+ ## Architecture
6
 
7
+ **Queue-based async system:**
8
+ - Submissions in (user input) β†’ Agent Loop β†’ Events output for possible UI updates
9
+ - Session maintains state (context + tools) for possible future Context Engineering
10
+ - Handlers operations like (USER_INPUT, INTERRUPT, COMPACT, UNDO, SHUTDOWN) for possible UI control
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  ```
13
+ core/
14
+ β”œβ”€β”€ agent_loop.py # submission_loop + Handlers
15
+ β”œβ”€β”€ session.py # Session, Event, OpType
16
+ └── executor.py # ToolExecutor
17
 
18
+ context_manager/
19
+ └── manager.py # Message history management
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
+ config.py # Config with model_name + tools
22
+ tools/ # Tool implementations (todo)
23
+ utils/ # Logging, etc
 
 
 
 
 
24
  ```