Skip to content

Commit

Permalink
Update readme and CI/CD (#2)
Browse files Browse the repository at this point in the history
* update service ip as host ip

* update service ip as host ip

* update service ip as host ip

* update service ip as host ip

* update service ip as host ip

* patch to fanglei's main

---------

Co-authored-by: Wilson Wang <[email protected]>
  • Loading branch information
ShuFangLei and wilsonwang371 authored Dec 17, 2024
1 parent 6d5ab81 commit 157327b
Show file tree
Hide file tree
Showing 12 changed files with 233 additions and 53 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: SPEAR-TEST

on: push

jobs:
Spear-build:
name: make and run Spear DEMO
runs-on: ubuntu-latest
steps:
- name: Read warehouse contents
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23' # 请根据需要选择合适的 Go 版本

- name: Verify Go version
run: go version

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.13'

- name: Verify Python version
run: python --version

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Install dependencies and compile files
run: |
sudo apt install portaudio19-dev libx11-dev libxtst-dev
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
make
- name: Set environment variables and run test program
run: |
ip_address=$(ip addr show eth0 | grep -oP 'inet \K[\d.]+')
echo "IP Address: $ip_address"
export SPEAR_RPC_ADDR=$ip_address
echo "SPEAR_RPC_ADDR=$ip_address" >> $GITHUB_ENV
OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}
HUGGINGFACEHUB_API_TOKEN=${{ secrets.HUGGINGFACEHUB_API_TOKEN }}
export OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}
export HUGGINGFACEHUB_API_TOKEN=${{ secrets.HUGGINGFACEHUB_API_TOKEN }}
echo "SPEAR_RPC_ADDR=$ip_address" >> $GITHUB_ENV
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> $GITHUB_ENV
echo "HUGGINGFACEHUB_API_TOKEN=${{ secrets.HUGGINGFACEHUB_API_TOKEN }}" >> $GITHUB_ENV
go test -v ./test/simple_req_test.go
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ sdk:
format_python:
isort -rc $(PROJECT_ROOT)/

format: format_python
format_golang:
gofmt -w .

format: format_python format_golang

.PHONY: all worker test workload clean sdk format_python format
125 changes: 112 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,59 @@
README.md

# SPEAR: Distributed AI Agent Platform

SPEAR is an advanced AI Agent platform designed to support multiple runtime environments. It provides flexibility and scalability for running AI agent workloads in various configurations. SPEAR is currently in development, with ongoing features and improvements.

## Features
<table border="1" cellspacing="0" cellpadding="10" style=" width: 100%;">
<tr>
<td style="width: 30%; font-weight: bold;">Features</td>
<td style="width: 35%; font-weight: bold;">Support</td>
<td style="width: 35%; font-weight: bold;">Status</td>
</tr>
<tr>
<td rowspan="4" style="font-weight: bold;">Runtime Support</td>
<td>Process</td>
<td>✅ Supported</td>
</tr>
<tr>
<td>Docker Container</td>
<td>✅ Supported</td>
</tr>
<tr>
<td>WebAssembly</td>
<td>⏳ Work in Progress</td>
</tr>
<tr>
<td>Kubernetes</td>
<td>⏳ Work in Progress</td>
</tr>
<tr>
<td rowspan="2" style="font-weight: bold;">Operating Modes</td>
<td>Local Mode</td>
<td>✅ Supported</td>
</tr>
<tr>
<td>Cluster Mode</td>
<td>⏳ Work in Progress</td>
</tr>
<tr>
<td style="font-weight: bold;">Deployment</td>
<td>Auto Deployment</td>
<td>⏳ Work in Progress</td>
</tr>
<tr>
<td rowspan="3" style="font-weight: bold;">Agent Service</td>
<td>Planning</td>
<td rowspan="3">⏳ Work in Progress</td>
</tr>
<tr>
<td>Memory</td>

</tr>
<tr>
<td>Tools</td>
</tr>
</table>


- **Runtime Support**:
- Process
Expand All @@ -14,8 +63,29 @@ SPEAR is an advanced AI Agent platform designed to support multiple runtime envi
- **Operating Modes**:
- **Local Mode**: Run a single AI agent workload on a local machine.
- **Cluster Mode**: Designed to support AI agent workloads across multiple clusters. *(Not yet implemented)*

- **Deployment**:
- **Auto deployment**: Auto Generate configuration files based on programming code.

- **Agent Service**:
- **Planning**: Offer some agent planning technology enhancing agent ability.
- **Memory**: Provide some memory services to manage the knowledge of the agent.
- **Tools**: Provide the user with some built-in tools, and allow the user to customize their own tools.

## Linux OS installation

## Build Instructions
### Dependencies
SPEAR relies on some other third-party software dependency packages. To install this packages on Linux, use the following command:

```bash
python -m pip install --upgrade pip
pip install build
apt install portaudio19-dev libx11-dev libxtst-dev
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
```

### Build Instructions

To build SPEAR and its related components, run the following command:

Expand All @@ -27,12 +97,14 @@ This command will:
- Compile all required binaries.
- Build Docker images for the related AI Agent workloads.

## Usage
### Usage

To run SPEAR in local mode, use the following command:

```bash
export OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>
export HUGGINGFACEHUB_API_TOKEN=<YOUR_HUGGINGFACEHUB_API_TOKEN>
export SPEAR_RPC_ADDR=<YOUR_LOCAL_SPEAR_RPC_ADDR>
bin/worker exec -n pyconversation
```

Expand All @@ -42,36 +114,63 @@ This command will:

Also, you need to set the environment variable `OPENAI_API_KEY` to your OpenAI API key. In the future, we will support other LLM providers.

## Dependencies


## Mac OS installation

### Dependencies
PortAudio is required for the audio processing component. To install PortAudio on MacOS, use the following command:

```bash
brew install portaudio
```
### Build Instructions

To build SPEAR and its related components, run the following command:

```bash
make
```

This command will:
- Compile all required binaries.
- Build Docker images for the related AI Agent workloads.

### Usage

To run SPEAR in local mode, use the following command:

## Development Status
```bash
export OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>
bin/worker exec -n pyconversation
```

This command will:
- Start the SPEAR worker process in local mode.
- Run the AI agent workload with an ID of 6. (pyconversation-local)

Also, you need to set the environment variable `OPENAI_API_KEY` to your OpenAI API key. In the future, we will support other LLM providers.


### Development Status

Supported Runtimes:
- Process
- Docker Container
- Planned Runtimes:

Planned Runtimes:
- WebAssembly
- Kubernetes

Supported Platforms:
- Currently developed and tested only on macOS.
- Other platforms have not yet been tested or supported.

## Future Plans

- Implementation of cluster mode to enable distributed AI agent workloads across multiple clusters.
- Expansion of runtime support to include WebAssembly and Kubernetes.
- Cross-platform support for environments beyond macOS.

## Contributing

Contributions are welcome! Please open an issue or submit a pull request to discuss new features, bug fixes, or enhancements.

## License

This project is licensed under the Apache License 2.0.
This project is licensed under the Apache License 2.0.
17 changes: 15 additions & 2 deletions cmd/worker/main.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package main

import (
"github.com/lfedgeai/spear/pkg/common"
"github.com/lfedgeai/spear/worker"
"github.com/lfedgeai/spear/worker/task"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"os"
)

type WorkerConfig struct {
Expand All @@ -17,6 +20,7 @@ var (
execWorkloadName string
execReqMethod string
execReqPayload string
execSpearAddr string
execVerbose bool
execDebug bool
)
Expand Down Expand Up @@ -50,6 +54,9 @@ func NewRootCmd() *cobra.Command {
log.Errorf("Invalid request method %s", execReqMethod)
return
}
if execSpearAddr == "" {
execSpearAddr = common.SpearPlatformAddress
}

// check if the workload type is valid
if rtType, ok := validChoices[execRtTypeStr]; !ok {
Expand All @@ -62,7 +69,7 @@ func NewRootCmd() *cobra.Command {
}

// create config
config := worker.NewExecWorkerConfig(execDebug)
config := worker.NewExecWorkerConfig(execDebug, execSpearAddr)
w := worker.NewWorker(config)
w.Initialize()

Expand Down Expand Up @@ -117,9 +124,13 @@ func NewRootCmd() *cobra.Command {
worker.SetLogLevel(log.DebugLevel)
}

if execSpearAddr == "" {
execSpearAddr = common.SpearPlatformAddress
}

// create config
config := worker.NewServeWorkerConfig(addr, port, paths,
debug)
debug, execSpearAddr)
w := worker.NewWorker(config)
w.Initialize()
w.StartServer()
Expand All @@ -138,6 +149,8 @@ func NewRootCmd() *cobra.Command {
serveCmd.PersistentFlags().BoolP("debug", "d", false, "debug mode")
rootCmd.AddCommand(serveCmd)

// spear platform address for workload to connect
rootCmd.PersistentFlags().StringVarP(&execSpearAddr, "spear-addr", "s", os.Getenv("SPEAR_RPC_ADDR"), "SPEAR platform address for workload RPC")
return rootCmd
}

Expand Down
1 change: 1 addition & 0 deletions pkg/common/const.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package common

const MaxDataResponseSize = 4096 * 1024
const SpearPlatformAddress = "172.17.0.1"
3 changes: 2 additions & 1 deletion pkg/tools/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"os"
"time"

"github.com/lfedgeai/spear/pkg/common"
"github.com/lfedgeai/spear/worker"
"github.com/lfedgeai/spear/worker/task/docker"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -43,7 +44,7 @@ func NewTestSetup() *TestSetup {
t.startVectorStoreContainer()

// setup the test environment
cfg := worker.NewServeWorkerConfig("localhost", "8080", []string{}, true)
cfg := worker.NewServeWorkerConfig("localhost", "8080", []string{}, true, common.SpearPlatformAddress)
t.w = worker.NewWorker(cfg)
t.w.Initialize()
go t.w.StartServer()
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CURRENT_DIR := $(shell pwd)
all: clean build

build:
python -m build
python3 -m build

clean:
rm -rf $(CURRENT_DIR)/dist $(CURRENT_DIR)/spear.egg-info
Loading

0 comments on commit 157327b

Please sign in to comment.