diff --git a/README.md b/README.md index 03fc2b2f..6d712c7c 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,60 @@ -# Welcome to Project Mercury +# AI Shell (a.k.a Project Mercury) -**Project Mercury** contains our latest CLI tool that provides an interactive shell session to chat -with language models, creating an *AI Shell*. Users can use _agents_ to interact with different AI models, or other -assistance providers, in a conversational manner. **Project Mercury** also provides a framework for -creating AI agents. +Welcome to the **AI Shell** repository! AI Shell is a CLI tool that brings the power of artificial +intelligence directly to your command line! Designed to help you get command assistance from various +AI assistants, AI Shell is a versatile tool to help you become more productive in the command line. +We call these various AI assistant providers _agents_. You can use agents to interact with different +generative AI models or other AI/ML/assistant providers in a conversational manner. This repo +contains the code of the AI Shell engine, agents and details on how to create your own agent. -Why the name **Project Mercury**? The name is inspired both by the Roman god of messages and the -first human spaceflight by the US. This project is our first step into the new world of AI powered -assistance and focuses on being the connection (or messenger) between the user and the AI model. +Why the name **Project Mercury**? This was the original code name of the project and was inspired +both by the Roman god of messages and the first human spaceflight by the US. This project is our +first step into the new world of AI powered assistance and focuses on being the connection (or +messenger) between the user and the AI model. -This project is currently in the **alpha** phase. Expect many significant changes to the code as we -experiment and refine the user experiences of this tool. We appreciate your feedback and patience as -we continue our development. +This project is currently in a very early **public preview** state. Expect many significant changes +to the code as we experiment and refine the user experiences of this tool. We appreciate your +feedback and patience as we continue our development. -![GIF showing demo of the AI Shell][04] +## New to AI Shell? -## Installation +To learn more about AI Shell, we recommend you check out the [overview][19] page of the AI Shell +documentation. + +### Usage + +There are two modes to use AI Shell, standalone and a side-by-side, integrated experience with +PowerShell 7. For more information see, +- [Get Started with AI Shell in PowerShell][15] +- [Get Started with AI Shell (standalone)][16] + +### AI Shell in PowerShell + +![GIF showing demo of the AI Shell in PowerShell][21] + +### Standalone experience + +![GIF showing demo of the AI Shell standalone][20] + +## Getting AI Shell + +AI Shell is supported on Windows, MacOS and Linux, however the best experience you can have is with +Windows, [PowerShell 7][11] and [Windows Terminal][14]. For more information see, +[Installing AI Shell][13]. + +## Locally Building AI Shell Some prerequisites for building an AI Shell: -- Build script requires PowerShell v7.2 or newer versions -- [PowerShell v7.4][11] is recommended +- Build script requires [PowerShell v7.4][18] or newer versions - [.NET SDK 8][09] is required to build the project Here are the steps to install and use. 1. Clone this repository, `git clone https://github.com/PowerShell/ProjectMercury` 2. Import the `build.psm1` module by running `import-module ./build.psm1` -3. Run the `Start-Build` command +3. Run the `Start-Build` command (You can specify which agents build with the `-AgentsToInclude` + parameter) 4. After the build is complete, you can find the produced executable `aish` in the `out\debug\app` folder within the repository's root directory. You can add the location to the `PATH` environment variable for easy access. The full path is copied to your clipboard after successful build. @@ -35,47 +62,22 @@ Here are the steps to install and use. ## AI Agents Project Mercury provides a framework for creating and registering multiple AI Agents. The agents are -libraries that you use to interact with different AI models or assistance providers. Currently, -these are the supported agents: +libraries that you use to interact with different AI models or assistance providers. AI Shell +releases with two agents, the `openai-gpt` and `azure` agent. However there are additional ones +supported if you locally build the project: Agent README files: -- [`openai-gpt`][08] +- [`openai-gpt`][08] (shipped with AI Shell) - [`ollama`][06] - [`interpreter`][07] +- [`azure`][17] (shipped with AI Shell) When you run `aish`, you are prompted to choose an agent. For more details about each agent, see the README in the each agent folder. To learn more about how to create an agent for yourself please see, [Creating an Agent][03]. -## Usage - -To start a chat session with the LLM, run `aish`, which starts a new session in your current window. -Choose the agent you would like to use. Once you select an agent you can begin your conversation. - -We suggest using a split pane approach with the terminal of choice. In Windows Terminal, use the -following command to start `aish` in a new split pane: - -```shell -wt -w 0 sp aish -``` - -You can bind this command to a key like `F3` in your PowerShell session. Add the following code to -your `$PROFILE` script: - -```powershell -$PSReadLineSplat = @{ - Chord = 'F3' - ScriptBlock = { - wt -w 0 sp --tabColor '#345beb'--size 0.4 -p $env:WT_PROFILE_ID --title 'AIShell' - } -} -Set-PSReadLineKeyHandler @PSReadLineSplat -``` - -Similarly, you can use iTerm2 to get a similiar split pane experience on MacOS. You can split the pane vertically by pressing `Cmd + D` and then run `aish` in one of the panes. - ### Chat commands By default, `aish` provides a base set of chat `/` commands used to interact with the responses from @@ -96,14 +98,15 @@ the AI model. To get a list of commands, use the `/help` command in the chat ses /retry Regenerate a new response for the last query. Core ``` -Also, agents can implement their own commands. For example, the `openai-gpt` agent register the command `/gpt` -for managing the GPTs defined for the agent. Some commands, such as `/like` and `/dislike`, are commands that -sends feedback to the agents. It is up to the agents to consume the feedback. +Also, agents can implement their own commands. For example, the `openai-gpt` agent register the +command `/gpt` for managing the GPTs defined for the agent. Some commands, such as `/like` and +`/dislike`, are commands that sends feedback to the agents. It is up to the agents to consume the +feedback. ### Key bindings for commands -AI Shell supports key bindings for the `/code` command. -They are currently hard-coded, but custom key bindings will be supported in future releases. +AI Shell supports key bindings for the `/code` command. They are currently hard-coded, but custom +key bindings will be supported in future releases. | Key bindings | Command | Functionality | | ------------------------- | ---------------- | ------------- | @@ -114,10 +117,12 @@ They are currently hard-coded, but custom key bindings will be supported in futu ### Configuration -Currently, AI Shell supports very basic configuration. One can creates a file named `config.json` under `~/.aish` to configure AI Shell, -but it only supports declaring the default agent to use at startup. This way you do not need to select agents everytime you run `aish.exe` +Currently, AI Shell supports very basic configuration. One can creates a file named `config.json` +under `~/.aish` to configure AI Shell, but it only supports declaring the default agent to use at +startup. This way you do not need to select agents every time you run `aish.exe` -Configuration of AI Shell will be improved in future releases to support custom key bindings, color themes and more. +Configuration of AI Shell will be improved in future releases to support custom key bindings, color +themes and more. ```json { @@ -131,14 +136,17 @@ Please see [CONTRIBUTING.md][02] for more details. ## Privacy -AIShell does not capture, collect, store, or process any personal data or personally identifiable information (PII). All data interactions -are limited to the scope of the functionality provided by the tool and do not involve any form of personal data collection. +AI Shell does not capture, collect, store, or process any personal data or personally identifiable +information (PII). All data interactions are limited to the scope of the functionality provided by +the tool and do not involve any form of personal data collection. -Some agents integrated with AIShell may collect telemetry data to improve performance, enhance user experience, or troubleshoot issues. -We recommend that you refer to the individual agent’s README or documentation for more information on the telemetry practices and data collection -policies for each agent. +Some agents integrated with AI Shell may collect telemetry data to improve performance, enhance user +experience, or troubleshoot issues. We recommend that you refer to the individual agent’s README or +documentation for more information on the telemetry practices and data collection policies for each +agent. -If you are interested in learning more, see [Microsoft's Privacy Statement](https://www.microsoft.com/en-us/privacy/privacystatement?msockid=1fe60b30e66967f13fb91f29e73f661a). +If you are interested in learning more, see +[Microsoft's Privacy Statement](https://www.microsoft.com/en-us/privacy/privacystatement?msockid=1fe60b30e66967f13fb91f29e73f661a). ## Support @@ -155,7 +163,7 @@ For any security issues, please see our [Security Policy][12]. ## Feedback We're still in development and value your feedback! Please file [issues][10] in this repository for -bugs, suggestions, or feedback. +bugs, suggestions, or feedback. If you would like to give more candid feedback and sign up for testing future versions and features before they are released, please fill out this [form][22]. [01]: ./docs/CODE_OF_CONDUCT.md @@ -165,8 +173,19 @@ bugs, suggestions, or feedback. [05]: ./docs/SUPPORT.md [06]: ./shell/agents/AIShell.Ollama.Agent/README.md [07]: ./shell/agents/AIShell.Interpreter.Agent/README.md -[08]: ./shell/agents/AIShell.OpenAI.Agent/README.md +[08]: https://learn.microsoft.com/powershell/utility-modules/aishell/how-to/agent-openai [09]: https://dotnet.microsoft.com/en-us/download [10]: https://github.com/PowerShell/ProjectMercury/issues [11]: https://learn.microsoft.com/powershell/scripting/install/installing-powershell [12]: ./docs/SECURITY.md +[13]: https://learn.microsoft.com/powershell/utility-modules/aishell/install-aishell +[14]: https://learn.microsoft.com/windows/terminal/ +[15]: https://learn.microsoft.com/powershell/utility-modules/aishell/get-started/aishell-powershell +[16]:https://learn.microsoft.com/powershell/utility-modules/aishell/get-started/aishell-standalone +[17]: https://learn.microsoft.com/powershell/utility-modules/aishell/how-to/agent-azure +[18]: https://github.com/PowerShell/PowerShell/releases/tag/v7.4.6 +[19]: https://learn.microsoft.com/powershell/utility-modules/aishell/overview +[20]: ./docs/media/standalone-startup.gif +[21]: ./docs/media/aishellwithPowerShell.gif +[22]: https://aka.ms/AIShell-Feedback +[logo]: ./docs/media/AIShellIconSVG.svg \ No newline at end of file diff --git a/docs/media/AIShellIconPNG.png b/docs/media/AIShellIconPNG.png new file mode 100644 index 00000000..bf15739b Binary files /dev/null and b/docs/media/AIShellIconPNG.png differ diff --git a/docs/media/AIShellIconSVG.svg b/docs/media/AIShellIconSVG.svg new file mode 100644 index 00000000..cb28c392 --- /dev/null +++ b/docs/media/AIShellIconSVG.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/media/aishellwithPowerShell.gif b/docs/media/aishellwithPowerShell.gif new file mode 100644 index 00000000..9d3ef285 Binary files /dev/null and b/docs/media/aishellwithPowerShell.gif differ diff --git a/docs/media/standalone-startup.gif b/docs/media/standalone-startup.gif new file mode 100644 index 00000000..e0266432 Binary files /dev/null and b/docs/media/standalone-startup.gif differ diff --git a/shell/AIShell.Kernel/Shell.cs b/shell/AIShell.Kernel/Shell.cs index 48424e8c..e797eef3 100644 --- a/shell/AIShell.Kernel/Shell.cs +++ b/shell/AIShell.Kernel/Shell.cs @@ -286,7 +286,7 @@ private void LoadAvailableAgents() chosenAgent ??= _agents.Count is 1 ? _agents[0] : Host.PromptForSelectionAsync( - title: "[orange1]Please select an [Blue]agent[/] to use[/]:\n[grey](You can switch to another agent later by typing [Blue]@[/])[/]", + title: "Welcome to AIShell! We’re excited to have you explore our [bold]Public Preview[/]. Documentation is available at [link=https://aka.ms/AIShell-Docs]aka.ms/AIShell-Docs[/], and we’d love to hear your thoughts - share your feedback with us at [link=https://aka.ms/AIShell-Feedback]aka.ms/AIShell-Feedback[/].\n\n[orange1]Please select an AI [Blue]agent[/] to use[/]:\n[grey](You can switch to another agent later by typing [Blue]@[/])[/]", choices: _agents, converter: static a => a.Impl.Name) .GetAwaiter().GetResult(); diff --git a/shell/agents/AIShell.OpenAI.Agent/README.md b/shell/agents/AIShell.OpenAI.Agent/README.md index 82406d30..e88bb2e6 100644 --- a/shell/agents/AIShell.OpenAI.Agent/README.md +++ b/shell/agents/AIShell.OpenAI.Agent/README.md @@ -4,96 +4,7 @@ This agent is designed to provide a flexible and user-friendly platform for inte services, either the public OpenAI service or a private deployment of the Azure OpenAI service, through one or more customly defined GPT instances. -## GPT - -GPTs are configured in the agent's settings file, which is in JSON format. Each GPT configuration -includes the name, description, the targeted OpenAI model, and the system prompt for interaction. -This allows for the creation of distinct GPTs, each tailored to a specific domain or scenario, whose -system prompts can be customized to suit these individual scenarios. Furthermore, you have the -flexibility to select different OpenAI models for each GPT as required. - -## Command - -The command `/gpt` is provided to make it easy to manage the GPTs. - -- Run `/gpt use ` to switch to another GPT instance, or run `/gpt use` to simply choose - from the available ones. -- Run `/gpt list ` to view the details of a GPT definition, or run `/gpt list` to list all - available GPTs. - -```shell -aish:1> /gpt --help -Description: - Command for GPT management within the 'openai-gpt' agent. - -Usage: - gpt [command] [options] - -Options: - -h, --help Show help and usage information - -Commands: - list List a specific GPT, or all available GPTs. - use Specify a GPT to use, or choose one from the available GPTs. -``` - -## Prerequisites - -- For OpenAI, you need the **Model Name** and **API Key** to use the agent. - - [OpenAI API Key][03] - - [OpenAI Model][04] - -- For Azure OpenAI Service, you need the **Endpoint**, **Deployment Name**, **Model Name**, and **API Key** to use the agent. - - [Access to Azure OpenAI][01] - - [Create an Azure OpenAI deployment][02] - -## Configuration - -To configure the agent, run `/agent config openai-gpt` to open up the setting file in your default editor, -and then update the file based on the following example. - -```jsonc -{ - // Declare GPT instances. - "GPTs": [ - // To use the Azure OpenAI service: - // - Set `Endpoint` to the endpoint of your Azure OpenAI service, - // or the endpoint to the Azure API Management service if you are using it as a gateway. - // - Set `Deployment` to the deployment name of your Azure OpenAI service. - // - Set `ModelName` to the name of the model used for your deployment, e.g. "gpt-4-0613". - // - Set `Key` to the access key of your Azure OpenAI service, - // or the key of the Azure API Management service if you are using it as a gateway. - { - "Name": "ps-az-gpt4", - "Description": "A GPT instance with expertise in PowerShell scripting and command line utilities. Use gpt-4 running in Azure.", - "Endpoint": "", - "Deployment": "", - "ModelName": "", // required field to infer properties of the service, such as token limit. - "Key": "", - "SystemPrompt": "1. You are a helpful and friendly assistant with expertise in PowerShell scripting and command line.\n2. Assume user is using the operating system `Windows 11` unless otherwise specified.\n3. Use the `code block` syntax in markdown to encapsulate any part in responses that is code, YAML, JSON or XML, but not table.\n4. When encapsulating command line code, use '```powershell' if it's PowerShell command; use '```sh' if it's non-PowerShell CLI command.\n5. When generating CLI commands, never ever break a command into multiple lines. Instead, always list all parameters and arguments of the command on the same line.\n6. Please keep the response concise but to the point. Do not overexplain." - }, - - // To use the public OpenAI service: - // - Ignore the `Endpoint` and `Deployment` keys. - // - Set `ModelName` to the name of the model to be used. - // - Set `Key` to be the OpenAI access token. - // For example: - { - "Name": "ps-gpt4o", - "Description": "A GPT instance with expertise in PowerShell scripting and command line utilities. Use gpt-4o running in OpenAI.", - "ModelName": "gpt-4o", - "Key": "", - "SystemPrompt": "1. You are a helpful and friendly assistant with expertise in PowerShell scripting and command line.\n2. Assume user is using the operating system `Windows 11` unless otherwise specified.\n3. Use the `code block` syntax in markdown to encapsulate any part in responses that is code, YAML, JSON or XML, but not table.\n4. When encapsulating command line code, use '```powershell' if it's PowerShell command; use '```sh' if it's non-PowerShell CLI command.\n5. When generating CLI commands, never ever break a command into multiple lines. Instead, always list all parameters and arguments of the command on the same line.\n6. Please keep the response concise but to the point. Do not overexplain." - } - ], - - // Specify the default GPT instance to use for user query. - "Active": "ps-az-gpt4" -} -``` +For more information about this agent, see the [OpenAI Agent][01] documentation. -[01]: https://aka.ms/oai/access?azure-portal=true -[02]: https://learn.microsoft.com/azure/ai-services/openai/how-to/create-resource?pivots=web-portal -[03]: https://platform.openai.com/api-keys -[04]: https://platform.openai.com/docs/models +[01]: https://learn.microsoft.com/powershell/utility-modules/aishell/how-to/agent-openai diff --git a/shell/agents/Microsoft.Azure.Agent/AzureAgent.cs b/shell/agents/Microsoft.Azure.Agent/AzureAgent.cs index 3ccb764b..38bb5ed1 100644 --- a/shell/agents/Microsoft.Azure.Agent/AzureAgent.cs +++ b/shell/agents/Microsoft.Azure.Agent/AzureAgent.cs @@ -59,20 +59,19 @@ public AzureAgent() Name = "azure"; Company = "Microsoft"; - Description = "This AI assistant can generate Azure CLI and Azure PowerShell commands for managing Azure resources, answer questions, and provides information tailored to your specific Azure environment."; + Description = "This AI assistant connects you to the Copilot in Azure and can generate Azure CLI and Azure PowerShell commands for managing Azure resources and answer questions about Azure."; SampleQueries = [ - "Create a VM with a public IP address", - "How to create a web app?", - "Backup an Azure SQL database to a storage container" + "How do I create a resource group?", + "Help me create a storage account" ]; LegalLinks = new(StringComparer.OrdinalIgnoreCase) { - ["Terms"] = "https://aka.ms/TermsofUseCopilot", + ["Terms"] = "https://aka.ms/AzureAgentTermsofUse", ["Privacy"] = "https://aka.ms/privacy", - ["FAQ"] = "https://aka.ms/CopilotforAzureClientToolsFAQ", - ["Transparency"] = "https://aka.ms/CopilotAzCLIPSTransparency", + ["FAQ"] = "https://aka.ms/AzureAgentFAQ", + ["Transparency"] = "https://aka.ms/AzureAgentTransparency", }; } diff --git a/shell/agents/Microsoft.Azure.Agent/ChatSession.cs b/shell/agents/Microsoft.Azure.Agent/ChatSession.cs index 2ed666b3..298b14ce 100644 --- a/shell/agents/Microsoft.Azure.Agent/ChatSession.cs +++ b/shell/agents/Microsoft.Azure.Agent/ChatSession.cs @@ -200,8 +200,7 @@ private async Task OpenConversationAsync(CancellationToken cancellationT { activity.ExtractMetadata(out _, out ConversationState conversationState); int chatNumber = conversationState.DailyConversationNumber; - int requestNumber = conversationState.TurnNumber; - return $"{activity.Text}\nThis is chat #{chatNumber}, request #{requestNumber}.\n"; + return $"{activity.Text} This is chat #{chatNumber}.\n\n\x1b[96mAI Generated content may be incorrect.\x1b[0m\n"; } } } diff --git a/shell/agents/Microsoft.Azure.Agent/README.md b/shell/agents/Microsoft.Azure.Agent/README.md new file mode 100644 index 00000000..80c87f56 --- /dev/null +++ b/shell/agents/Microsoft.Azure.Agent/README.md @@ -0,0 +1,5 @@ +# Copilot in Azure Agent + +For more details about this agent please see, [Copilot in Azure Agent][01]. + +[01]: https://learn.microsoft.com/powershell/utility-modules/aishell/how-to/agent-azure \ No newline at end of file