Skip to content

Commit

Permalink
update readme (#2)
Browse files Browse the repository at this point in the history
* update readme

* add badge

* Update Readme.md
  • Loading branch information
LittleLittleCloud committed Apr 26, 2024
1 parent 2c1a123 commit e8af34a
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 18 deletions.
30 changes: 24 additions & 6 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,32 @@
using Azure.AI.OpenAI;
using Powershell.GPT;

var AZURE_OPENAI_ENDPOINT = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? throw new ArgumentNullException("AZURE_OPENAI_ENDPOINT");
var AZURE_OPENAI_KEY = Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY") ?? throw new ArgumentNullException("AZURE_OPENAI_API_KEY");
var AZURE_OPENAI_ENDPOINT = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT");
var AZURE_OPENAI_KEY = Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY");
var AZURE_DEPLOYMENT_NAME = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOY_NAME");
var OPENAI_API_KEY = Environment.GetEnvironmentVariable("OPENAI_API_KEY");
var OPENAI_MODEL_ID = Environment.GetEnvironmentVariable("OPENAI_MODEL_ID") ?? "gpt-3.5-turbo-0125";

var client = new OpenAIClient(new Uri(AZURE_OPENAI_ENDPOINT), new Azure.AzureKeyCredential(AZURE_OPENAI_KEY));
OpenAIClient client;
bool useAzure = false;
if (AZURE_OPENAI_ENDPOINT is string && AZURE_OPENAI_KEY is string && AZURE_DEPLOYMENT_NAME is string)
{
client = new OpenAIClient(new Uri(AZURE_OPENAI_ENDPOINT), new Azure.AzureKeyCredential(AZURE_OPENAI_KEY));
useAzure = true;
}
else if (OPENAI_API_KEY is string)
{
client = new OpenAIClient(OPENAI_API_KEY);
}
else
{
throw new ArgumentException("Please provide either (AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_KEY, AZURE_DEPLOYMENT_NAME) or OPENAI_API_KEY");
}

var manager = AgentFactory.CreateManagerAgent(client);
var pwshDeveloper = AgentFactory.CreatePwshDeveloperAgent(client, Environment.CurrentDirectory);
var customerService = AgentFactory.CreateCustomerServiceAgent(client);
var deployModelName = useAzure ? AZURE_DEPLOYMENT_NAME! : OPENAI_MODEL_ID;
var manager = AgentFactory.CreateManagerAgent(client, modelName: deployModelName);
var pwshDeveloper = AgentFactory.CreatePwshDeveloperAgent(client, Environment.CurrentDirectory, modelName: deployModelName);
var customerService = AgentFactory.CreateCustomerServiceAgent(client, modelName: deployModelName);
var pwshRunner = AgentFactory.CreatePwshRunnerAgent();

var userAgent = new UserProxyAgent("user")
Expand Down
44 changes: 34 additions & 10 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,42 @@
## Powershell.GPT
## PS.GPT

A dotnet tool which uses multi-agent workflow to resolve tasks using powershell scripts.

To those who struggles with lengthy powershell command.

![NuGet Version](https://img.shields.io/nuget/v/PS.GPT) ![NuGet Downloads](https://img.shields.io/nuget/dt/PS.GPT)


### Get start
> [!Note]
> Before running the tool, you need to set up the following environment variables:
> - `OPENAI_API_KEY`: The key of the OpenAI service.
> - `OPENAI_MODEL_ID`: The model to use, if not set, it will use the `gpt-3.5-turbo-0125`.
>
> If you want to use Azure OpenAI service, you need to set up the following environment variables:
> - `AZURE_OPENAI_ENDPOINT`: The endpoint of the Azure OpenAI service.
> - `AZURE_OPENAI_KEY`: The key of the Azure OpenAI service.
> - `AZURE_OPENAI_DEPLOY_NAME`: The model of the Azure OpenAI service.
#### Install the tool
```bash
dotnet tool install -g PS.GPT
```
#### Run the tool using ps-gpt command
```bash
ps-gpt
```
#### Ask your question
```bash
list all files assending by size
```

### Examples
Below are some examples of the tasks that can be resolved using this workflow.

#### listing all files and its size, and sort by size in descending order.
![Example](asset/output.gif)

### Workflow overview
![Workflow](asset/image.png)

Expand All @@ -18,12 +51,3 @@ To those who struggles with lengthy powershell command.
The workflow can be easily extended to support the following scenarios:
- approve script before execution: Asking user for approval before executing the script.
- support more bash languages: Adding more engineers!

### Examples
Below are some examples of the tasks that can be resolved using this workflow.

#### listing all files and its size, and sort by size in descending order.
![Example](asset/output.gif)

#### switch to light theme

2 changes: 1 addition & 1 deletion eng/MetaInfo.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VersionPrefix>0.0.1</VersionPrefix>
<VersionPrefix>0.0.2</VersionPrefix>
<Authors>LittleLittleCloud</Authors>
<PackageProjectUrl>https://github.com/LittleLittleCloud/PowershellGPT</PackageProjectUrl>
<RepositoryUrl>https://github.com/LittleLittleCloud/PowershellGPT</RepositoryUrl>
Expand Down
2 changes: 1 addition & 1 deletion nuget/nuget-package.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Authors>LittleLittleCloud</Authors>
<Product>PowershellGPT</Product>
<Description>A GPT that resolves tasks using powershell</Description>
<PackageTags>AI, Artificial Intelligence, SDK</PackageTags>
<PackageTags>AI, Artificial Intelligence, SDK, Powershell, GPT</PackageTags>
<PackageId>$(AssemblyName)</PackageId>

<!-- Required license, copyright, and repo information. Packages can override. -->
Expand Down

0 comments on commit e8af34a

Please sign in to comment.