PHPackages                             sarfraznawaz2005/ai-team - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sarfraznawaz2005/ai-team

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sarfraznawaz2005/ai-team
========================

A package allowing to create team of AI members that can work and collaborate together to achieve a common goal.

1044PHP

Since Mar 20Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/sarfraznawaz2005/ai-team)[ Packagist](https://packagist.org/packages/sarfraznawaz2005/ai-team)[ RSS](/packages/sarfraznawaz2005-ai-team/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

🤖 AI-Team
=========

[](#robot-ai-team)

A package allowing to create team of AI members that can work and collaborate together to achieve a common goal.

Installation
------------

[](#installation)

`composer require sarfraznawaz2005/ai-team:dev-main`

Workflow
--------

[](#workflow)

1. 👥 Create Team (with optional overall goal)
2. 👤 Create Members (with optional data provided to them)
3. 📋 Define Role of Members
4. 📝 Assign Tasks to Members
5. 🏃 Run

Example
-------

[](#example)

Here we create a team with overall goal along with two members assigned with tasks.

```
$apiKey = getenv('GEMINI_API_KEY');

// define our team and overall goal
$myTeam = new Team('Provide short introduction of the cricketer.', new GoogleGeminiAI($apiKey));

// define members with roles, goals and tasks with same or different LLMs/AI models

$Researcher = (new Member('Researcher', 'You are a Researcher', new GoogleGeminiAI($apiKey)))
    ->assignTask('Provide the list of cricketers with more than one centuries.')
    ->withData(function () {
        // this could come from your database or api for example.
        return assignTask('Retrieve the name of a cricketer with most centuries.');

// add members to the team
$myTeam->addMembers([$Researcher, $Analyst]);

// get team of members to do their work
$result = $myTeam->performTasks();
echo $result;
```

🙌 Result:

```
Researcher performing the task:

Role: You are a Researcher

Task: Provide the list of cricketers with more than one centuries.

Researcher performed task with result:

1. Sachin Tendulkar (100 centuries)
2. Ricky Ponting (71 centuries)
3. Virat Kohli (70 centuries)

Analyst performing the task:

Role: You are an Analyst

Task: Retrieve the name of a cricketer with most centuries.

Analyst performed task with result:

Sachin Tendulkar

FINAL TEAM RESULT:

Sachin Tendulkar is a legendary Indian cricketer widely regarded as one of the greatest batsmen
in the history of the sport. Known as the "Master Blaster," Tendulkar holds the record for most
centuries (100) in international cricket.
```

[See more examples here](https://github.com/sarfraznawaz2005/ai-team/tree/main/examples)

How it works ?
--------------

[](#how-it-works-)

Each member performs his task and passes result to next member as context. Next members uses that information as context to perform his task and provide own results to next and so on. Therefore result of each member is passed to next to build collective knowledge and infer results based on that.

Supported LLMs
--------------

[](#supported-llms)

- OpenAI
- Google Gemini ([They provide reasonable free plan](https://ai.google.dev/tutorials/rest_quickstart))
- Local LLMs ([see example](https://github.com/sarfraznawaz2005/ai-team/blob/main/examples/LocalAI_Example.php))

LLM Signature:

```
(string $apiKey, array $options = [])
```

In `$options`, it is possible to pass LLM settings such as `model`, `temperature`, `topP`, etc. Make sure it's as per the LLM requirements/format.

### Adding Your Own LLMs

[](#adding-your-own-llms)

To add your own LLM providers, implement the [LLMProvider](https://github.com/sarfraznawaz2005/ai-team/blob/main/src/Contracts/LLMProvider.php) interface:

```
interface LLMProvider {
    public function generateText(string $prompt): string;
}
```

Usage Details
-------------

[](#usage-details)

**Creating a Team Member**

Signature:

```
(string $name, string $role, LLMProvider $llmProvider, bool $verbose = true)
```

```
$awesomeMember = (new Member('Researcher', 'You are a Researcher', new GoogleGeminiAI($apiKey)))
 ->assignTask("Perform Awesome Task!");
```

Providing Context Data to Member:

```
$awesomeMember = (new Member('Researcher', 'You are a Researcher', new GoogleGeminiAI($apiKey)))
 ->assignTask("Perform Awesome Task!")
  ->withData(function () {
  // this could come from your database or api for example.
  return assignTask("Perform Awesome Task!")
 ->withData(new MyDataProvider());
```

Two built-in data providers are provided by the package:

- [LLMDataProvider](https://github.com/sarfraznawaz2005/ai-team/blob/main/src/DataProviders/LLMDataProvider.php): Provides results for given prompt by asking LLM model. [See Example](https://github.com/sarfraznawaz2005/ai-team/blob/main/examples/TripPlan_Example.php)
- [UrlDataProvider](https://github.com/sarfraznawaz2005/ai-team/blob/main/src/DataProviders/UrlDataProvider.php): Provides results for given URL by asking LLM model. [See Example](https://github.com/sarfraznawaz2005/ai-team/blob/main/examples/UrlResearch_Example.php)

**Creating a Team**

Signature:

```
(string $overallGoal = '', LLMProvider $llmProvider = null, ExecutionInterface $execution = null, $executionDelayMilliSeconds = 500)
```

```
$myTeam = new Team();
```

or with overall goal of the team in which case after all members have returned results, LLM will be used again against overall goal with context as result of all members.

```
$myTeam = new Team("Team's overall goal here...", new GoogleGeminiAI($apiKey));
```

Adding members to the team:

```
$myTeam->addMembers([$researcher, $analyst]);
```

Third parameter of `Team` class is execution type and currently only `SequentialExecution` type is supported.

- [SequentialExecution](https://github.com/sarfraznawaz2005/ai-team/blob/main/src/Executions/SequentialExecution.php): In this mode, all members are run sequentially in the order passed to `addMembers` method. In this mode, each members passes his result to next member as context and so on.

**Getting Final Results**

Call to get final team result:

```
echo $myTeam->performTasks();
```

**Note** As can be seen in above examples, by passing LLM instance with options, team and members can use different LLMs and models specialized for their tasks.

**Using a Member without a Team**

It is possible to use one or members to get the job done without being part of a team:

```
$awesomeMember = (new Member('Researcher', 'You are a Researcher', new GoogleGeminiAI($apiKey)))
 ->assignTask("Perform Awesome Task!");

 $awesomeMember->performTask();
 $result = $awesomeMember->getResult();
```

[See Example](https://github.com/sarfraznawaz2005/ai-team/blob/main/examples/CodeGenerator_Example.php)

Enabling Collaboration Between Members
--------------------------------------

[](#enabling-collaboration-between-members)

Collaboration or communication between members to achieve given task can be enabled via `provideFeedbackTo` method. It has following signature:

```
(array $members, $maxFeedbacks = 3, $feedbackDelayMilliSeconds = 2, $exitOnFailedFeedback = false)
```

- `$members` specifies which members to collaborate with.
- `$maxFeedbacks` specifies total number of attempts to get desired results from `$members`
- `$feedbackDelayMilliSeconds` specifies delay time before new communication attempt is made
- `$exitOnFailedFeedback` specifies whether to exit the program if collaboration fails.

Let's understand with an example. Let's say we want to create a game. For this we create three AI members:

- Software Engineer
- Code Reviewer
- QA Engineer

We want to make sure code written by Software Engineer is reviewed by Code Reviewer and its QA is done by QA Engineer. If at any point, either of Code Reviewer or QA Engineer find any issues in game code written by Software Engineer, they would inform him about his mistake until hopefully Software Engineer comes up with acceptable result. Here is how we can put this together:

```
$apiKey = getenv('GEMINI_API_KEY');

$SoftwareEngineer = (new Member(
    'Senior Software Engineer',
    'You are expert software engineer specializing in game development with over 10 years of
    experience.',
    new GoogleGeminiAI($apiKey)
))->assignTask(
    'Create a simple shooter game to shoot at enemies that can be played by pressing spacebar
    key to shoot at enemies. Enemies keep coming from the top and as the time passes, game
    should get harder and enemies keep on coming they never stop. Your final answer must be
    the html, css and javascript code, only the html, css and javascript code and nothing else.

You will get $100 if you are able to create error-free, working and really playable game!

Below are rules you must follow:
- Make sure entire code is in SINGLE and in SAME index.html file.
- Do not use external packages or libraries.
- Game boundaries must inside window boundaries.
- Do not assume anything and provide full working code without comments.
'
);

$CodeReviewer = (new Member(
    'Senior Code Reviewer',
    'You are expert code reviewer.',
    new GoogleGeminiAI($apiKey)
))
    ->assignTask(
        'Your job is to do code review of code written by software engineer and make sure it has
         no errors.'
    )
    // max 2 feedback attempts to try to get correct code answer from software engineer
    ->provideFeedbackTo([$SoftwareEngineer], 2);

$QAEngineer = (new Member(
    'Senior QA Engineer',
    'You are expert QA Engineer',
    new GoogleGeminiAI($apiKey)
))
    ->assignTask('Your job is to make sure game is playable and has no errors. Otherwise list the issues you identify.')
    // max 2 feedback attempts to try to get correct code answer from software engineer
    ->provideFeedbackTo([$SoftwareEngineer], 2);

$gameTeam = new Team();

$gameTeam
    ->addMembers([$SoftwareEngineer, $CodeReviewer, $QAEngineer])
    ->excludeResults([$CodeReviewer, $QAEngineer]);

$gameTeam->performTasks();

// save final results to file and remove member names from result
$gameTeam->saveToFile('game.html', true);
```

It would result in something like:

```
Senior Software Engineer performing the task:

Role: You are expert software engineer specializing in game development with over 10 years of experience.

Task: Create a simple shooter game to shoot at enemies that can be played by pressing spacebar key to shoot at enemies.
Enemies keep coming from the top and as the time passes, game should get harder and enemies keep on coming they never stop.
Your final answer must be the html, css and javascript code, only the html, css and javascript code and nothing else.

Senior Software Engineer performed task with result:

[actual code written by software engineer skipped for brevity]

Senior Code Reviewer has entered into feedback loop with Senior Software Engineer.

Senior Code Reviewer has provided following feedback to Senior Software Engineer:

Seems like game is not working properly, fix the code so that it works as expected.

Feedback #1:

Senior Software Engineer has replied with following updated answer:

[actual code written by software engineer skipped for brevity]

Senior Code Reviewer has provided following feedback to Senior Software Engineer:

No further feedback

Successful collaboration between Senior Code Reviewer and Senior Software Engineer!

Senior Code Reviewer exiting the feedback loop with Senior Software Engineer.

Senior QA Engineer has entered into feedback loop with Senior Software Engineer.

Senior QA Engineer has provided following feedback to Senior Software Engineer:

Well done.

Senior QA Engineer is satisfied with answer of Senior Software Engineer!

Senior QA Engineer exiting the feedback loop with Senior Software Engineer.

FINAL TEAM RESULT:

Senior Software Engineer:

[actual code written by software engineer skipped for brevity]
```

[See Example Code Here](https://github.com/sarfraznawaz2005/ai-team/blob/main/examples/GameCreate_Example.php) with [Actual Output Here](https://github.com/sarfraznawaz2005/ai-team/blob/main/examples/GameCreate_Example_Output.txt)

Notice the use of `excludeResults` method in above example. If used, the results of that member will not be shown in final team output and will not be passed to any other member except for whom they are in feedback/communication loop.

Also notice use of `saveToFile` method to save final results to a given path.

Note
----

[](#note)

Not recommended to be used in production, watch out for costs, use at your own risk!

**Probably I won't be updating this package much (hence no release created) due to lack of time but PRs are welcomed through `develop` branch.**

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance40

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/3f9bbcf3a6cda5f8bdf9afe10c20f5c6f563fc1a4d628a9af25c5fdec3f9c216?d=identicon)[sarfraznawaz2005](/maintainers/sarfraznawaz2005)

---

Top Contributors

[![sarfraznawaz2005](https://avatars.githubusercontent.com/u/201788?v=4)](https://github.com/sarfraznawaz2005 "sarfraznawaz2005 (47 commits)")

### Embed Badge

![Health badge](/badges/sarfraznawaz2005-ai-team/health.svg)

```
[![Health](https://phpackages.com/badges/sarfraznawaz2005-ai-team/health.svg)](https://phpackages.com/packages/sarfraznawaz2005-ai-team)
```

###  Alternatives

[akiraz2/yii2-ticket-support

Yii2 Support Ticket Module, easy, flexible, fast

611.7k](/packages/akiraz2-yii2-ticket-support)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
