jiva-core 0.1.0
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.
- package/.env.example +18 -0
- package/.fluen/cache/state.json +7 -0
- package/README.md +350 -0
- package/actions/action_registry.py +75 -0
- package/actions/python_coder.py +470 -0
- package/api/main.py +269 -0
- package/dist/core/agent.d.ts +69 -0
- package/dist/core/agent.d.ts.map +1 -0
- package/dist/core/agent.js +214 -0
- package/dist/core/agent.js.map +1 -0
- package/dist/core/config.d.ts +222 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +138 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/workspace.d.ts +53 -0
- package/dist/core/workspace.d.ts.map +1 -0
- package/dist/core/workspace.js +164 -0
- package/dist/core/workspace.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/cli/index.d.ts +6 -0
- package/dist/interfaces/cli/index.d.ts.map +1 -0
- package/dist/interfaces/cli/index.js +257 -0
- package/dist/interfaces/cli/index.js.map +1 -0
- package/dist/interfaces/cli/repl.d.ts +9 -0
- package/dist/interfaces/cli/repl.d.ts.map +1 -0
- package/dist/interfaces/cli/repl.js +139 -0
- package/dist/interfaces/cli/repl.js.map +1 -0
- package/dist/interfaces/cli/setup-wizard.d.ts +9 -0
- package/dist/interfaces/cli/setup-wizard.d.ts.map +1 -0
- package/dist/interfaces/cli/setup-wizard.js +321 -0
- package/dist/interfaces/cli/setup-wizard.js.map +1 -0
- package/dist/mcp/client.d.ts +58 -0
- package/dist/mcp/client.d.ts.map +1 -0
- package/dist/mcp/client.js +178 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/mcp/server-manager.d.ts +58 -0
- package/dist/mcp/server-manager.d.ts.map +1 -0
- package/dist/mcp/server-manager.js +135 -0
- package/dist/mcp/server-manager.js.map +1 -0
- package/dist/models/base.d.ts +57 -0
- package/dist/models/base.d.ts.map +1 -0
- package/dist/models/base.js +5 -0
- package/dist/models/base.js.map +1 -0
- package/dist/models/harmony.d.ts +78 -0
- package/dist/models/harmony.d.ts.map +1 -0
- package/dist/models/harmony.js +226 -0
- package/dist/models/harmony.js.map +1 -0
- package/dist/models/krutrim.d.ts +30 -0
- package/dist/models/krutrim.d.ts.map +1 -0
- package/dist/models/krutrim.js +185 -0
- package/dist/models/krutrim.js.map +1 -0
- package/dist/models/orchestrator.d.ts +49 -0
- package/dist/models/orchestrator.d.ts.map +1 -0
- package/dist/models/orchestrator.js +140 -0
- package/dist/models/orchestrator.js.map +1 -0
- package/dist/utils/errors.d.ts +23 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +45 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/logger.d.ts +24 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +74 -0
- package/dist/utils/logger.js.map +1 -0
- package/docs/BUILD.md +317 -0
- package/docs/DEV_WORKFLOW.md +197 -0
- package/docs/FILESYSTEM_ACCESS.md +244 -0
- package/docs/IMPLEMENTATION_SUMMARY.md +459 -0
- package/docs/QUICKSTART.md +162 -0
- package/docs/TROUBLESHOOTING.md +393 -0
- package/examples/code-review-directive.md +26 -0
- package/examples/data-analysis-directive.md +26 -0
- package/examples/programmatic-usage.ts +120 -0
- package/jiva-directive.md +24 -0
- package/package.json +46 -0
- package/setup.sh +65 -0
- package/src/core/agent.ts +275 -0
- package/src/core/config.ts +177 -0
- package/src/core/workspace.ts +205 -0
- package/src/index.ts +21 -0
- package/src/interfaces/cli/index.ts +290 -0
- package/src/interfaces/cli/repl.ts +182 -0
- package/src/interfaces/cli/setup-wizard.ts +355 -0
- package/src/mcp/client.ts +231 -0
- package/src/mcp/server-manager.ts +168 -0
- package/src/models/base.ts +63 -0
- package/src/models/harmony.ts +301 -0
- package/src/models/krutrim.ts +236 -0
- package/src/models/orchestrator.ts +180 -0
- package/src/utils/errors.ts +41 -0
- package/src/utils/logger.ts +87 -0
- package/tsconfig.json +22 -0
package/.env.example
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Jiva Framework Environment Variables
|
|
2
|
+
# Copy this file to .env and fill in your API keys
|
|
3
|
+
|
|
4
|
+
# Search Engine APIs (optional - DuckDuckGo works without any keys)
|
|
5
|
+
# Get these from: https://brave.com/search/api
|
|
6
|
+
BRAVE_API_KEY=your_brave_api_key_here
|
|
7
|
+
|
|
8
|
+
# Get these from: https://azure.microsoft.com/en-us/services/cognitive-services/bing-web-search-api/
|
|
9
|
+
BING_SEARCH_KEY=your_bing_search_key_here
|
|
10
|
+
|
|
11
|
+
# Get these from: https://serpapi.com
|
|
12
|
+
SERPAPI_KEY=your_serpapi_key_here
|
|
13
|
+
|
|
14
|
+
# LLM Provider API Keys (if using external providers)
|
|
15
|
+
OPENAI_API_KEY=your_openai_api_key_here
|
|
16
|
+
ANTHROPIC_API_KEY=your_anthropic_api_key_here
|
|
17
|
+
MISTRAL_API_KEY=your_mistral_api_key_here
|
|
18
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
# Jiva - Versatile Autonomous AI Agent
|
|
2
|
+
|
|
3
|
+
Jiva is a powerful autonomous AI agent powered by gpt-oss-120b with full MCP (Model Context Protocol) support. It's designed to be highly goal-oriented, autonomous, and extensible for various use cases.
|
|
4
|
+
|
|
5
|
+
## 🚀 Quick Links
|
|
6
|
+
|
|
7
|
+
- **[Quick Start Guide](QUICKSTART.md)** - Get up and running in 30 seconds
|
|
8
|
+
- **[Build Instructions](BUILD.md)** - Detailed setup and development workflow
|
|
9
|
+
- **[Implementation Summary](IMPLEMENTATION_SUMMARY.md)** - Architecture and technical details
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Powered by gpt-oss-120b**: Leverages OpenAI's powerful open-weight reasoning model
|
|
14
|
+
- **Harmony Format Support**: Full implementation of the Harmony response format required by gpt-oss models
|
|
15
|
+
- **MCP Integration**: Seamless integration with Model Context Protocol servers for extensible tooling
|
|
16
|
+
- **Multi-Modal Support**: Optional integration with Llama-4-Maverick-17B for image understanding
|
|
17
|
+
- **Directive-Based**: Supports `jiva-directive.md` files to orient the agent for specific tasks
|
|
18
|
+
- **Extensible Architecture**: Designed to expand from CLI to Electron desktop app or web application
|
|
19
|
+
- **Robust Tool Calling**: Advanced parsing and error handling for reliable tool execution
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install
|
|
25
|
+
npm run build
|
|
26
|
+
npm link # For global CLI access
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
### 1. First-Time Setup
|
|
32
|
+
|
|
33
|
+
Run the setup wizard to configure Jiva:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
jiva setup
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
You'll be prompted for:
|
|
40
|
+
- Krutrim API endpoint (default: `https://cloud.olakrutrim.com/v1/chat/completions`)
|
|
41
|
+
- API key for reasoning model (gpt-oss-120b)
|
|
42
|
+
- Optional multimodal model configuration (Llama-4-Maverick-17B)
|
|
43
|
+
- MCP server configuration
|
|
44
|
+
|
|
45
|
+
### 2. Interactive Chat
|
|
46
|
+
|
|
47
|
+
Start an interactive session:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
jiva chat
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Or with custom workspace:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
jiva chat --workspace /path/to/workspace --directive ./my-directive.md
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 3. Single Prompt Execution
|
|
60
|
+
|
|
61
|
+
Execute a single prompt:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
jiva run "Analyze the code in this directory and suggest improvements"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Configuration
|
|
68
|
+
|
|
69
|
+
Configuration is stored in your system's config directory (managed by `conf` package).
|
|
70
|
+
|
|
71
|
+
### View Configuration Location
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
jiva config
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Manual Configuration
|
|
78
|
+
|
|
79
|
+
You can also manually edit the config file. Location varies by OS:
|
|
80
|
+
- macOS: `~/Library/Preferences/jiva-nodejs/`
|
|
81
|
+
- Linux: `~/.config/jiva-nodejs/`
|
|
82
|
+
- Windows: `%APPDATA%\jiva-nodejs\`
|
|
83
|
+
|
|
84
|
+
## Directive Files
|
|
85
|
+
|
|
86
|
+
Jiva can be oriented with a `jiva-directive.md` file that defines its purpose, tasks, and constraints.
|
|
87
|
+
|
|
88
|
+
### Example Directive
|
|
89
|
+
|
|
90
|
+
Create a file called `jiva-directive.md`:
|
|
91
|
+
|
|
92
|
+
```markdown
|
|
93
|
+
# Purpose
|
|
94
|
+
|
|
95
|
+
You are a code review assistant focused on identifying security vulnerabilities
|
|
96
|
+
and suggesting performance improvements in Python projects.
|
|
97
|
+
|
|
98
|
+
# Tasks
|
|
99
|
+
|
|
100
|
+
- Scan Python files for common security issues (SQL injection, XSS, etc.)
|
|
101
|
+
- Identify performance bottlenecks
|
|
102
|
+
- Suggest modern Python best practices
|
|
103
|
+
- Check for outdated dependencies
|
|
104
|
+
|
|
105
|
+
# Constraints
|
|
106
|
+
|
|
107
|
+
- Only analyze Python files (.py)
|
|
108
|
+
- Do not modify code without explicit approval
|
|
109
|
+
- Prioritize security issues over style improvements
|
|
110
|
+
|
|
111
|
+
# Context
|
|
112
|
+
|
|
113
|
+
This project is a Django web application with a PostgreSQL database.
|
|
114
|
+
It handles sensitive user data and must comply with GDPR.
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Jiva will automatically look for this file in:
|
|
118
|
+
1. Path specified with `--directive` flag
|
|
119
|
+
2. `jiva-directive.md` in workspace root
|
|
120
|
+
3. `.jiva/directive.md` in workspace root
|
|
121
|
+
|
|
122
|
+
## MCP Servers
|
|
123
|
+
|
|
124
|
+
Jiva comes pre-configured with two MCP servers:
|
|
125
|
+
|
|
126
|
+
### 1. Filesystem Server
|
|
127
|
+
Provides tools for file operations across your entire filesystem (subject to OS permissions).
|
|
128
|
+
- **Status:** Enabled by default
|
|
129
|
+
- **Package:** `@modelcontextprotocol/server-filesystem`
|
|
130
|
+
- **Access:** Full filesystem access - workspace is the default working area, not a restriction
|
|
131
|
+
- **Details:** See [FILESYSTEM_ACCESS.md](FILESYSTEM_ACCESS.md)
|
|
132
|
+
|
|
133
|
+
### 2. Commands Server
|
|
134
|
+
Allows execution of shell commands.
|
|
135
|
+
- **Status:** Disabled by default (known stability issues)
|
|
136
|
+
- **Package:** `@modelcontextprotocol/server-commands`
|
|
137
|
+
- **Note:** You can enable this manually via `npx jiva config` if needed
|
|
138
|
+
|
|
139
|
+
**Troubleshooting MCP Issues:** See [TROUBLESHOOTING.md](TROUBLESHOOTING.md#mcp-server-issues)
|
|
140
|
+
|
|
141
|
+
### Adding Custom MCP Servers
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
jiva config
|
|
145
|
+
# Select "MCP Servers" > "Add Server"
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Or programmatically:
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import { configManager } from 'jiva';
|
|
152
|
+
|
|
153
|
+
configManager.addMCPServer('my-server', {
|
|
154
|
+
command: 'npx',
|
|
155
|
+
args: ['-y', '@my-org/mcp-server'],
|
|
156
|
+
enabled: true,
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## CLI Commands
|
|
161
|
+
|
|
162
|
+
### Interactive Mode Commands
|
|
163
|
+
|
|
164
|
+
While in chat mode, you can use these commands:
|
|
165
|
+
|
|
166
|
+
- `help` - Show available commands
|
|
167
|
+
- `exit` / `quit` - Exit the session
|
|
168
|
+
- `reset` - Reset conversation history
|
|
169
|
+
- `history` - Show conversation history
|
|
170
|
+
- `tools` - List available MCP tools
|
|
171
|
+
- `servers` - Show MCP server status
|
|
172
|
+
|
|
173
|
+
## Architecture
|
|
174
|
+
|
|
175
|
+
Jiva is designed with extensibility in mind:
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
jiva/
|
|
179
|
+
├── src/
|
|
180
|
+
│ ├── core/ # Core agent logic
|
|
181
|
+
│ ├── models/ # Model integrations and Harmony format
|
|
182
|
+
│ ├── mcp/ # MCP client and server management
|
|
183
|
+
│ ├── interfaces/ # CLI, Electron, Web interfaces
|
|
184
|
+
│ └── utils/ # Utilities and helpers
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Key Components
|
|
188
|
+
|
|
189
|
+
1. **JivaAgent**: Main orchestrator coordinating models, tools, and workspace
|
|
190
|
+
2. **ModelOrchestrator**: Manages multi-model coordination (reasoning + multimodal)
|
|
191
|
+
3. **MCPServerManager**: Handles MCP server lifecycle and tool discovery
|
|
192
|
+
4. **WorkspaceManager**: Manages workspace directory and directive files
|
|
193
|
+
5. **Harmony Format Handler**: Implements gpt-oss-120b's required response format
|
|
194
|
+
|
|
195
|
+
## Working with gpt-oss-120b
|
|
196
|
+
|
|
197
|
+
The gpt-oss-120b model requires the Harmony response format. Jiva handles this automatically with:
|
|
198
|
+
|
|
199
|
+
### Tool Call Parsing
|
|
200
|
+
- Robust parsing of `<|call|>function_name({"param": "value"})<|return|>` format
|
|
201
|
+
- Automatic JSON fixing for common formatting issues
|
|
202
|
+
- Validation against available tools
|
|
203
|
+
|
|
204
|
+
### Multi-Channel Output
|
|
205
|
+
- Analysis channel: Chain-of-thought reasoning
|
|
206
|
+
- Final channel: User-facing responses
|
|
207
|
+
- Tool calling: Structured function calls
|
|
208
|
+
|
|
209
|
+
### Error Handling
|
|
210
|
+
- Retry logic for malformed tool calls
|
|
211
|
+
- Graceful degradation when tools fail
|
|
212
|
+
- Detailed logging for debugging
|
|
213
|
+
|
|
214
|
+
## Development
|
|
215
|
+
|
|
216
|
+
### Build
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
npm run build
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Development Mode
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
npm run dev
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Type Checking
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
npm run type-check
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Programmatic Usage
|
|
235
|
+
|
|
236
|
+
Jiva can also be used programmatically:
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
import {
|
|
240
|
+
JivaAgent,
|
|
241
|
+
createKrutrimModel,
|
|
242
|
+
ModelOrchestrator,
|
|
243
|
+
MCPServerManager,
|
|
244
|
+
WorkspaceManager,
|
|
245
|
+
} from 'jiva';
|
|
246
|
+
|
|
247
|
+
// Create models
|
|
248
|
+
const reasoningModel = createKrutrimModel({
|
|
249
|
+
endpoint: 'https://cloud.olakrutrim.com/v1/chat/completions',
|
|
250
|
+
apiKey: 'your-api-key',
|
|
251
|
+
model: 'gpt-oss-120b',
|
|
252
|
+
type: 'reasoning',
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
// Create orchestrator
|
|
256
|
+
const orchestrator = new ModelOrchestrator({ reasoningModel });
|
|
257
|
+
|
|
258
|
+
// Initialize MCP
|
|
259
|
+
const mcpManager = new MCPServerManager();
|
|
260
|
+
await mcpManager.initialize({
|
|
261
|
+
filesystem: {
|
|
262
|
+
command: 'npx',
|
|
263
|
+
args: ['-y', '@modelcontextprotocol/server-filesystem', process.cwd()],
|
|
264
|
+
enabled: true,
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
// Initialize workspace
|
|
269
|
+
const workspace = new WorkspaceManager({
|
|
270
|
+
workspaceDir: process.cwd(),
|
|
271
|
+
});
|
|
272
|
+
await workspace.initialize();
|
|
273
|
+
|
|
274
|
+
// Create agent
|
|
275
|
+
const agent = new JivaAgent({
|
|
276
|
+
orchestrator,
|
|
277
|
+
mcpManager,
|
|
278
|
+
workspace,
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
// Use agent
|
|
282
|
+
const response = await agent.chat('Hello, Jiva!');
|
|
283
|
+
console.log(response.content);
|
|
284
|
+
|
|
285
|
+
// Cleanup
|
|
286
|
+
await agent.cleanup();
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Troubleshooting
|
|
290
|
+
|
|
291
|
+
### Tool Calls Not Working
|
|
292
|
+
|
|
293
|
+
The gpt-oss-120b model has known issues with tool calling reliability. Jiva implements several workarounds:
|
|
294
|
+
|
|
295
|
+
1. **Retry Logic**: Automatically retries malformed tool calls
|
|
296
|
+
2. **JSON Fixing**: Attempts to fix common JSON formatting issues
|
|
297
|
+
3. **Validation**: Validates tool calls against available tools
|
|
298
|
+
4. **Logging**: Enable debug mode to see detailed tool call information
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
jiva chat --debug
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### MCP Server Connection Issues
|
|
305
|
+
|
|
306
|
+
Check server status:
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
jiva chat
|
|
310
|
+
# Then type: servers
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
View logs:
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
jiva chat --debug
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
## API Documentation
|
|
320
|
+
|
|
321
|
+
For detailed API documentation, see the TypeScript definitions in `src/`.
|
|
322
|
+
|
|
323
|
+
## Contributing
|
|
324
|
+
|
|
325
|
+
Contributions are welcome! Please ensure:
|
|
326
|
+
|
|
327
|
+
1. Code follows TypeScript best practices
|
|
328
|
+
2. All new features include proper error handling
|
|
329
|
+
3. Documentation is updated
|
|
330
|
+
|
|
331
|
+
## License
|
|
332
|
+
|
|
333
|
+
MIT
|
|
334
|
+
|
|
335
|
+
## References
|
|
336
|
+
|
|
337
|
+
- [gpt-oss-120b Model Card](https://huggingface.co/openai/gpt-oss-120b)
|
|
338
|
+
- [Harmony Response Format](https://github.com/openai/harmony)
|
|
339
|
+
- [Model Context Protocol](https://modelcontextprotocol.io/)
|
|
340
|
+
- [Krutrim Cloud API](https://cloud.olakrutrim.com/)
|
|
341
|
+
|
|
342
|
+
## Sources
|
|
343
|
+
|
|
344
|
+
This implementation is based on research from:
|
|
345
|
+
|
|
346
|
+
- [OpenAI Harmony GitHub Repository](https://github.com/openai/harmony)
|
|
347
|
+
- [MCP with OpenAI gpt-oss](https://github.com/Vaibhavs10/mcp-with-openai-gpt-oss)
|
|
348
|
+
- [OpenAI Cookbook - Harmony Format](https://cookbook.openai.com/articles/openai-harmony)
|
|
349
|
+
- [MCP Best Practices](https://modelcontextprotocol.info/docs/best-practices/)
|
|
350
|
+
- [vLLM GPT-OSS Documentation](https://docs.vllm.ai/projects/recipes/en/latest/OpenAI/GPT-OSS.html)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# actions/action_registry.py
|
|
2
|
+
|
|
3
|
+
from typing import Dict, Callable, Any
|
|
4
|
+
from core.llm_interface import LLMInterface
|
|
5
|
+
from core.memory import Memory
|
|
6
|
+
|
|
7
|
+
# Import actions with their existing docstrings
|
|
8
|
+
from actions.file_operations import (
|
|
9
|
+
read_file, write_file, append_file, delete_file,
|
|
10
|
+
list_directory, create_directory,
|
|
11
|
+
read_json, write_json,
|
|
12
|
+
read_csv, write_csv
|
|
13
|
+
)
|
|
14
|
+
import actions.python_coder as py
|
|
15
|
+
import actions.memory_retrieval as mem
|
|
16
|
+
import actions.think as think
|
|
17
|
+
|
|
18
|
+
import actions.web_interface as wi
|
|
19
|
+
|
|
20
|
+
def get_action_registry(llm_interface: LLMInterface, memory: Memory) -> Dict[str, Callable]:
|
|
21
|
+
"""
|
|
22
|
+
Get the registry of all available actions.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
llm_interface (LLMInterface): The language model interface.
|
|
26
|
+
memory (Memory): The memory interface.
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
Dict[str, Callable]: A dictionary mapping action names to their corresponding functions.
|
|
30
|
+
"""
|
|
31
|
+
wi.set_llm_interface(llm=llm_interface)
|
|
32
|
+
think.set_llm_interface(llm=llm_interface)
|
|
33
|
+
py.set_llm_interface(llm=llm_interface)
|
|
34
|
+
mem.set_memory(memory_instance=memory)
|
|
35
|
+
|
|
36
|
+
actions = {
|
|
37
|
+
# File operations
|
|
38
|
+
"read_file": read_file,
|
|
39
|
+
"write_file": write_file,
|
|
40
|
+
"append_file": append_file,
|
|
41
|
+
"delete_file": delete_file,
|
|
42
|
+
"list_directory": list_directory,
|
|
43
|
+
"create_directory": create_directory,
|
|
44
|
+
"read_json": read_json,
|
|
45
|
+
"write_json": write_json,
|
|
46
|
+
"read_csv": read_csv,
|
|
47
|
+
"write_csv": write_csv,
|
|
48
|
+
|
|
49
|
+
# Python coding actions
|
|
50
|
+
"generate_python_code": py.generate_python_code,
|
|
51
|
+
"write_python_code": py.write_python_code,
|
|
52
|
+
"execute_python_code": py.execute_python_code,
|
|
53
|
+
"analyze_python_code": py.analyze_python_code,
|
|
54
|
+
"test_python_function": py.test_python_function,
|
|
55
|
+
|
|
56
|
+
# Memory operations
|
|
57
|
+
# "retrieve_recent_memory": lambda n: retrieve_recent_memory(memory, n),
|
|
58
|
+
# "retrieve_task_result": lambda task_description: retrieve_task_result(memory, task_description),
|
|
59
|
+
# "retrieve_context_for_task": lambda task_description, n=5: retrieve_context_for_task(memory, task_description, n),
|
|
60
|
+
"query_long_term_memory": mem.query_long_term_memory,
|
|
61
|
+
|
|
62
|
+
# Think action
|
|
63
|
+
"think": think.think,
|
|
64
|
+
"replan_tasks": think.replan_tasks,
|
|
65
|
+
"sleep": think.sleep,
|
|
66
|
+
"rerun_tasks": think.rerun_tasks,
|
|
67
|
+
|
|
68
|
+
# Web search actions
|
|
69
|
+
"web_search": wi.web_search,
|
|
70
|
+
"visit_page": wi.visit_page,
|
|
71
|
+
"find_links": wi.find_links,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
return actions
|