mirror of
https://github.com/microsoft/autogen.git
synced 2026-04-20 03:02:16 -04:00
Update docs (#11)
* docs update WIP * getting started guide updated * update getting started guide * clarify github app creation * add webhook secret to getting started guide and gh-flow app * restructure Readme * fix the Organization assumption * add mermaid diagram of the event flow * devtunnel feature to devcontainer * throw all the exceptions and add the history to the prompt * Update github-flow.md * update readme
This commit is contained in:
@@ -91,7 +91,8 @@ var app = builder.Build();
|
||||
app.UseRouting()
|
||||
.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapGitHubWebhooks();
|
||||
var ghOptions = app.Services.GetService<IOptions<GithubOptions>>().Value;
|
||||
endpoints.MapGitHubWebhooks(secret: ghOptions.WebhookSecret );
|
||||
});
|
||||
|
||||
app.Map("/dashboard", x => x.UseOrleansDashboard());
|
||||
|
||||
@@ -27,7 +27,7 @@ public sealed class GithubWebHookProcessor : WebhookEventProcessor
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Processing issue event");
|
||||
var org = issuesEvent.Organization.Login;
|
||||
var org = issuesEvent.Repository.Owner.Login;
|
||||
var repo = issuesEvent.Repository.Name;
|
||||
var issueNumber = issuesEvent.Issue.Number;
|
||||
var input = issuesEvent.Issue.Body;
|
||||
@@ -52,9 +52,10 @@ public sealed class GithubWebHookProcessor : WebhookEventProcessor
|
||||
await HandleClosingIssue(issueNumber, parentNumber,skillName, labels[skillName], suffix, org, repo);
|
||||
}
|
||||
}
|
||||
catch (System.Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError("Processing issue event");
|
||||
_logger.LogError(ex, "Processing issue event");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,10 +67,10 @@ public sealed class GithubWebHookProcessor : WebhookEventProcessor
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Processing issue comment event");
|
||||
var org = issueCommentEvent.Organization.Login;
|
||||
var org = issueCommentEvent.Repository.Owner.Login;
|
||||
var repo = issueCommentEvent.Repository.Name;
|
||||
var issueNumber = issueCommentEvent.Issue.Number;
|
||||
var input = issueCommentEvent.Issue.Body;
|
||||
var input = issueCommentEvent.Comment.Body;
|
||||
// Assumes the label follows the following convention: Skill.Function example: PM.Readme
|
||||
var labels = issueCommentEvent.Issue.Labels
|
||||
.Select(l => l.Name.Split('.'))
|
||||
@@ -84,9 +85,10 @@ public sealed class GithubWebHookProcessor : WebhookEventProcessor
|
||||
await HandleNewAsk(issueNumber, parentNumber, skillName, labels[skillName], suffix, input, org, repo);
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError("Processing issue comment event");
|
||||
_logger.LogError(ex, "Processing issue comment event");
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -149,9 +151,10 @@ public sealed class GithubWebHookProcessor : WebhookEventProcessor
|
||||
Data = data
|
||||
});
|
||||
}
|
||||
catch (System.Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError("Handling new ask");
|
||||
_logger.LogError(ex, "Handling new ask");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
"Microsoft.AspNetCore": "Information",
|
||||
"Orleans.Streams": "Information"
|
||||
}
|
||||
},
|
||||
"ApplicationInsights": {
|
||||
@@ -13,7 +14,8 @@
|
||||
"GithubOptions" : {
|
||||
"AppKey": "",
|
||||
"AppId": "",
|
||||
"InstallationId": ""
|
||||
"InstallationId": "",
|
||||
"WebhookSecret": ""
|
||||
},
|
||||
"AzureOptions" : {
|
||||
"SubscriptionId":"",
|
||||
@@ -22,15 +24,14 @@
|
||||
"FilesShareName":"",
|
||||
"FilesAccountName":"",
|
||||
"FilesAccountKey":"",
|
||||
"CosmosConnectionString":"",
|
||||
"SandboxImage" : "mcr.microsoft.com/dotnet/sdk:7.0",
|
||||
"ManagedIdentity": ""
|
||||
},
|
||||
"OpenAIOptions" : {
|
||||
"ServiceType":"AzureOpenAI",
|
||||
"ServiceId":"",
|
||||
"DeploymentOrModelId":"",
|
||||
"EmbeddingDeploymentOrModelId":"",
|
||||
"ServiceId":"gpt-4",
|
||||
"DeploymentOrModelId":"gpt-4",
|
||||
"EmbeddingDeploymentOrModelId":"text-embedding-ada-002",
|
||||
"Endpoint":"",
|
||||
"ApiKey":""
|
||||
},
|
||||
45
src/apps/gh-flow/appsettings.local.template.json
Normal file
45
src/apps/gh-flow/appsettings.local.template.json
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Information",
|
||||
"Orleans.Streams": "Information"
|
||||
}
|
||||
},
|
||||
"ApplicationInsights": {
|
||||
"ConnectionString": ""
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"SANDBOX_IMAGE" : "mcr.microsoft.com/dotnet/sdk:7.0",
|
||||
"GithubOptions" : {
|
||||
"AppKey": "",
|
||||
"AppId": "",
|
||||
"InstallationId": "",
|
||||
"WebhookSecret": ""
|
||||
},
|
||||
"AzureOptions" : {
|
||||
"SubscriptionId":"",
|
||||
"Location":"",
|
||||
"ContainerInstancesResourceGroup":"",
|
||||
"FilesShareName":"",
|
||||
"FilesAccountName":"",
|
||||
"FilesAccountKey":"",
|
||||
"SandboxImage" : "mcr.microsoft.com/dotnet/sdk:7.0",
|
||||
"ManagedIdentity": ""
|
||||
},
|
||||
"OpenAIOptions" : {
|
||||
"ServiceType":"AzureOpenAI",
|
||||
"ServiceId":"gpt-4",
|
||||
"DeploymentOrModelId":"gpt-4",
|
||||
"EmbeddingDeploymentOrModelId":"text-embedding-ada-002",
|
||||
"Endpoint":"",
|
||||
"ApiKey":""
|
||||
},
|
||||
"QdrantOptions" : {
|
||||
"Endpoint" : "http://qdrant:6333",
|
||||
"VectorSize" : "1536"
|
||||
},
|
||||
"ServiceOptions" : {
|
||||
"IngesterUrl" : "http://localhost:7071"
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ public static class DevLead {
|
||||
]
|
||||
}
|
||||
Do not output any other text.
|
||||
Do not wrap the JSON in any other text, output the JSON format described above.
|
||||
Input: {{$input}}
|
||||
{{$wafContext}}
|
||||
""";
|
||||
|
||||
@@ -39,12 +39,19 @@ public abstract class AiAgent : Agent
|
||||
});
|
||||
}
|
||||
|
||||
protected string GetChatHistory()
|
||||
{
|
||||
return string.Join("\n",_state.State.History.Select(message=> $"{message.UserType}: {message.Message}"));
|
||||
}
|
||||
|
||||
protected async Task<string> CallFunction(string template, string ask, IKernel kernel, ISemanticTextMemory memory)
|
||||
{
|
||||
var function = kernel.CreateSemanticFunction(template, new OpenAIRequestSettings { MaxTokens = 15000, Temperature = 0.8, TopP = 1 });
|
||||
var context = await CreateWafContext(memory, ask);
|
||||
var result = (await kernel.RunAsync(context, function)).ToString();
|
||||
AddToHistory(ask, ChatUserType.User);
|
||||
var history = GetChatHistory();
|
||||
var context = await CreateWafContext(memory, history);
|
||||
var result = (await kernel.RunAsync(context, function)).ToString();
|
||||
|
||||
AddToHistory(result, ChatUserType.Agent);
|
||||
await _state.WriteStateAsync();
|
||||
return result;
|
||||
|
||||
@@ -3,4 +3,5 @@ public class GithubOptions
|
||||
public string AppKey { get; set; }
|
||||
public int AppId { get; set; }
|
||||
public long InstallationId { get; set; }
|
||||
}
|
||||
public string WebhookSecret { get; set; }
|
||||
}
|
||||
@@ -40,6 +40,7 @@ public class AzureService : IManageAzure
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error deleting sandbox");
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -59,7 +60,7 @@ public class AzureService : IManageAzure
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error checking sandbox status");
|
||||
return false;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,6 +106,7 @@ public class AzureService : IManageAzure
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error running sandbox");
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -146,6 +148,7 @@ public class AzureService : IManageAzure
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error storing output");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class GithubAuthService
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error getting GitHub client");
|
||||
return default;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,7 @@ public class GithubService : IManageGithub
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error committing to branch");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +86,7 @@ public class GithubService : IManageGithub
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error creating branch");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +101,7 @@ public class GithubService : IManageGithub
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error getting main language");
|
||||
return default;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +121,7 @@ public class GithubService : IManageGithub
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error creating issue");
|
||||
return default;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +135,7 @@ public class GithubService : IManageGithub
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error creating PR");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,6 +150,7 @@ public class GithubService : IManageGithub
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error marking task complete");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,6 +163,7 @@ public class GithubService : IManageGithub
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error posting comment");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +177,7 @@ public class GithubService : IManageGithub
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error getting files");
|
||||
return Enumerable.Empty<FileResponse>();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,7 +208,7 @@ public class GithubService : IManageGithub
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error collecting files");
|
||||
return Enumerable.Empty<FileResponse>();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user