Skip to content

Commit

Permalink
Adding basic test suite and ci github actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
darielnoel committed Jul 16, 2024
1 parent 2f5d6da commit bd4f9ae
Show file tree
Hide file tree
Showing 13 changed files with 941 additions and 147 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/test-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Run Tests on PR

on:
pull_request:
branches: [ main ] # Adjust based on your target branch

jobs:
test:
runs-on: ubuntu-latest
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Install dependencies
run: npm install

- name: Build for integration tests
run: npm run build:test

- name: Run integration tests
run: npm run test:integration

- name: Build production version
run: npm run build

- name: Run e2e tests
run: npm run test:e2e
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@
"module": "dist/bundle.esm.js",
"unpkg": "dist/bundle.umd.js",
"scripts": {
"build": "rollup -c",
"build:test": "TEST_ENV=mocked-llm-apis rollup -c",
"dev": "NODE_ENV=development rollup -c -w",
"test": "npm run build:test && jest",
"test:watch": "jest --watch",
"test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand --verbose",
"test:prod": "npm run build && jest",
"play-react": "cd playground/react && npm run dev",
"play-node": "cd playground/nodejs && node index.js"
"build": "rollup -c",
"build:test": "TEST_ENV=mocked-llm-apis rollup -c",
"dev": "NODE_ENV=development rollup -c -w",
"test": "npm run build:test && test:integration",
"test:watch": "TEST_ENV=mocked-llm-apis jest --testPathPattern='tests/e2e' --watch",
"test:debug": "TEST_ENV=mocked-llm-apis node --inspect-brk node_modules/.bin/jest --runInBand --verbose",
"test:prod": "npm run build && jest",
"test:integration": "TEST_ENV=mocked-llm-apis jest --testPathPattern='tests/e2e'",
"test:e2e": "TEST_ENV=real-llm-apis jest --testPathPattern='tests/e2e'",
"play-react": "cd playground/react && npm run dev",
"play-node": "cd playground/nodejs && node index.js"
},

"packageManager": "[email protected]",
"repository": {
"type": "git",
Expand Down Expand Up @@ -59,8 +62,6 @@
"@rollup/plugin-replace": "^5.0.7",
"dotenv": "^16.4.5",
"eslint": "^7.32.0",
"fetch-mock": "^10.0.7",
"fetch-mock-jest": "^1.5.1",
"jest": "^29.7.0",
"prettier": "^2.3.2",
"rollup-plugin-peer-deps-external": "^2.2.4",
Expand Down
1 change: 0 additions & 1 deletion playground/react/src/teams/anthropic/productSpecsTeam.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ const team = new Team({
agents: [requirementsAnalyst, technicalWriter, validator],
tasks: [analysisTask, writingTask, validationTask],
inputs: { founderIdea: 'I want to add a Referral program to our SAAS platform.' }, // Initial input for the first task
env: { OPENAI_API_KEY: import.meta.env.VITE_OPENAI_API_KEY}
});

export default team;
78 changes: 78 additions & 0 deletions tests/e2e/examples/teams/anthropic/productSpecsTeam.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
const { Agent, Task, Team } = require('agenticjs');

// Define agents
const requirementsAnalyst = new Agent({
name: 'Emma',
role: 'Requirements Analyst',
goal: 'Outline core functionalities and objectives for new features based on the founder’s input.',
background: 'Business Analysis',
tools: [],
llmConfig: {
provider: "anthropic", // or "openai"
model: "claude-3-5-sonnet-20240620",
temperature: 0.9,
maxTokens: 1024,
anthropicApiUrl: "https://www.agenticjs.com/proxy/anthropic",
}

});

const technicalWriter = new Agent({
name: 'Lucas',
role: 'Technical Writer',
goal: 'Convert functional outlines into detailed technical specifications.',
background: 'Technical Writing',
tools: [],
llmConfig: {
provider: "anthropic", // or "openai"
model: "claude-3-5-sonnet-20240620",
temperature: 0.9,
maxTokens: 1024,
anthropicApiUrl: "https://www.agenticjs.com/proxy/anthropic",
}
});

const validator = new Agent({
name: 'Mia',
role: 'Validator',
goal: 'Ensure the specifications are accurate and complete.',
background: 'Quality Assurance',
tools: [],
llmConfig: {
provider: "anthropic", // or "openai"
model: "claude-3-5-sonnet-20240620",
temperature: 0.9,
maxTokens: 1024,
anthropicApiUrl: "https://www.agenticjs.com/proxy/anthropic",
}
});

// Define tasks
const analysisTask = new Task({
description: `Analyze the founder's idea: {founderIdea} and outline the necessary functionalities to implement it.`,
expectedOutput: 'A functional outline of the Founder Idea',
agent: requirementsAnalyst
});

const writingTask = new Task({
description: `Create detailed technical specifications based on the functional outline provided. Include user stories, system requirements, and acceptance criteria.`,
expectedOutput: 'A detailed technical specifications document.',
isDeliverable: true,
agent: technicalWriter
});

const validationTask = new Task({
description: `Review the technical specifications to ensure they match the founder's vision and that are technically feasible.`,
expectedOutput: 'A validated technical specifications document ready for development. Must be in Markdown format.',
agent: validator
});

// Create a team
const team = new Team({
name: 'Product Specs Team',
agents: [requirementsAnalyst, technicalWriter, validator],
tasks: [analysisTask, writingTask, validationTask],
inputs: { founderIdea: 'I want to add a Referral program to our SAAS platform.' }, // Initial input for the first task
});

module.exports = team;
115 changes: 115 additions & 0 deletions tests/e2e/examples/teams/anthropic/productSpecsTeam.requests.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

192 changes: 192 additions & 0 deletions tests/e2e/examples/teams/google/productSpecsTeam.requests.js

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions tests/e2e/examples/teams/mistral/productSpecsTeam.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const { Agent, Task, Team } = require('agenticjs');

// Define agents
const requirementsAnalyst = new Agent({
name: 'Emma',
role: 'Requirements Analyst',
goal: 'Outline core functionalities and objectives for new features based on the founder’s input.',
background: 'Business Analysis',
tools: [],
llmConfig: {
provider: "mistral",
model: "mistral-small",
}

});

const technicalWriter = new Agent({
name: 'Lucas',
role: 'Technical Writer',
goal: 'Convert functional outlines into detailed technical specifications.',
background: 'Technical Writing',
tools: [],
llmConfig: {
provider: "mistral",
model: "mistral-small",
}
});

const validator = new Agent({
name: 'Mia',
role: 'Validator',
goal: 'Ensure the specifications are accurate and complete.',
background: 'Quality Assurance',
tools: [],
llmConfig: {
provider: "mistral",
model: "mistral-small",
}
});

// Define tasks
const analysisTask = new Task({
description: `Analyze the founder's idea: {founderIdea} and outline the necessary functionalities to implement it.`,
expectedOutput: 'A functional outline of the Founder Idea',
agent: requirementsAnalyst
});

const writingTask = new Task({
description: `Create detailed technical specifications based on the functional outline provided. Include user stories, system requirements, and acceptance criteria.`,
expectedOutput: 'A detailed technical specifications document.',
isDeliverable: true,
agent: technicalWriter
});

const validationTask = new Task({
description: `Review the technical specifications to ensure they match the founder's vision and that are technically feasible.`,
expectedOutput: 'A validated technical specifications document ready for development. Must be in Markdown format.',
agent: validator
});

// Create a team
const team = new Team({
name: 'Product Specs Team',
agents: [requirementsAnalyst, technicalWriter, validator],
tasks: [analysisTask, writingTask, validationTask],
inputs: { founderIdea: 'I want to add a Referral program to our SAAS platform.' }, // Initial input for the first task
});

module.exports = team;
Loading

0 comments on commit bd4f9ae

Please sign in to comment.