|
| 1 | +# Nexent Developer Guide 🛠️ |
| 2 | + |
| 3 | +[](DEVELOPPER_NOTE.md) |
| 4 | +[](DEVELOPPER_NOTE_CN.md) |
| 5 | + |
| 6 | +This guide will help developers quickly get started with Nexent development, including environment setup, tool development, and agent customization. |
| 7 | + |
| 8 | +## Chapter 1: Environment Setup and Running 🚀 |
| 9 | + |
| 10 | +### 1. Install Dependencies |
| 11 | +```bash |
| 12 | +# Navigate to SDK directory |
| 13 | +cd sdk |
| 14 | + |
| 15 | +# Install core dependencies |
| 16 | +pip install . |
| 17 | +``` |
| 18 | + |
| 19 | +### 2. Start Backend Services |
| 20 | +Nexent consists of three core backend services that need to be started separately: |
| 21 | + |
| 22 | +```bash |
| 23 | +# Start data processing service |
| 24 | +python backend/data_process_service.py |
| 25 | + |
| 26 | +# Start main service |
| 27 | +python backend/main_service.py |
| 28 | + |
| 29 | +# Start MCP service |
| 30 | +python backend/mcp_service.py |
| 31 | +``` |
| 32 | + |
| 33 | +### 3. Start Frontend Service |
| 34 | +```bash |
| 35 | +# Navigate to frontend directory |
| 36 | +cd frontend |
| 37 | + |
| 38 | +# Install dependencies |
| 39 | +npm install |
| 40 | + |
| 41 | +# Start development server |
| 42 | +npm run dev |
| 43 | +``` |
| 44 | + |
| 45 | +## Chapter 2: Developing Custom Tools 🛠️ |
| 46 | + |
| 47 | +Nexent implements its tool system based on [Model Context Protocol (MCP)](https://github.com/modelcontextprotocol/python-sdk). To develop a new tool: |
| 48 | + |
| 49 | +1. Implement the tool logic in `mcp_service.py` |
| 50 | +2. Register the tool using the `@mcp.tool()` decorator |
| 51 | +3. Restart the MCP service to activate the new tool |
| 52 | + |
| 53 | +Example: |
| 54 | +```python |
| 55 | +@mcp.tool(name="my_tool", description="My custom tool") |
| 56 | +def my_tool(param1: str, param2: int) -> str: |
| 57 | + # Implement tool logic |
| 58 | + return f"Processing result: {param1} {param2}" |
| 59 | +``` |
| 60 | + |
| 61 | +## Chapter 3: Developing Custom Agents 🤖 |
| 62 | + |
| 63 | +### 1. System Prompts |
| 64 | +System prompt templates are located in the `sdk/nexent/core/prompts` directory, including: |
| 65 | +- `code_agent.yaml`: Base agent prompt |
| 66 | +- `code_agent_demo.yaml`: Demo agent prompt |
| 67 | + |
| 68 | +### 2. Agent Implementation |
| 69 | +Refer to the implementation in `agent_utils.py`: |
| 70 | + |
| 71 | +1. Create an agent instance: |
| 72 | +```python |
| 73 | +from nexent.core.agents import CoreAgent |
| 74 | +from nexent.core.models import OpenAIModel |
| 75 | + |
| 76 | +# Create model instance |
| 77 | +model = OpenAIModel( |
| 78 | + model_id="your-model-id", |
| 79 | + api_key="your-api-key", |
| 80 | + api_base="your-api-base" |
| 81 | +) |
| 82 | + |
| 83 | +# Create agent |
| 84 | +agent = CoreAgent( |
| 85 | + model=model, |
| 86 | + tools=[your_tools], # Add your tools |
| 87 | + system_prompt="Your system prompt" # Custom system prompt |
| 88 | +) |
| 89 | +``` |
| 90 | + |
| 91 | +2. Add tools and configuration: |
| 92 | +- Add custom tools in the `tools` parameter |
| 93 | +- Set agent behavior through `system_prompt` |
| 94 | +- Configure other parameters like `max_steps`, `temperature`, etc. |
| 95 | + |
| 96 | +## Important Notes ⚠️ |
| 97 | + |
| 98 | +1. Ensure all services are properly started before testing |
| 99 | +2. Restart the relevant service after code modifications |
| 100 | +3. Use debug mode in development environment |
| 101 | +4. Follow MCP protocol specifications when developing tools |
| 102 | +5. System prompts need thorough testing |
| 103 | + |
| 104 | +## Getting Help 💬 |
| 105 | + |
| 106 | +- Check the [FAQ](FAQ.md) |
| 107 | +- Join our [Discord community](https://discord.gg/tb5H3S3wyv) |
| 108 | +- Submit [GitHub Issues](https://github.com/AI-Application-Innovation/nexent/issues) |
0 commit comments