Skip to content

Commit 36b86d8

Browse files
committed
feat: update readme
1 parent fd8918f commit 36b86d8

File tree

1 file changed

+108
-20
lines changed

1 file changed

+108
-20
lines changed

README.md

+108-20
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
```
2-
___ __ ____
3-
/ _ |___ ____ ___ / /_/ __/__ _____ _____
2+
___ __ ____
3+
/ _ |___ ____ ___ / /_/ __/__ _____ _____
44
/ __ / _ `/ -_) _ \/ __/\ \/ -_) __/ |/ / -_)
5-
/_/ |_\_, /\__/_//_/\__/___/\__/_/ |___/\__/
6-
/___/
5+
/_/ |_\_, /\__/_//_/\__/___/\__/_/ |___/\__/
6+
/___/
77
```
88

99
# AgentServe SDK
@@ -42,7 +42,8 @@ AgentServe provides a Command-Line Interface (CLI) tool to setup your AI agent p
4242

4343
```bash
4444
agentserve init <project_name> [--framework <framework>] # Initialize a new project
45-
agentserve setup # Add AgentServe to an existing project
45+
agentserve build # Generate Dockerfiles
46+
agentserve run # Run the API server and worker
4647
```
4748

4849
## Getting Started
@@ -54,6 +55,7 @@ First we need to set up agentserve in our project. We can do this by running the
5455
Create a new AgentServe project with a specified agent framework.
5556

5657
**Command:**
58+
5759
```bash
5860
agentserve init <project_name> [--framework <framework>]
5961
```
@@ -67,6 +69,7 @@ agentserve init <project_name> [--framework <framework>]
6769
- `blank`
6870

6971
**Example:**
72+
7073
```bash
7174
agentserve init my_project --framework openai
7275
```
@@ -81,9 +84,9 @@ You can update the environment variables in the `.env` file to add your OpenAI A
8184

8285
Use Docker Compose to build and run the server:
8386

84-
```bash
85-
docker-compose up --build
86-
```
87+
```bash
88+
docker-compose up --build
89+
```
8790

8891
This command starts the API server and a Redis instance, allowing your agent to process tasks.
8992

@@ -108,16 +111,19 @@ After initializing a new project, your project directory will look like this:
108111

109112
```
110113
my_project/
111-
├── Dockerfile
112-
├── docker-compose.yml
114+
├── agent/
115+
│ ├── example_agent.py
116+
├── docker/
117+
│ ├── Dockerfile
118+
│ ├── docker-compose.yml
113119
├── main.py
114-
├── example_agent.py
115120
├── requirements.txt
121+
├── .env
116122
```
117123

118124
- **`main.py`**: The main application file where the agent server is configured.
119125
- **`Dockerfile` & `docker-compose.yml`**: Docker configurations for building and running the application.
120-
- **`example_openai_agent.py`**: An example agent tailored to the OpenAI framework.
126+
- **`example_agent.py`**: An example agent tailored to the OpenAI framework.
121127
- **`requirements.txt`**: Lists Python dependencies.
122128

123129
## API Reference
@@ -154,7 +160,6 @@ Get the status of a task.
154160

155161
- `status`: The status of the task.
156162

157-
158163
### GET /task/result/:task_id
159164

160165
Get the result of a task.
@@ -179,23 +184,106 @@ agentserve init my_new_project --framework openai
179184
- Populates it with necessary AgentServe files tailored to the OpenAI framework.
180185
- Sets up `requirements.txt` with necessary dependencies.
181186

182-
### Setup Command (for existing projects)
187+
### Build Command
188+
189+
```bash
190+
agentserve build
191+
```
183192

184-
Navigate to your existing project directory and run:
193+
### Run Command
185194

186195
```bash
187-
agentserve setup
196+
agentserve run
188197
```
189198

190-
**Result:**
199+
## Adding AgentServe to an Existing Project
200+
201+
This guide provides step-by-step instructions to manually integrate AgentServe into your existing Python application. By following these steps, you can add AI agent capabilities to your project without using the AgentServe CLI.
202+
203+
### Steps to Integrate AgentServe
204+
205+
#### 1. Install AgentServe
206+
207+
First, install the agentserve package using pip:
208+
209+
```bash
210+
pip install agentserve
211+
```
212+
213+
If you're using a virtual environment, make sure it is activated before running the command.
214+
215+
#### 2. Update Your requirements.txt
216+
217+
If your project uses a requirements.txt file, add agentserve to it:
218+
219+
```
220+
agentserve
221+
```
222+
223+
This ensures that AgentServe will be installed when setting up the project in the future.
191224

192-
- Adds AgentServe to the project and sets up the necessary files.
193-
- Note this command will not run if the project already included a main.py, Dockerfile or docker-compose.yml
225+
#### 3. Create an agents Directory
226+
227+
Create a new directory called agent in the root of your project. This is where your agent classes will reside.
228+
229+
```bash
230+
mkdir agent
231+
```
232+
233+
#### 4. Implement Your Agent Class
234+
235+
Inside the directory, create a new Python file for your agent. For example, my_agent.py:
236+
237+
```bash
238+
touch agent/my_agent.py
239+
```
240+
241+
Open agent/my_agent.py and implement your agent by subclassing Agent from agentserve:
242+
243+
```python
244+
# agent/my_agent.py
245+
from agentserve import Agent
246+
247+
class MyAgent(Agent):
248+
def process(self, task_data):
249+
# Implement your agent's logic here
250+
client = OpenAI()
251+
response = client.chat.completions.create(
252+
model="gpt-4o-mini",
253+
messages=[{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": task_data}]
254+
)
255+
return response.choices[0].message.content
256+
```
257+
258+
#### 5. Create or Update Your main.py
259+
260+
In the root of your project, create a main.py file if it doesn't already exist:
261+
262+
```bash
263+
touch main.py
264+
```
265+
266+
Open main.py and set up the AgentServer:
267+
268+
```python
269+
from agentserve import AgentServer
270+
from agent.my_agent import MyAgent
271+
272+
agent_server = AgentServer(MyAgent)
273+
app = agent_server.app
274+
```
275+
276+
#### 6. Build and Run the Server
277+
278+
```bash
279+
agentserve build
280+
agentserve run
281+
```
194282

195283
## License
196284

197285
This project is licensed under the MIT License.
198286

199287
## Contact
200288

201-
For any questions or issues, please contact Peter at [email protected].
289+
For any questions or issues, please contact Peter at [email protected].

0 commit comments

Comments
 (0)