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.
RAG combines retrieval and generation processes to produce accurate and contextually relevant outputs. The framework operates as follows:
By integrating these two phases, RAG ensures the AI specialists deliver precise and informed outputs based on a comprehensive knowledge base.
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.
Install Required Modules: Ensure you have the required PowerShell modules installed:
Install-Module -Name PSAOAI
Install-Module -Name PSScriptAnalyzer
Install-Module -Name powerHTML
Install the Script: Install script from Powershell Gallery.
Install-Script AIPSTeam
Run the Script: Execute the script using PowerShell:
"Your project description here" | AIPSTeam.ps1
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.To configure the script to use external providers, you need to set the following environment variables:
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:
[!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.
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')
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:
RAG Configuration:
AZURE_BING_API_KEY
: Your Azure Bing Web Search API key.AZURE_BING_ENDPOINT
: Your Azure Bing Web Search endpoint. ()Example:
Ensure these environment variables are set before running the script to enable the respective functionalities.
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."
Disable Live Streaming:
"Monitor RAM usage" | AIPSTeam.ps1 -Stream $false
Specify Log Folder:
"Monitor RAM usage" | AIPSTeam.ps1 -LogFolder "C:\Logs"
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.
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
.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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".
AIPSTeam.ps1
ProjectTeam
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.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.PSAOAI
PSScriptAnalyzer
PowerHTML
Install-Module
.How do I install the required modules?
Install-Module -Name PSAOAI
Install-Module -Name PSScriptAnalyzer
Install-Module -Name powerHTML
How do I disable live streaming?
AIPSTeam.ps1 -Stream $false
Where are the log files stored?
Log files are stored in the specified log folder or the default folder in MyDocuments
.
How do I load a saved project status?
AIPSTeam.ps1 -LoadProjectStatus "path\to\your\Project.xml"
How do I disable the Project Manager functions?
AIPSTeam.ps1 -NOPM
How do I specify a custom LLM model for ollama?
$env:OLLAMA_MODEL = "your_custom_model"
AIPSTeam.ps1 -LLMProvider "ollama"