{"id":16294149,"url":"https://github.com/sarfraznawaz2005/ai-team","last_synced_at":"2025-03-20T04:30:27.761Z","repository":{"id":223663950,"uuid":"761177001","full_name":"sarfraznawaz2005/ai-team","owner":"sarfraznawaz2005","description":"A package allowing to create team of AI members that can work and collaborate together to achieve a common goal.","archived":false,"fork":false,"pushed_at":"2024-03-25T06:46:12.000Z","size":139,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-25T14:02:18.641Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sarfraznawaz2005.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-21T11:40:45.000Z","updated_at":"2024-04-09T07:49:01.000Z","dependencies_parsed_at":"2024-02-27T20:25:34.462Z","dependency_job_id":"0de3579c-984f-4433-b53f-7cae9d9c0f4c","html_url":"https://github.com/sarfraznawaz2005/ai-team","commit_stats":null,"previous_names":["sarfraznawaz2005/ai-team"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sarfraznawaz2005%2Fai-team","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sarfraznawaz2005%2Fai-team/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sarfraznawaz2005%2Fai-team/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sarfraznawaz2005%2Fai-team/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sarfraznawaz2005","download_url":"https://codeload.github.com/sarfraznawaz2005/ai-team/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244551797,"owners_count":20470919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T20:14:20.668Z","updated_at":"2025-03-20T04:30:27.214Z","avatar_url":"https://github.com/sarfraznawaz2005.png","language":"PHP","funding_links":[],"categories":["LLMs \u0026 AI APIs","Natural Language Processing"],"sub_categories":["Recommended core stack","AI Agents \u0026 Orchestration"],"readme":"# :robot: AI-Team\n\nA package allowing to create team of AI members that can work and collaborate together to achieve a common goal.\n\n## Installation\n\n`composer require sarfraznawaz2005/ai-team:dev-main`\n\n## Workflow\n\n1. :busts_in_silhouette: Create Team (with optional overall goal)\n2. :bust_in_silhouette: Create Members (with optional data provided to them)\n3. :clipboard: Define Role of Members\n4. :pencil: Assign Tasks to Members\n5. :running: Run\n\n## Example\n\nHere we create a team with overall goal along with two members assigned with tasks.\n\n```php\n\n$apiKey = getenv('GEMINI_API_KEY');\n\n// define our team and overall goal\n$myTeam = new Team('Provide short introduction of the cricketer.', new GoogleGeminiAI($apiKey));\n\n// define members with roles, goals and tasks with same or different LLMs/AI models\n\n$Researcher = (new Member('Researcher', 'You are a Researcher', new GoogleGeminiAI($apiKey)))\n    -\u003eassignTask('Provide the list of cricketers with more than one centuries.')\n    -\u003ewithData(function () {\n        // this could come from your database or api for example.\n        return \u003c\u003c\u003cdata\n  Name: Sachin Tendulkar\n  Centuries: 100\n\n  Name: Ricky Ponting\n  Centuries: 71\n\n  Name: Virat Kohli\n  100s: 70\n\n  Name: John Doe\n  Centuries: 0\n  data;\n    });\n\n$Analyst = (new Member('Analyst', 'You are an Analyst', new GoogleGeminiAI($apiKey)))\n    -\u003eassignTask('Retrieve the name of a cricketer with most centuries.');\n\n// add members to the team\n$myTeam-\u003eaddMembers([$Researcher, $Analyst]);\n\n// get team of members to do their work\n$result = $myTeam-\u003eperformTasks();\necho $result;\n\n```\n\n:raised_hands: Result:\n\n```txt\nResearcher performing the task:\n\nRole: You are a Researcher\n\nTask: Provide the list of cricketers with more than one centuries.\n\nResearcher performed task with result:\n\n1. Sachin Tendulkar (100 centuries)\n2. Ricky Ponting (71 centuries)\n3. Virat Kohli (70 centuries)\n\n\nAnalyst performing the task:\n\nRole: You are an Analyst\n\nTask: Retrieve the name of a cricketer with most centuries.\n\nAnalyst performed task with result:\n\nSachin Tendulkar\n\n\nFINAL TEAM RESULT:\n\nSachin Tendulkar is a legendary Indian cricketer widely regarded as one of the greatest batsmen \nin the history of the sport. Known as the \"Master Blaster,\" Tendulkar holds the record for most \ncenturies (100) in international cricket.\n```\n\n[See more examples here](https://github.com/sarfraznawaz2005/ai-team/tree/main/examples)\n\n## How it works ?\n\nEach member performs his task and passes result to next member as context. Next members uses that information as context\nto perform his task and provide own results to next and so on. Therefore result of each member is passed to next to build\ncollective knowledge and infer results based on that.\n\n## Supported LLMs\n\n- OpenAI\n- Google Gemini ([They provide reasonable free plan](https://ai.google.dev/tutorials/rest_quickstart))\n- Local LLMs ([see example](https://github.com/sarfraznawaz2005/ai-team/blob/main/examples/LocalAI_Example.php))\n\nLLM Signature:\n\n```php\n(string $apiKey, array $options = [])\n```\n\nIn `$options`, it is possible to pass LLM settings such as `model`, `temperature`, `topP`, etc. Make sure it's as per the LLM requirements/format.\n\n### Adding Your Own LLMs\n\nTo add your own LLM providers, implement the [LLMProvider](https://github.com/sarfraznawaz2005/ai-team/blob/main/src/Contracts/LLMProvider.php) interface:\n\n```php\ninterface LLMProvider {\n    public function generateText(string $prompt): string;\n}\n```\n\n## Usage Details\n\n**Creating a Team Member**\n\nSignature:\n\n```php\n(string $name, string $role, LLMProvider $llmProvider, bool $verbose = true)\n```\n\n```php\n\n$awesomeMember = (new Member('Researcher', 'You are a Researcher', new GoogleGeminiAI($apiKey)))\n -\u003eassignTask(\"Perform Awesome Task!\");\n```\n\nProviding Context Data to Member:\n\n```php\n$awesomeMember = (new Member('Researcher', 'You are a Researcher', new GoogleGeminiAI($apiKey)))\n -\u003eassignTask(\"Perform Awesome Task!\")\n  -\u003ewithData(function () {\n  // this could come from your database or api for example.\n  return \u003c\u003c\u003cdata\n  Some Data\n  data;\n });\n```\n\nor pass a class that should implement [DataProviderInterface](https://github.com/sarfraznawaz2005/ai-team/blob/main/src/Contracts/DataProviderInterface.php) interface:\n\n```php\n$awesomeMember = (new Member('Researcher', 'You are a Researcher', new GoogleGeminiAI($apiKey)))\n -\u003eassignTask(\"Perform Awesome Task!\")\n -\u003ewithData(new MyDataProvider());\n```\n\nTwo built-in data providers are provided by the package:\n\n- [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)\n- [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)\n\n**Creating a Team**\n\nSignature:\n\n```php\n(string $overallGoal = '', LLMProvider $llmProvider = null, ExecutionInterface $execution = null, $executionDelayMilliSeconds = 500)\n```\n\n```php\n$myTeam = new Team();\n```\n\nor with overall goal of the team in which case after all members have returned results,\nLLM will be used again against overall goal with context as result of all members.\n\n```php\n$myTeam = new Team(\"Team's overall goal here...\", new GoogleGeminiAI($apiKey));\n```\n\nAdding members to the team:\n\n```php\n$myTeam-\u003eaddMembers([$researcher, $analyst]);\n```\n\nThird parameter of `Team` class is execution type and currently only `SequentialExecution` type is supported.\n\n- [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.\n\n**Getting Final Results**\n\nCall to get final team result:\n\n```php\necho $myTeam-\u003eperformTasks();\n```\n\n**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.\n\n**Using a Member without a Team**\n\nIt is possible to use one or members to get the job done without being part of a team:\n\n```php\n$awesomeMember = (new Member('Researcher', 'You are a Researcher', new GoogleGeminiAI($apiKey)))\n -\u003eassignTask(\"Perform Awesome Task!\");\n\n $awesomeMember-\u003eperformTask();\n $result = $awesomeMember-\u003egetResult();\n```\n\n[See Example](https://github.com/sarfraznawaz2005/ai-team/blob/main/examples/CodeGenerator_Example.php)\n\n## Enabling Collaboration Between Members\n\nCollaboration or communication between members to achieve given task can be enabled via `provideFeedbackTo` method.\nIt has following signature:\n\n```php\n(array $members, $maxFeedbacks = 3, $feedbackDelayMilliSeconds = 2, $exitOnFailedFeedback = false)\n```\n\n- `$members` specifies which members to collaborate with.\n- `$maxFeedbacks` specifies total number of attempts to get desired results from `$members`\n- `$feedbackDelayMilliSeconds` specifies delay time before new communication attempt is made\n- `$exitOnFailedFeedback` specifies whether to exit the program if collaboration fails.\n\nLet's understand with an example. Let's say we want to create a game. For this we create three AI members:\n\n- Software Engineer\n- Code Reviewer\n- QA Engineer\n\nWe want to make sure code written by Software Engineer is reviewed by Code Reviewer and its QA is done by QA Engineer.\nIf at any point, either of Code Reviewer or QA Engineer find any issues in game code written by Software Engineer, they\nwould inform him about his mistake until hopefully Software Engineer comes up with acceptable result. Here is how we can\nput this together:\n\n```php\n$apiKey = getenv('GEMINI_API_KEY');\n\n$SoftwareEngineer = (new Member(\n    'Senior Software Engineer',\n    'You are expert software engineer specializing in game development with over 10 years of \n    experience.',\n    new GoogleGeminiAI($apiKey)\n))-\u003eassignTask(\n    'Create a simple shooter game to shoot at enemies that can be played by pressing spacebar \n    key to shoot at enemies. Enemies keep coming from the top and as the time passes, game \n    should get harder and enemies keep on coming they never stop. Your final answer must be \n    the html, css and javascript code, only the html, css and javascript code and nothing else.\n\nYou will get $100 if you are able to create error-free, working and really playable game!\n\nBelow are rules you must follow:\n- Make sure entire code is in SINGLE and in SAME index.html file.\n- Do not use external packages or libraries.\n- Game boundaries must inside window boundaries.\n- Do not assume anything and provide full working code without comments.\n'\n);\n\n$CodeReviewer = (new Member(\n    'Senior Code Reviewer',\n    'You are expert code reviewer.',\n    new GoogleGeminiAI($apiKey)\n))\n    -\u003eassignTask(\n        'Your job is to do code review of code written by software engineer and make sure it has\n         no errors.'\n    )\n    // max 2 feedback attempts to try to get correct code answer from software engineer\n    -\u003eprovideFeedbackTo([$SoftwareEngineer], 2);\n\n$QAEngineer = (new Member(\n    'Senior QA Engineer',\n    'You are expert QA Engineer',\n    new GoogleGeminiAI($apiKey)\n))\n    -\u003eassignTask('Your job is to make sure game is playable and has no errors. Otherwise list the issues you identify.')\n    // max 2 feedback attempts to try to get correct code answer from software engineer\n    -\u003eprovideFeedbackTo([$SoftwareEngineer], 2);\n\n$gameTeam = new Team();\n\n$gameTeam\n    -\u003eaddMembers([$SoftwareEngineer, $CodeReviewer, $QAEngineer])\n    -\u003eexcludeResults([$CodeReviewer, $QAEngineer]);\n\n$gameTeam-\u003eperformTasks();\n\n// save final results to file and remove member names from result\n$gameTeam-\u003esaveToFile('game.html', true);\n```\n\nIt would result in something like:\n\n```txt\nSenior Software Engineer performing the task:\n\nRole: You are expert software engineer specializing in game development with over 10 years of experience.\n\nTask: Create a simple shooter game to shoot at enemies that can be played by pressing spacebar key to shoot at enemies.\nEnemies keep coming from the top and as the time passes, game should get harder and enemies keep on coming they never stop.\nYour final answer must be the html, css and javascript code, only the html, css and javascript code and nothing else.\n\nSenior Software Engineer performed task with result:\n\n[actual code written by software engineer skipped for brevity]\n\nSenior Code Reviewer has entered into feedback loop with Senior Software Engineer.\n\nSenior Code Reviewer has provided following feedback to Senior Software Engineer:\n\nSeems like game is not working properly, fix the code so that it works as expected.\n\nFeedback #1:\n\nSenior Software Engineer has replied with following updated answer:\n\n[actual code written by software engineer skipped for brevity]\n\nSenior Code Reviewer has provided following feedback to Senior Software Engineer:\n\nNo further feedback\n\nSuccessful collaboration between Senior Code Reviewer and Senior Software Engineer!\n\nSenior Code Reviewer exiting the feedback loop with Senior Software Engineer.\n\nSenior QA Engineer has entered into feedback loop with Senior Software Engineer.\n\nSenior QA Engineer has provided following feedback to Senior Software Engineer:\n\nWell done.\n\nSenior QA Engineer is satisfied with answer of Senior Software Engineer!\n\nSenior QA Engineer exiting the feedback loop with Senior Software Engineer.\n\n\nFINAL TEAM RESULT:\n\nSenior Software Engineer:\n\n[actual code written by software engineer skipped for brevity]\n```\n\n[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)\n\nNotice the use of `excludeResults` method in above example. If used, the results of that member will not be shown in\nfinal team output and will not be passed to any other member except for whom they are in feedback/communication loop.\n\nAlso notice use of `saveToFile` method to save final results to a given path.\n\n## Note\n\nNot recommended to be used in production, watch out for costs, use at your own risk!\n\n**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.**\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsarfraznawaz2005%2Fai-team","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsarfraznawaz2005%2Fai-team","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsarfraznawaz2005%2Fai-team/lists"}