Skip to content

Commit

Permalink
Merge branch 'main' into ags_v1_vd
Browse files Browse the repository at this point in the history
  • Loading branch information
victordibia authored Nov 8, 2024
2 parents b55f161 + 621b17e commit 514aabb
Show file tree
Hide file tree
Showing 73 changed files with 2,581 additions and 720 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,9 @@ jobs:
source ${{ github.workspace }}/python/.venv/bin/activate
poe gen-proto
working-directory: ./python
- name: Evaluate if there are changes
run: |
if [[ `git status --porcelain` ]]; then
echo "There are changes that need to be generated and commit for the proto files"
git --no-pager diff
exit 1
fi
shell: bash
- name: Check if there are uncommited changes
id: changes
uses: UnicornGlobal/has-changes-action@v1.0.11
- name: Process changes
if: steps.changes.outputs.changed == 1
run: echo "There are changes in the proto files. Please commit them."
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
{ ref: "v0.4.0.dev1", dest-dir: "0.4.0.dev1" },
{ ref: "v0.4.0.dev2", dest-dir: "0.4.0.dev2" },
{ ref: "v0.4.0.dev3", dest-dir: "0.4.0.dev3" },
{ ref: "v0.4.0.dev4", dest-dir: "0.4.0.dev4" },
]
steps:
- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ We look forward to your contributions!
First install the packages:

```bash
pip install 'autogen-agentchat==0.4.0.dev3' 'autogen-ext[docker]==0.4.0.dev3'
pip install 'autogen-agentchat==0.4.0.dev4' 'autogen-ext[docker]==0.4.0.dev4'
```

The following code uses code execution, you need to have [Docker installed](https://docs.docker.com/engine/install/)
Expand All @@ -124,7 +124,7 @@ async def main() -> None:
termination = TextMentionTermination("TERMINATE")
group_chat = RoundRobinGroupChat([coding_assistant_agent, code_executor_agent], termination_condition=termination)
stream = group_chat.run_stream(
"Create a plot of NVDIA and TSLA stock returns YTD from 2024-01-01 and save it to 'nvidia_tesla_2024_ytd.png'."
task="Create a plot of NVDIA and TSLA stock returns YTD from 2024-01-01 and save it to 'nvidia_tesla_2024_ytd.png'."
)
async for message in stream:
print(message)
Expand Down
9 changes: 7 additions & 2 deletions docs/switcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
{
"name": "0.4.0.dev3",
"version": "0.4.0.dev3",
"url": "/autogen/0.4.0.dev3/",
"url": "/autogen/0.4.0.dev3/"
},
{
"name": "0.4.0.dev4",
"version": "0.4.0.dev4",
"url": "/autogen/0.4.0.dev4/",
"preferred": true
}
]
]
7 changes: 0 additions & 7 deletions dotnet/AutoGen.sln
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AutoGen.Abstracti
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AutoGen.Extensions.SemanticKernel", "src\Microsoft.AutoGen\Extensions\SemanticKernel\Microsoft.AutoGen.Extensions.SemanticKernel.csproj", "{952827D4-8D4C-4327-AE4D-E8D25811EF35}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AutoGen.Extensions.CloudEvents", "src\Microsoft.AutoGen\Extensions\CloudEvents\Microsoft.AutoGen.Extensions.CloudEvents.csproj", "{21C9EC49-E848-4EAE-932F-0862D44F7A80}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AutoGen.Runtime", "src\Microsoft.AutoGen\Runtime\Microsoft.AutoGen.Runtime.csproj", "{A905E29A-7110-497F-ADC5-2CE2A148FEA0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AutoGen.ServiceDefaults", "src\Microsoft.AutoGen\ServiceDefaults\Microsoft.AutoGen.ServiceDefaults.csproj", "{D7E9D90B-5595-4E72-A90A-6DE20D9AB7AE}"
Expand Down Expand Up @@ -266,10 +264,6 @@ Global
{952827D4-8D4C-4327-AE4D-E8D25811EF35}.Debug|Any CPU.Build.0 = Debug|Any CPU
{952827D4-8D4C-4327-AE4D-E8D25811EF35}.Release|Any CPU.ActiveCfg = Release|Any CPU
{952827D4-8D4C-4327-AE4D-E8D25811EF35}.Release|Any CPU.Build.0 = Release|Any CPU
{21C9EC49-E848-4EAE-932F-0862D44F7A80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21C9EC49-E848-4EAE-932F-0862D44F7A80}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21C9EC49-E848-4EAE-932F-0862D44F7A80}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21C9EC49-E848-4EAE-932F-0862D44F7A80}.Release|Any CPU.Build.0 = Release|Any CPU
{A905E29A-7110-497F-ADC5-2CE2A148FEA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A905E29A-7110-497F-ADC5-2CE2A148FEA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A905E29A-7110-497F-ADC5-2CE2A148FEA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -391,7 +385,6 @@ Global
{FD87BD33-4616-460B-AC85-A412BA08BB78} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}
{E0C991D9-0DB8-471C-ADC9-5FB16E2A0106} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}
{952827D4-8D4C-4327-AE4D-E8D25811EF35} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}
{21C9EC49-E848-4EAE-932F-0862D44F7A80} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}
{A905E29A-7110-497F-ADC5-2CE2A148FEA0} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}
{D7E9D90B-5595-4E72-A90A-6DE20D9AB7AE} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}
{668726B9-77BC-45CF-B576-0F0773BF1615} = {686480D7-8FEC-4ED3-9C5D-CEBE1057A7ED}
Expand Down
2 changes: 2 additions & 0 deletions dotnet/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<MicrosoftSemanticKernelVersion>1.22.0</MicrosoftSemanticKernelVersion>
<MicrosoftSemanticKernelExperimentalVersion>1.22.0-alpha</MicrosoftSemanticKernelExperimentalVersion>
<MicrosoftExtensionsAIVersion>9.0.0-preview.9.24525.1</MicrosoftExtensionsAIVersion>

<NuGetAuditMode>direct</NuGetAuditMode>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Aspire.Hosting" Version="9.0.0-rc.1.24511.1" />
Expand Down
16 changes: 5 additions & 11 deletions dotnet/samples/Hello/HelloAIAgents/HelloAIAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,10 @@ public class HelloAIAgent(
{
var prompt = "Please write a limerick greeting someone with the name " + item.Message;
var response = await client.CompleteAsync(prompt);
var evt = new Output
{
Message = response.Message.Text
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(evt).ConfigureAwait(false);
var goodbye = new ConversationClosed
{
UserId = this.AgentId.Key,
UserMessage = "Goodbye"
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(goodbye).ConfigureAwait(false);
var evt = new Output { Message = response.Message.Text };
await PublishMessageAsync(evt).ConfigureAwait(false);

var goodbye = new ConversationClosed { UserId = this.AgentId.Key, UserMessage = "Goodbye" };
await PublishMessageAsync(goodbye).ConfigureAwait(false);
}
}
12 changes: 6 additions & 6 deletions dotnet/samples/Hello/HelloAIAgents/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,23 @@ public async Task Handle(NewMessageReceived item)
var evt = new Output
{
Message = response
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(evt).ConfigureAwait(false);
};
await PublishMessageAsync(evt).ConfigureAwait(false);
var goodbye = new ConversationClosed
{
UserId = this.AgentId.Key,
UserMessage = "Goodbye"
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(goodbye).ConfigureAwait(false);
};
await PublishMessageAsync(goodbye).ConfigureAwait(false);
}
public async Task Handle(ConversationClosed item)
{
var goodbye = $"********************* {item.UserId} said {item.UserMessage} ************************";
var evt = new Output
{
Message = goodbye
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(evt).ConfigureAwait(false);
};
await PublishMessageAsync(evt).ConfigureAwait(false);
//sleep30 seconds
await Task.Delay(30000).ConfigureAwait(false);
await AgentsApp.ShutdownAsync().ConfigureAwait(false);
Expand Down
15 changes: 6 additions & 9 deletions dotnet/samples/Hello/HelloAgent/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,23 @@ public class HelloAgent(
public async Task Handle(NewMessageReceived item)
{
var response = await SayHello(item.Message).ConfigureAwait(false);
var evt = new Output
{
Message = response
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(evt).ConfigureAwait(false);
var evt = new Output { Message = response };
await PublishMessageAsync(evt).ConfigureAwait(false);
var goodbye = new ConversationClosed
{
UserId = this.AgentId.Key,
UserMessage = "Goodbye"
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(goodbye).ConfigureAwait(false);
};
await PublishMessageAsync(goodbye).ConfigureAwait(false);
}
public async Task Handle(ConversationClosed item)
{
var goodbye = $"********************* {item.UserId} said {item.UserMessage} ************************";
var evt = new Output
{
Message = goodbye
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(evt).ConfigureAwait(false);
};
await PublishMessageAsync(evt).ConfigureAwait(false);

// Signal shutdown.
hostApplicationLifetime.StopApplication();
Expand Down
12 changes: 6 additions & 6 deletions dotnet/samples/Hello/HelloAgentState/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ public async Task Handle(NewMessageReceived item)
var evt = new Output
{
Message = response
}.ToCloudEvent(this.AgentId.Key);
};
var entry = "We said hello to " + item.Message;
await Store(new AgentState
{
AgentId = this.AgentId,
TextData = entry
}).ConfigureAwait(false);
await PublishEvent(evt).ConfigureAwait(false);
await PublishMessageAsync(evt).ConfigureAwait(false);
var goodbye = new ConversationClosed
{
UserId = this.AgentId.Key,
UserMessage = "Goodbye"
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(goodbye).ConfigureAwait(false);
};
await PublishMessageAsync(goodbye).ConfigureAwait(false);
}
public async Task Handle(ConversationClosed item)
{
Expand All @@ -54,8 +54,8 @@ public async Task Handle(ConversationClosed item)
var evt = new Output
{
Message = goodbye
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(evt).ConfigureAwait(false);
};
await PublishMessageAsync(evt).ConfigureAwait(false);
//sleep
await Task.Delay(10000).ConfigureAwait(false);
await AgentsApp.ShutdownAsync().ConfigureAwait(false);
Expand Down
8 changes: 4 additions & 4 deletions dotnet/samples/dev-team/DevTeam.Agents/Developer/Developer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public async Task Handle(CodeGenerationRequested item)
Repo = item.Repo,
IssueNumber = item.IssueNumber,
Code = code
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(evt);
};
await PublishMessageAsync(evt);
}

public async Task Handle(CodeChainClosed item)
Expand All @@ -35,8 +35,8 @@ public async Task Handle(CodeChainClosed item)
var evt = new CodeCreated
{
Code = lastCode
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(evt);
};
await PublishMessageAsync(evt);
}

public async Task<string> GenerateCode(string ask)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public async Task Handle(DevPlanRequested item)
Repo = item.Repo,
IssueNumber = item.IssueNumber,
Plan = plan
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(evt);
};
await PublishMessageAsync(evt);
}

public async Task Handle(DevPlanChainClosed item)
Expand All @@ -36,8 +36,8 @@ public async Task Handle(DevPlanChainClosed item)
var evt = new DevPlanCreated
{
Plan = lastPlan
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(evt);
};
await PublishMessageAsync(evt);
}
public async Task<string> CreatePlan(string ask)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public async Task Handle(ReadmeChainClosed item)
var evt = new ReadmeCreated
{
Readme = lastReadme
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(evt);
};
await PublishMessageAsync(evt);
}

public async Task Handle(ReadmeRequested item)
Expand All @@ -35,8 +35,8 @@ public async Task Handle(ReadmeRequested item)
Org = item.Org,
Repo = item.Repo,
IssueNumber = item.IssueNumber
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(evt);
};
await PublishMessageAsync(evt);
}

public async Task<string> CreateReadme(string ask)
Expand Down
4 changes: 2 additions & 2 deletions dotnet/samples/dev-team/DevTeam.Backend/Agents/AzureGenie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public async Task Handle(ReadmeCreated item)
// TODO: Not sure we need to store the files if we use ACA Sessions
// //var data = item.ToData();
// // await Store(data["org"], data["repo"], data.TryParseLong("parentNumber"), data.TryParseLong("issueNumber"), "readme", "md", "output", data["readme"]);
// await PublishEvent(new Event
// await PublishEventAsync(new Event
// {
// Namespace = item.Namespace,
// Type = nameof(EventTypes.ReadmeStored),
Expand All @@ -36,7 +36,7 @@ public async Task Handle(CodeCreated item)
// //var data = item.ToData();
// // await Store(data["org"], data["repo"], data.TryParseLong("parentNumber"), data.TryParseLong("issueNumber"), "run", "sh", "output", data["code"]);
// // await RunInSandbox(data["org"], data["repo"], data.TryParseLong("parentNumber"), data.TryParseLong("issueNumber"));
// await PublishEvent(new Event
// await PublishEventAsync(new Event
// {
// Namespace = item.Namespace,
// Type = nameof(EventTypes.SandboxRunCreated),
Expand Down
2 changes: 1 addition & 1 deletion dotnet/samples/dev-team/DevTeam.Backend/Agents/Sandbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
// if (await _azService.IsSandboxCompleted(sandboxId))
// {
// await _azService.DeleteSandbox(sandboxId);
// await PublishEvent(new Event
// await PublishEventAsync(new Event
// {
// Namespace = this.GetPrimaryKeyString(),
// Type = nameof(GithubFlowEventType.SandboxRunFinished),
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/Microsoft.AutoGen/Abstractions/IAgentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ public interface IAgentBase
void ReceiveMessage(Message message);
Task Store(AgentState state);
Task<T> Read<T>(AgentId agentId) where T : IMessage, new();
ValueTask PublishEvent(CloudEvent item);
ValueTask PublishEventAsync(CloudEvent item, CancellationToken token = default);
}
11 changes: 9 additions & 2 deletions dotnet/src/Microsoft.AutoGen/Agents/AgentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,16 @@ static async ((AgentBase Agent, RpcRequest Request, TaskCompletionSource<RpcResp
return await completion.Task.ConfigureAwait(false);
}

public async ValueTask PublishEvent(CloudEvent item)
public async ValueTask PublishMessageAsync<T>(T message, string? source = null, CancellationToken token = default) where T : IMessage
{
var activity = s_source.StartActivity($"PublishEvent '{item.Type}'", ActivityKind.Client, Activity.Current?.Context ?? default);
var src = string.IsNullOrWhiteSpace(source) ? this.AgentId.Key : source;
var evt = message.ToCloudEvent(src);
await PublishEventAsync(evt, token).ConfigureAwait(false);
}

public async ValueTask PublishEventAsync(CloudEvent item, CancellationToken token = default)
{
var activity = s_source.StartActivity($"PublishEventAsync '{item.Type}'", ActivityKind.Client, Activity.Current?.Context ?? default);
activity?.SetTag("peer.service", $"{item.Type}/{item.Source}");

// TODO: fix activity
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/Microsoft.AutoGen/Agents/AgentWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public sealed class AgentWorker(IAgentWorkerRuntime runtime, DistributedContextP
[FromKeyedServices("EventTypes")] EventTypes eventTypes, ILogger<AgentBase> logger)
: AgentBase(new AgentContext(new AgentId("client", Guid.NewGuid().ToString()), runtime, logger, distributedContextPropagator), eventTypes)
{
public async ValueTask PublishEventAsync(CloudEvent evt) => await PublishEvent(evt);
public async ValueTask PublishEventAsync(CloudEvent evt) => await base.PublishEventAsync(evt);

public async ValueTask PublishEventAsync(string topic, IMessage evt)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public override async Task Handle(Input item)
var evt = new InputProcessed
{
Route = _route
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(evt);
};
await PublishMessageAsync(evt);
}

public override async Task Handle(Output item)
Expand All @@ -40,8 +40,8 @@ public override async Task Handle(Output item)
var evt = new OutputWritten
{
Route = _route
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(evt);
};
await PublishMessageAsync(evt);
}

public override Task<string> ProcessInput(string message)
Expand Down
Loading

0 comments on commit 514aabb

Please sign in to comment.