GithubHelp home page GithubHelp logo

voytas75 / aipsteam Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 703 KB

PowerShell script simulates a team of AI Agents working together on a user provided PowerShell project. It utilizes Retrieval-Augmented Generation (RAG). The project leverages Azure OpenAI, Ollama, and LM Studio.

PowerShell 100.00%
agents azure llm lmstudio ollama

aipsteam's Introduction

AI PowerShell Team with RAG

AIPSTeam

ko-fi

PowerShell Gallery Codacy Badge

Table of Contents

Overview

This PowerShell script simulates a team of AI Agents working together on a PowerShell project. Each Agent has a unique role and contributes to the project in a sequential manner. The script processes user input, performs various tasks, and generates outputs such as code, documentation, and analysis reports. The application utilizes Retrieval-Augmented Generation (RAG) to enhance its capabilities and can leverage Azure OpenAI, Ollama, or LM Studio to generate the output.

For more information on the AI models and services used in this script, please refer to the following links:

Important

You need AZURE OpenAI subscription, Ollama or LMStudio to use this script.

The quality of the project generated by the AI PowerShell Team depends significantly on the model used and the context window available. The model's ability to understand and process the input accurately is crucial for generating high-quality outputs. Ensure that the model and context window settings are optimized for the best performance and results.

Retrieval-Augmented Generation (RAG)

RAG combines retrieval and generation processes to produce accurate and contextually relevant outputs. The framework operates as follows:

  1. Retrieval: The system retrieves pertinent information from extensive data sources.
  2. Generation: A generative model uses the retrieved information to produce coherent and appropriate responses.

By integrating these two phases, RAG ensures the AI specialists deliver precise and informed outputs based on a comprehensive knowledge base.

Data Source for RAG

The AI PowerShell Team utilizes the Bing Web Search API as the primary data source for its Retrieval-Augmented Generation (RAG) capabilities. This API enables the system to retrieve relevant information from billions of web documents, ensuring that the generated outputs are accurate and contextually relevant.

For more information on the Bing Web Search API, please refer to the following link:

By leveraging the Bing Web Search API, the AI PowerShell Team can provide enhanced search details, safe and location-aware search results, and a variety of instant answers, including images, videos, news, and more. This integration significantly improves the quality and relevance of the outputs generated by the AI Agents.

Features

  • Team Simulation: Emulates a team of specialists including Requirements Analyst, System Architect, PowerShell Developer, QA Engineer, Documentation Specialist, and Project Manager.
  • Sequential Processing: Each specialist processes the input and passes the result to the next specialist in the workflow.
  • Live Streaming: Option to stream output live.
  • Logging: Logs actions and responses of each specialist.
  • Documentation Generation: Automatically generates comprehensive documentation for the project.
  • Code Analysis: Integrates with PSScriptAnalyzer for code quality checks.
  • Feedback Integration: Collects and integrates feedback from team members to improve the response.
  • State Management: Manages global state across different stages of the project.
  • Error Handling: Robust error handling mechanisms to capture and log errors.
  • Version Control: Saves and updates code versions with detailed logs.
  • Interactive Menu: Provides an interactive menu for suggesting new features, analyzing code, generating documentation, and more. This menu can be disabled by enabling Non-Interactive Mode.
  • Input Check: Checks user input and tests if clarification and more context are needed to ensure comprehensive understanding and accurate processing.
  • Non-Interactive Mode: Disables all interaction functionality, allowing the script to run the entire team collaboration workflow without requiring any user input or displaying any menus during the session.
  • User Code Support: Allows the team to work directly on user-provided PowerShell code instead of just a project description, enhancing the ability to debug, optimize, and extend existing scripts.

User Guide

Installation

  1. Install Required Modules: Ensure you have the required PowerShell modules installed:

    Install-Module -Name PSAOAI
    Install-Module -Name PSScriptAnalyzer
    Install-Module -Name powerHTML
  2. Install the Script: Install script from Powershell Gallery.

    Install-Script AIPSTeam
  3. Run the Script: Execute the script using PowerShell:

    "Your project description here" | AIPSTeam.ps1

Configuration

  • Parameters:
    • userInput: Defines the project outline as a string (can also be piped).
    • Stream: Controls whether the output should be streamed live (default: $true).
    • NOPM: Disables the Project Manager functions.
    • NODocumentator: Disables the Documentator functions.
    • NOLog: Disables the logging functions.
    • LogFolder: Specifies the folder where logs should be stored.
    • DeploymentChat: Specifies the deployment chat environment variable for Azure OpenAI (default: retrieved from environment variable PSAOAI_API_AZURE_OPENAI_CC_DEPLOYMENT - PSAOAI).
    • MaxTokens: Specifies the maximum number of tokens to generate in the response. This parameter controls the length of the generated output. The default value is set within the script, but it can be overridden by the user if needed.
    • LLMProvider: Specifies the LLM provider to use (e.g., ollama, LMStudio, AzureOpenAI). Default is "AzureOpenAI".
    • NOTips: Disables tips.
    • VerbosePrompt: Show Prompts.
    • LoadProjectStatus: Loads the project status from a specified path. Part of the 'LoadStatus' parameter set.
    • LLMProvider: Specifies the LLM provider to use (e.g., ollama, LMStudio, AzureOpenAI). Default is "AzureOpenAI".
    • NORAG: Disables the RAG (Retrieve and Generate) functionality.
    • NOUserInputCheck: Disables the input check.
    • NOInteraction: Disable the interaction.
    • TheCodePath: Specifies the path to the user code to be processed by the AI Team.

Environment Variables

To configure the script to use external providers, you need to set the following environment variables:

  1. Azure OpenAI:

    • PSAOAI_API_AZURE_OPENAI_KEY: Your Azure OpenAI API key.
    • PSAOAI_API_AZURE_OPENAI_ENDPOINT: Your Azure OpenAI endpoint.
    • PSAOAI_API_AZURE_OPENAI_APIVERSION: The version of the Azure OpenAI API you want to use.
    • PSAOAI_API_AZURE_OPENAI_CC_DEPLOYMENT: Your Azure OpenAI Chat Completion deployment name.
    • PSAOAI_BANNER: Disable PSAOAI banner. AIPSTeam sets to "0".

    When you start the script, you will be prompted to provide these environment variables if they are not already set. Alternatively, you can set them earlier to avoid prompts during execution. Additionally, ensure that you have the latest version of the PSAOAI module installed to avoid compatibility issues. You can check for updates and install the latest version using the following command:

    Install-Module -Name PSAOAI

    Example:

    [Environment]::SetEnvironmentVariable('PSAOAI_API_AZURE_OPENAI_ENDPOINT','https://<your-endpoint>.openai.azure.com','user')
    [Environment]::SetEnvironmentVariable('PSAOAI_API_AZURE_OPENAI_APIVERSION','2024-05-01-preview','user')
    [Environment]::SetEnvironmentVariable('PSAOAI_API_AZURE_OPENAI_CC_DEPLOYMENT','your-deployment-name','user')

Important

The PSAOAI_API_AZURE_OPENAI_KEY environment variable cannot be provided manually because the PSAOAI module encrypts it for security purposes. Ensure that the key is set and managed through the PSAOAI module's secure mechanisms.

  1. Ollama:
    • OLLAMA_ENDPOINT: Ollama API Endpoint.
    • OLLAMA_MODEL: Ollama model.

The OLLAMA_ENDPOINT environment variable is set to a default value of http://localhost:11434/ by the script. If you need to use a different endpoint, you must manually change the value of this environment variable. You can do this by using the following command:

[Environment]::SetEnvironmentVariable('OLLAMA_ENDPOINT','your-ollama-api-endpoint-uri','user')

Important

For the Ollama provider, you do not need to manually define the OLLAMA_MODEL environment variable. The script will automatically check the status of Ollama and interactively prompt you to start and choose the model to use if it is not already running. This ensures a seamless setup process and reduces the need for manual.

Example:

[Environment]::SetEnvironmentVariable('OLLAMA_MODEL','ollama model, example: phi3:latest','user')
  1. LM Studio:

    • OPENAI_API_KEY: Your LM Studio API key, default is 'lm-studio'.
    • OPENAI_API_BASE : The LLM model to use with LM Studio, default is 'http://localhost:1234/v1'.

    Example:

    [Environment]::SetEnvironmentVariable('OPENAI_API_KEY','lm-studio','user')
    [Environment]::SetEnvironmentVariable('OPENAI_API_BASE','http://localhost:1234/v1','user')
  2. RAG Configuration:

    • AZURE_BING_API_KEY: Your Azure Bing Web Search API key.
    • AZURE_BING_ENDPOINT: Your Azure Bing Web Search endpoint. ()

    Example:

    [Environment]::SetEnvironmentVariable('AZURE_BING_API_KEY','your-azure-bing-api-key','user')
    [Environment]::SetEnvironmentVariable('AZURE_BING_ENDPOINT','https://api.bing.microsoft.com/','user')

Bing Search API documentation

Ensure these environment variables are set before running the script to enable the respective functionalities.

Usage

  1. Basic Usage:

    "Monitor RAM usage and show a single color block based on the load." | AIPSTeam.ps1

    or

    AIPSTeam -userInput "Monitor RAM usage and show a single color block based on the load."
  2. Disable Live Streaming:

    "Monitor RAM usage" | AIPSTeam.ps1 -Stream $false
  3. Specify Log Folder:

    "Monitor RAM usage" | AIPSTeam.ps1 -LogFolder "C:\Logs"
  4. Monitor Disk Usage:

    "Monitor disk usage and display a pie chart of used vs free space." | AIPSTeam.ps1 -Stream $false

    Description: This example monitors the disk usage and displays a pie chart showing the used versus free space. The -Stream $false parameter disables live streaming of the output.

  5. Generate System Report:

    "Script for reporting CPU, RAM, and disk usage." | AIPSTeam -LogFolder "C:\SystemReports"

    Description: This example generates a comprehensive system report that includes details about CPU, RAM, and disk usage. The report is saved in the specified log folder C:\SystemReports.

  6. Check Network Latency:

    "Check network latency and display a line graph of latency over time." | AIPSTeam.ps1 -NOPM

    Description: This example checks the network latency and displays a line graph showing the latency over time. The -NOPM parameter disables the Project Manager functions.

  7. Analyze Event Logs:

    "Analyze Windows Event Logs and summarize critical errors." | AIPSTeam.ps1 -NODocumentator

    Description: This example analyzes the Windows Event Logs and provides a summary of critical errors. The -NODocumentator parameter disables the Documentator functions.

  8. Backup Important Files:

    "Backup important files from Documents to an external drive." | AIPSTeam -NOLog

    Description: This example backs up important files from the Documents folder to an external drive. The -NOLog parameter disables the logging functions.

  9. Monitor GPU Usage:

    "Monitor GPU usage and display a bar chart of GPU load." | AIPSTeam -Stream $true

    Description: This example monitors the GPU usage and displays a bar chart showing the GPU load. The -Stream $true parameter enables live streaming of the output.

  10. Check System Uptime:

    "Check system uptime and display the total uptime in days." | AIPSTeam.ps1 -NOLog -NOPM

    Description: This example checks the system uptime and displays the total uptime in days. The -NOLog parameter disables the logging functions, and the -NOPM parameter disables the Project Manager functions.

  11. Generate Security Audit Report:

    "Generate a security audit report for the system." | AIPSTeam.ps1 -LogFolder "C:\SecurityReports" -NODocumentator

    Description: This example generates a security audit report for the system. The report is saved in the specified log folder C:\SecurityReports. The -NODocumentator parameter disables the Documentator functions.

  12. Monitor Network Bandwidth:

    "Monitor network bandwidth usage and display a real-time graph." | AIPSTeam.ps1 -Stream $true -NOLog

    Description: This example monitors the network bandwidth usage and displays a real-time graph. The -Stream $true parameter enables live streaming of the output, and the -NOLog parameter disables the logging functions.

  13. Check Disk Health:

    "Check disk health and display a summary of SMART attributes." | AIPSTeam -NOPM -NODocumentator

    Description: This example checks the disk health and displays a summary of SMART attributes. The -NOPM parameter disables the Project Manager functions, and the -NODocumentator parameter disables the Documentator functions.

  14. Generate Text Summary Using LLM Provider:

    "Recent software activities on Windows 11." | AIPSTeam -LLMProvider "ollama" -Stream $false

    Description: This example generates a text summary of recent project activities using the specified LLM provider, in this case, "ollama". The -Stream $false parameter disables live streaming of the output.

  15. Run Script Without User Input Check:

    "Cleaning folders where is file 'clean.it'" | AIPSTeam.ps1 -NOUserInputCheck

    Description: This example runs the script without performing any user input checks. The -NOUserInputCheck parameter disables the input validation functions.

  16. Run Script with Disabled Interaction:

    "Generate a daily system health report." | AIPSTeam.ps1 -NOInteraction

    Description: This example runs the script without requiring any user interaction throughout the session. The -NOInteraction parameter ensures that the script will not prompt the user for any input or display any menus.

  17. Work on User's Code:

    AIPSTeam.ps1 -TheCodePath "C:\UserScripts\script.ps1"

    Description: This example works on the user's provided PowerShell script located at C:\UserScripts\script.ps1. The -TheCodePath parameter specifies the path to the user code that the AI team will enhance. If interactive mode is not disabled, the user can provide additional instructions during the session, such as "adding additional logging functionality".

Developer Notes

Code Structure

  • Main Script: AIPSTeam.ps1
  • Classes: ProjectTeam
  • Functions: Various utility functions for processing input, logging, and analysis.

Key Functions and Logic

  • ProjectTeam Class: Represents a team member with specific expertise.
    • ProcessInput: Processes the input and generates a response.
    • Feedback: Provides feedback on the input.
    • AddLogEntry: Adds an entry to the log.
    • Notify: Sends a notification.
    • SummarizeMemory: Summarizes the team member's memory.
  • Utility Functions:
    • SendFeedbackRequest: Sends a feedback request to a team member.
    • Invoke-CodeWithPSScriptAnalyzer: Analyzes the code using PSScriptAnalyzer.
    • Export-AndWritePowerShellCodeBlocks: Exports and writes PowerShell code blocks to a file.

Installation Instructions

Installation

Dependencies and Prerequisites

  • PowerShell Version: Ensure you are using PowerShell 5.1 or later.
  • Modules:
    • PSAOAI
    • PSScriptAnalyzer
    • PowerHTML

Troubleshooting Tips and Common Issues

  • Module Not Found: Ensure the required modules are installed using Install-Module.
  • Permission Issues: Run PowerShell as an administrator.
  • Script Errors: Check the log files in the specified log folder for detailed error messages.

FAQ

  1. How do I install the required modules?

    Install-Module -Name PSAOAI
    Install-Module -Name PSScriptAnalyzer
    Install-Module -Name powerHTML
  2. How do I disable live streaming?

    AIPSTeam.ps1 -Stream $false
  3. Where are the log files stored?

    Log files are stored in the specified log folder or the default folder in MyDocuments.

  4. How do I load a saved project status?

    AIPSTeam.ps1 -LoadProjectStatus "path\to\your\Project.xml"
  5. How do I disable the Project Manager functions?

    AIPSTeam.ps1 -NOPM
  6. How do I specify a custom LLM model for ollama?

    $env:OLLAMA_MODEL = "your_custom_model"
    AIPSTeam.ps1 -LLMProvider "ollama"

aipsteam's People

Contributors

voytas75 avatar nathanwindisch avatar

Stargazers

devanssound avatar

Watchers

 avatar  avatar

Forkers

nathanwindisch

aipsteam's Issues

Ih: delivery project prompt

If you're uncertain about whether the user wants to create code, prepare a structure, or write an article, you can craft a general prompt that allows GPT-3.5 Turbo to generate content for any of these scenarios. However, if you're specifically looking to generate content for a code-related task, a structural design task, or an article writing task, it's better to provide a prompt tailored to each of those scenarios.

Here are examples of both a general prompt and prompts tailored to each specific scenario:

  1. General Prompt:
Given the provided context, generate content that aligns with the user's needs. The content could involve writing code, preparing a structural design, or composing an article. Ensure that the generated content is relevant and coherent based on the given context.
  1. Code Writing Prompt:
Write a code snippet that fulfills the specified requirements. Ensure that the code is syntactically correct, efficient, and adheres to best coding practices.
  1. Structural Design Prompt:
Create a structured outline or plan for the given project. Define the key components, functionalities, and their interrelationships to provide a clear blueprint for implementation.
  1. Article Writing Prompt:
Compose an informative and engaging article on the provided topic. Ensure that the article is well-researched, organized, and contains valuable insights or perspectives for the target audience.

Based on the specific task at hand or the user's requirements, you can choose the appropriate prompt to guide the content generation process. If you're unsure about the user's intentions, starting with a general prompt can help provide flexibility until more clarity is obtained.

Ih: prompt for request message:


Your task is to generate english JSON for a developer to use in code. The specific task is to create a JSON structure for the idea "write article in japanise about KQL basics in azure sentinel.". The response must be in JSON format ready to be copied and pasted into a code snippet. Every json value must be in english. Modify only the values, in the given JSON example structure: { "type": "", "task": "", "language": "", "task_description": "" }

Related projects

Add to menu option for suggestion of related projects (generated with or wo rag)

Ih: create dynamically plan

Generating the plan dynamically after the user provides a description is a great idea! To prompt the GPT orchestrator to create the plan based on the user's description, you can use a directive prompt that instructs the orchestrator to generate a project plan tailored to the provided description. Here's a suggestion for the prompt:

"Generate a project plan based on the user's description. Your task is to analyze the provided description and outline the necessary steps to achieve the project objectives. Consider factors such as data gathering, task execution, expert interaction, iteration, and final deliverables. Provide clear and detailed instructions for each step of the plan."

This prompt instructs the orchestrator to create a comprehensive project plan that encompasses all relevant aspects of the project based on the user's description. The orchestrator will then proceed to generate the plan according to the instructions provided in the prompt. This approach allows for flexibility and customization based on the specific requirements of each project. Let me know if you'd like further refinement or if you have any other questions!

Ih: json prompt step plan

{
  "plan": {
    "Understanding the Objective": {
      "Orchestrator Prompt": "You act as the project manager. Your task is to clearly define the project objectives based on the user's description. Summarize the key requirements and goals of the project, considering factors such as scope, deliverables, and desired outcomes. Provide a clear overview of what needs to be achieved.",
      "Sub-step": "Update the project objective summary based on any new information or insights gathered during the data gathering phase."
    },
    "Data Gathering": {
      "Orchestrator Prompt": "You act as the project manager. Your task is to gather comprehensive information to inform the project planning process. Identify the specific requirements, constraints, and preferences outlined by the user. Collect relevant data, specifications, and background context to guide the project development.",
      "Sub-step": "Review and update the gathered data to ensure its accuracy and relevance. Incorporate any new findings or changes in project requirements."
    },
    "Developing a Project Plan": {
      "Orchestrator Prompt": "You act as the project manager. Your task is to create a detailed project plan outlining the steps to achieve the project objectives. Break down the project into manageable tasks, establish timelines, and allocate resources accordingly. Consider dependencies, risks, and contingencies to ensure a well-structured and feasible plan.",
      "Sub-step": "Revise the project plan based on the updated data and insights gathered during the data gathering phase. Adjust task priorities, timelines, and resource allocations as needed."
    },
    "Execution": {
      "Orchestrator Prompt": "You act as the project manager. Your task is to assign specific tasks to expert models or team members for execution. Clearly define the scope, objectives, and expectations for each task. Encourage creativity and innovation in task implementation while ensuring alignment with project goals and requirements.",
      "Sub-step": "Monitor the progress of task execution and gather feedback from team members. Incorporate any new developments or insights into the ongoing project activities."
    },
    "Expert Interaction": {
      "Task-specific Expert Model Prompt": "You act as the expert model for [specific task]. Your task is to develop a solution or provide expertise in your assigned area. Apply relevant knowledge, skills, and best practices to address the task requirements effectively. Deliver outputs that meet the specified criteria and contribute to the overall project objectives.",
      "Sub-step": "Regularly review and update the outputs of expert models based on the latest project data and feedback. Continuously refine and improve the solutions to better align with project requirements."
    },
    "Integrating Expert Outputs": {
      "Orchestrator Prompt": "You act as the project manager. Your task is to integrate the outputs from expert models or team members into a cohesive solution. Ensure consistency, compatibility, and alignment with the project plan and objectives. Coordinate the integration process and provide feedback to refine the outputs as needed.",
      "Sub-step": "Iteratively integrate and test the outputs from expert models to ensure they work together seamlessly. Address any compatibility issues or conflicts that arise during the integration process."
    },
    "Iterating and Refining": {
      "Orchestrator Prompt": "You act as the project manager. After reviewing the initial outputs, iterate on the design and implementation to improve quality and performance. Solicit feedback from stakeholders and team members to identify areas for refinement. Continuously evaluate and refine the solution to achieve optimal results.",
      "Sub-step": "Iterate on the project plan, execution, and outputs based on feedback and ongoing data analysis. Make adjustments to improve project outcomes and address any emerging challenges or opportunities."
    },
    "Finalizing Deliverables": {
      "Orchestrator Prompt": "You act as the project manager. Your task is to finalize the project deliverables and documentation. Ensure that all requirements have been met, and the solution is ready for deployment or implementation. Prepare comprehensive documentation and instructions to support end-users.",
      "Sub-step": "Review and update the finalized deliverables and documentation to reflect the latest project updates and changes. Ensure that all information is accurate, up-to-date, and relevant for end-users."
    },
    "Generating Output": {
      "Orchestrator Prompt": "You act as the project manager. Deliver the completed project deliverables along with detailed documentation and instructions. Provide support for user deployment, configuration, and troubleshooting. Encourage feedback and plan for future updates or enhancements as needed.",
      "Sub-step": "Provide mechanisms for ongoing support, maintenance, and updates to the delivered project outputs. Establish channels for user feedback and incorporate improvements based on user experiences and evolving requirements."
    }
  }
}

Error when Load Project Status

when importing existing project there are five errors: "Join-Path : Cannot bind argument to parameter 'Path' because it is null.". two other was fixed. the problem was with using $globalstate before it was created.

come back to root menu

add escape to root menu without any action. example: now is not possible to come back when i.e. '1' choosen.

non-interactive

add feature to run script in non-interactive mode. i.e. -NONInteractive param. param is not valid, no need to safe in globalstate when the project is loaded from xml file. in such case the menu appears.

Ih: new project exploration

{
"step_name": "Project Exploration",
"isRequired": true,
"prompt": "Using the provided JSON format as a reference, analyze the user's earlier input about the project to identify key objectives, desired functionalities, and any constraints or limitations. Ensure that the output follows the JSON structure: { "project_name": "", "objectives": [ "" ], "functionalities": [ "" ], "constraints": { "resources": [ "" ], "technology": [ "" ], "other": [ "" ] }}. Fill in any missing information to complete the task."
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.