mirror of https://github.com/microsoft/autogen.git
Compare commits
53 Commits
d64631cc55
...
f3499e212a
Author | SHA1 | Date |
---|---|---|
Kosta Petan | f3499e212a | |
afourney | 51b361dfcf | |
afourney | e111db9afa | |
Mohammad Mazraeh | 570471bed7 | |
Gerardo Moreno | 3b8d0ddb67 | |
peterychang | 0afde6da69 | |
Eric Zhu | e27c740961 | |
Eric Zhu | 4786f189bc | |
Eric Zhu | 9f175089c5 | |
Eric Zhu | 5547a6716e | |
Eric Zhu | 1cc0f4f7c5 | |
Eric Zhu | 8f7c717149 | |
Eric Zhu | 12becdddb1 | |
Victor Dibia | 0e985d4b40 | |
Eric Zhu | f40b0c2730 | |
Eric Zhu | 3f28aa8874 | |
Eric Zhu | 111e69142b | |
Diego Colombo | 621b17ebbe | |
Eric Zhu | 5fa38b0166 | |
Eric Zhu | 9e388925d4 | |
Eric Zhu | 2e3155be2a | |
Mark Sze | 930e61306a | |
Mahesh Subramanian | 2382ff9248 | |
Eric Zhu | 4be1c9cf76 | |
Eric Zhu | 5be7ac7b12 | |
David Luong | 378b307623 | |
Eric Zhu | c3283c64a3 | |
Kosta Petan | 39d79b0064 | |
Hussein Mozannar | 10987685b9 | |
Hussein Mozannar | 8603317537 | |
Gerardo Moreno | eca8a95c61 | |
Reuben Bond | f40336fda1 | |
Eric Zhu | 16e64c4c10 | |
David Luong | f46e52e6ff | |
Xiaoyun Zhang | 5e0b677acc | |
Eric Zhu | 4e5f3ababe | |
Eric Zhu | 4fec22ddc5 | |
Reuben Bond | 7d1857dae6 | |
Eric Zhu | 27ea99a485 | |
Eric Zhu | ca7caa779d | |
Reuben Bond | e9c16fe22e | |
Reuben Bond | a4901f3ba8 | |
Eric Zhu | c3b2597e12 | |
Eric Zhu | 173acc6638 | |
Eric Zhu | 369ffb511b | |
Eric Zhu | cff7d842a6 | |
Mohammad Mazraeh | 4023454c58 | |
Rohan Thacker | 3c63f6f3ef | |
Xiaoyun Zhang | 6bea055b26 | |
Eric Zhu | 3d51ab76ae | |
Xiaoyun Zhang | e63fd17ed5 | |
Ryan Sweet | 51cd5b8d1f | |
Kosta Petan | 32dec074ef |
|
@ -33,10 +33,8 @@
|
|||
*.tsx text
|
||||
*.xml text
|
||||
*.xhtml text diff=html
|
||||
|
||||
# Docker
|
||||
Dockerfile text eol=lf
|
||||
|
||||
# Documentation
|
||||
*.ipynb text
|
||||
*.markdown text diff=markdown eol=lf
|
||||
|
@ -62,7 +60,6 @@ NEWS text eol=lf
|
|||
readme text eol=lf
|
||||
*README* text eol=lf
|
||||
TODO text
|
||||
|
||||
# Configs
|
||||
*.cnf text eol=lf
|
||||
*.conf text eol=lf
|
||||
|
@ -84,8 +81,9 @@ yarn.lock text -diff
|
|||
browserslist text
|
||||
Makefile text eol=lf
|
||||
makefile text eol=lf
|
||||
|
||||
# Images
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.jpg filter=lfs diff=lfs merge=lfs -text
|
||||
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
||||
python/packages/autogen-magentic-one/imgs/autogen-magentic-one-example.png filter=lfs diff=lfs merge=lfs -text
|
||||
python/packages/autogen-magentic-one/imgs/autogen-magentic-one-agents.png filter=lfs diff=lfs merge=lfs -text
|
||||
|
|
|
@ -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."
|
||||
|
|
|
@ -35,6 +35,10 @@ jobs:
|
|||
{ ref: "v0.4.0.dev0", dest-dir: "0.4.0.dev0" },
|
||||
{ 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" },
|
||||
{ ref: "v0.4.0.dev5", dest-dir: "0.4.0.dev5" },
|
||||
{ ref: "v0.4.0.dev6", dest-dir: "0.4.0.dev6" },
|
||||
]
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
|
52
README.md
52
README.md
|
@ -101,37 +101,45 @@ We look forward to your contributions!
|
|||
First install the packages:
|
||||
|
||||
```bash
|
||||
pip install autogen-agentchat==0.4.0.dev2 autogen-ext==0.4.0.dev2
|
||||
pip install 'autogen-agentchat==0.4.0.dev6' 'autogen-ext[openai]==0.4.0.dev6'
|
||||
```
|
||||
|
||||
The following code uses code execution, you need to have [Docker installed](https://docs.docker.com/engine/install/)
|
||||
and running on your machine.
|
||||
The following code uses OpenAI's GPT-4o model and you need to provide your
|
||||
API key to run.
|
||||
To use Azure OpenAI models, follow the instruction
|
||||
[here](https://microsoft.github.io/autogen/dev/user-guide/core-user-guide/cookbook/azure-openai-with-aad-auth.html).
|
||||
|
||||
```python
|
||||
import asyncio
|
||||
import logging
|
||||
from autogen_agentchat import EVENT_LOGGER_NAME
|
||||
from autogen_agentchat.agents import CodeExecutorAgent, CodingAssistantAgent
|
||||
from autogen_agentchat.logging import ConsoleLogHandler
|
||||
from autogen_agentchat.teams import RoundRobinGroupChat, StopMessageTermination
|
||||
from autogen_ext.code_executor.docker_executor import DockerCommandLineCodeExecutor
|
||||
from autogen_agentchat.agents import AssistantAgent
|
||||
from autogen_agentchat.task import Console, TextMentionTermination
|
||||
from autogen_agentchat.teams import RoundRobinGroupChat
|
||||
from autogen_ext.models import OpenAIChatCompletionClient
|
||||
|
||||
logger = logging.getLogger(EVENT_LOGGER_NAME)
|
||||
logger.addHandler(ConsoleLogHandler())
|
||||
logger.setLevel(logging.INFO)
|
||||
# Define a tool
|
||||
async def get_weather(city: str) -> str:
|
||||
return f"The weather in {city} is 73 degrees and Sunny."
|
||||
|
||||
async def main() -> None:
|
||||
async with DockerCommandLineCodeExecutor(work_dir="coding") as code_executor:
|
||||
code_executor_agent = CodeExecutorAgent("code_executor", code_executor=code_executor)
|
||||
coding_assistant_agent = CodingAssistantAgent(
|
||||
"coding_assistant", model_client=OpenAIChatCompletionClient(model="gpt-4o", api_key="YOUR_API_KEY")
|
||||
)
|
||||
group_chat = RoundRobinGroupChat([coding_assistant_agent, code_executor_agent])
|
||||
result = await group_chat.run(
|
||||
task="Create a plot of NVDIA and TSLA stock returns YTD from 2024-01-01 and save it to 'nvidia_tesla_2024_ytd.png'.",
|
||||
termination_condition=StopMessageTermination(),
|
||||
)
|
||||
# Define an agent
|
||||
weather_agent = AssistantAgent(
|
||||
name="weather_agent",
|
||||
model_client=OpenAIChatCompletionClient(
|
||||
model="gpt-4o-2024-08-06",
|
||||
# api_key="YOUR_API_KEY",
|
||||
),
|
||||
tools=[get_weather],
|
||||
)
|
||||
|
||||
# Define termination condition
|
||||
termination = TextMentionTermination("TERMINATE")
|
||||
|
||||
# Define a team
|
||||
agent_team = RoundRobinGroupChat([weather_agent], termination_condition=termination)
|
||||
|
||||
# Run the team and stream messages to the console
|
||||
stream = agent_team.run_stream(task="What is the weather in New York?")
|
||||
await Console(stream)
|
||||
|
||||
asyncio.run(main())
|
||||
```
|
||||
|
|
|
@ -21,7 +21,27 @@
|
|||
{
|
||||
"name": "0.4.0.dev2",
|
||||
"version": "0.4.0.dev2",
|
||||
"url": "/autogen/0.4.0.dev2/",
|
||||
"url": "/autogen/0.4.0.dev2/"
|
||||
},
|
||||
{
|
||||
"name": "0.4.0.dev3",
|
||||
"version": "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/"
|
||||
},
|
||||
{
|
||||
"name": "0.4.0.dev5",
|
||||
"version": "0.4.0.dev5",
|
||||
"url": "/autogen/0.4.0.dev5/"
|
||||
},
|
||||
{
|
||||
"name": "0.4.0.dev6",
|
||||
"version": "0.4.0.dev6",
|
||||
"url": "/autogen/0.4.0.dev6/",
|
||||
"preferred": true
|
||||
}
|
||||
]
|
||||
|
|
|
@ -193,10 +193,6 @@ csharp_using_directive_placement = outside_namespace:error
|
|||
csharp_prefer_static_local_function = true:warning
|
||||
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning
|
||||
|
||||
# Header template
|
||||
file_header_template = Copyright (c) Microsoft Corporation. All rights reserved.\n{fileName}
|
||||
dotnet_diagnostic.IDE0073.severity = error
|
||||
|
||||
# enable format error
|
||||
dotnet_diagnostic.IDE0055.severity = error
|
||||
|
||||
|
@ -221,13 +217,14 @@ dotnet_diagnostic.IDE0161.severity = warning # Use file-scoped namespace
|
|||
|
||||
csharp_style_var_elsewhere = true:suggestion # Prefer 'var' everywhere
|
||||
csharp_prefer_simple_using_statement = true:suggestion
|
||||
csharp_style_namespace_declarations = block_scoped:silent
|
||||
csharp_style_namespace_declarations = file_scoped:warning
|
||||
csharp_style_prefer_method_group_conversion = true:silent
|
||||
csharp_style_prefer_top_level_statements = true:silent
|
||||
csharp_style_prefer_primary_constructors = true:suggestion
|
||||
csharp_style_expression_bodied_lambdas = true:silent
|
||||
csharp_style_prefer_local_over_anonymous_function = true:suggestion
|
||||
dotnet_diagnostic.CA2016.severity = suggestion
|
||||
csharp_prefer_static_anonymous_function = true:suggestion
|
||||
|
||||
# disable check for generated code
|
||||
[*.generated.cs]
|
||||
|
@ -556,8 +553,8 @@ dotnet_diagnostic.IDE0060.severity = warning
|
|||
dotnet_diagnostic.IDE0062.severity = warning
|
||||
|
||||
# IDE0073: File header
|
||||
dotnet_diagnostic.IDE0073.severity = suggestion
|
||||
file_header_template = Copyright (c) Microsoft. All rights reserved.
|
||||
dotnet_diagnostic.IDE0073.severity = warning
|
||||
file_header_template = Copyright (c) Microsoft Corporation. All rights reserved.\n{fileName}
|
||||
|
||||
# IDE1006: Required naming style
|
||||
dotnet_diagnostic.IDE1006.severity = warning
|
||||
|
@ -697,6 +694,7 @@ dotnet_style_prefer_compound_assignment = true:suggestion
|
|||
dotnet_style_prefer_simplified_interpolation = true:suggestion
|
||||
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
|
||||
dotnet_style_namespace_match_folder = true:suggestion
|
||||
dotnet_style_qualification_for_method = false:silent
|
||||
|
||||
[**/*.g.cs]
|
||||
generated_code = true
|
||||
|
|
|
@ -37,9 +37,6 @@ bld/
|
|||
# vs code cache
|
||||
.vscode/
|
||||
|
||||
# Properties
|
||||
Properties/
|
||||
|
||||
artifacts/
|
||||
output/
|
||||
|
||||
|
@ -56,8 +53,6 @@ bld/
|
|||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
appsettings.json
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
|
|
|
@ -68,6 +68,13 @@ EndProject
|
|||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{243E768F-EA7D-4AF1-B625-0398440BB1AB}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
.gitattributes = .gitattributes
|
||||
.gitignore = .gitignore
|
||||
Directory.Build.props = Directory.Build.props
|
||||
Directory.Build.targets = Directory.Build.targets
|
||||
Directory.Packages.props = Directory.Packages.props
|
||||
global.json = global.json
|
||||
NuGet.config = NuGet.config
|
||||
spelling.dic = spelling.dic
|
||||
EndProjectSection
|
||||
EndProject
|
||||
|
@ -77,12 +84,8 @@ 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}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AgentChat", "AgentChat", "{668726B9-77BC-45CF-B576-0F0773BF1615}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoGen.Anthropic.Samples", "samples\AutoGen.Anthropic.Samples\AutoGen.Anthropic.Samples.csproj", "{84020C4A-933A-4693-9889-1B99304A7D76}"
|
||||
|
@ -123,9 +126,27 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloAgent", "samples\Hello
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIModelClientHostingExtensions", "src\Microsoft.AutoGen\Extensions\AIModelClientHostingExtensions\AIModelClientHostingExtensions.csproj", "{97550E87-48C6-4EBF-85E1-413ABAE9DBFD}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AutoGen.Agents.Tests", "Microsoft.AutoGen.Agents.Tests\Microsoft.AutoGen.Agents.Tests.csproj", "{CF4C92BD-28AE-4B8F-B173-601004AEC9BF}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{686480D7-8FEC-4ED3-9C5D-CEBE1057A7ED}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloAgentState", "samples\Hello\HelloAgentState\HelloAgentState.csproj", "{64EF61E7-00A6-4E5E-9808-62E10993A0E5}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloAgentState", "samples\Hello\HelloAgentState\HelloAgentState.csproj", "{64EF61E7-00A6-4E5E-9808-62E10993A0E5}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MarketingTeam", "MarketingTeam", "{ACC20E50-0E9A-47AE-B6B3-9F1AFE74E470}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Marketing.AgentHost", "samples\marketing-team\Marketing.AgentHost\Marketing.AgentHost.csproj", "{6C796ACE-9599-4D55-AA0D-F1615B2D8C42}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Marketing.Agents", "samples\marketing-team\Marketing.Agents\Marketing.Agents.csproj", "{7EF1F26A-85BF-4C6F-8891-331C44B5802B}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Marketing.AppHost", "samples\marketing-team\Marketing.AppHost\Marketing.AppHost.csproj", "{31DC6301-E354-46AA-BA0A-BED38AED8D36}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Marketing.Backend", "samples\marketing-team\Marketing.Backend\Marketing.Backend.csproj", "{60132BCE-0E8B-4E13-AEB0-919BC795E068}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Marketing.ServiceDefaults", "samples\marketing-team\Marketing.ServiceDefaults\Marketing.ServiceDefaults.csproj", "{F7C5E0CD-6FDA-4118-B419-74377C9CFD27}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Marketing.Shared", "samples\marketing-team\Marketing.Shared\Marketing.Shared.csproj", "{06CD34BB-93BF-467D-891A-91C44F0CD423}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevTeam.ServiceDefaults", "samples\dev-team\DevTeam.ServiceDefaults\DevTeam.ServiceDefaults.csproj", "{FA454D8D-F4CD-4B8F-97EB-AB2BE18AD3AD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -257,18 +278,10 @@ 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
|
||||
{A905E29A-7110-497F-ADC5-2CE2A148FEA0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D7E9D90B-5595-4E72-A90A-6DE20D9AB7AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D7E9D90B-5595-4E72-A90A-6DE20D9AB7AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D7E9D90B-5595-4E72-A90A-6DE20D9AB7AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D7E9D90B-5595-4E72-A90A-6DE20D9AB7AE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{84020C4A-933A-4693-9889-1B99304A7D76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{84020C4A-933A-4693-9889-1B99304A7D76}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{84020C4A-933A-4693-9889-1B99304A7D76}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
@ -337,10 +350,42 @@ Global
|
|||
{97550E87-48C6-4EBF-85E1-413ABAE9DBFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{97550E87-48C6-4EBF-85E1-413ABAE9DBFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{97550E87-48C6-4EBF-85E1-413ABAE9DBFD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{CF4C92BD-28AE-4B8F-B173-601004AEC9BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CF4C92BD-28AE-4B8F-B173-601004AEC9BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CF4C92BD-28AE-4B8F-B173-601004AEC9BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CF4C92BD-28AE-4B8F-B173-601004AEC9BF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{64EF61E7-00A6-4E5E-9808-62E10993A0E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{64EF61E7-00A6-4E5E-9808-62E10993A0E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{64EF61E7-00A6-4E5E-9808-62E10993A0E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{64EF61E7-00A6-4E5E-9808-62E10993A0E5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6C796ACE-9599-4D55-AA0D-F1615B2D8C42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6C796ACE-9599-4D55-AA0D-F1615B2D8C42}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6C796ACE-9599-4D55-AA0D-F1615B2D8C42}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6C796ACE-9599-4D55-AA0D-F1615B2D8C42}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7EF1F26A-85BF-4C6F-8891-331C44B5802B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7EF1F26A-85BF-4C6F-8891-331C44B5802B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7EF1F26A-85BF-4C6F-8891-331C44B5802B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7EF1F26A-85BF-4C6F-8891-331C44B5802B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{31DC6301-E354-46AA-BA0A-BED38AED8D36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{31DC6301-E354-46AA-BA0A-BED38AED8D36}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{31DC6301-E354-46AA-BA0A-BED38AED8D36}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{31DC6301-E354-46AA-BA0A-BED38AED8D36}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{60132BCE-0E8B-4E13-AEB0-919BC795E068}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{60132BCE-0E8B-4E13-AEB0-919BC795E068}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{60132BCE-0E8B-4E13-AEB0-919BC795E068}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{60132BCE-0E8B-4E13-AEB0-919BC795E068}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F7C5E0CD-6FDA-4118-B419-74377C9CFD27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F7C5E0CD-6FDA-4118-B419-74377C9CFD27}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F7C5E0CD-6FDA-4118-B419-74377C9CFD27}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F7C5E0CD-6FDA-4118-B419-74377C9CFD27}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{06CD34BB-93BF-467D-891A-91C44F0CD423}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{06CD34BB-93BF-467D-891A-91C44F0CD423}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{06CD34BB-93BF-467D-891A-91C44F0CD423}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{06CD34BB-93BF-467D-891A-91C44F0CD423}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FA454D8D-F4CD-4B8F-97EB-AB2BE18AD3AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FA454D8D-F4CD-4B8F-97EB-AB2BE18AD3AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FA454D8D-F4CD-4B8F-97EB-AB2BE18AD3AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FA454D8D-F4CD-4B8F-97EB-AB2BE18AD3AD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -378,9 +423,7 @@ 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}
|
||||
{84020C4A-933A-4693-9889-1B99304A7D76} = {668726B9-77BC-45CF-B576-0F0773BF1615}
|
||||
{5777515F-4053-42F9-AF2B-95D8D0F5384A} = {668726B9-77BC-45CF-B576-0F0773BF1615}
|
||||
|
@ -401,7 +444,16 @@ Global
|
|||
{A20B9894-F352-4338-872A-F215A241D43D} = {7EB336C2-7C0A-4BC8-80C6-A3173AB8DC45}
|
||||
{8F7560CF-EEBB-4333-A69F-838CA40FD85D} = {7EB336C2-7C0A-4BC8-80C6-A3173AB8DC45}
|
||||
{97550E87-48C6-4EBF-85E1-413ABAE9DBFD} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}
|
||||
{CF4C92BD-28AE-4B8F-B173-601004AEC9BF} = {F823671B-3ECA-4AE6-86DA-25E920D3FE64}
|
||||
{64EF61E7-00A6-4E5E-9808-62E10993A0E5} = {7EB336C2-7C0A-4BC8-80C6-A3173AB8DC45}
|
||||
{ACC20E50-0E9A-47AE-B6B3-9F1AFE74E470} = {686480D7-8FEC-4ED3-9C5D-CEBE1057A7ED}
|
||||
{6C796ACE-9599-4D55-AA0D-F1615B2D8C42} = {ACC20E50-0E9A-47AE-B6B3-9F1AFE74E470}
|
||||
{7EF1F26A-85BF-4C6F-8891-331C44B5802B} = {ACC20E50-0E9A-47AE-B6B3-9F1AFE74E470}
|
||||
{31DC6301-E354-46AA-BA0A-BED38AED8D36} = {ACC20E50-0E9A-47AE-B6B3-9F1AFE74E470}
|
||||
{60132BCE-0E8B-4E13-AEB0-919BC795E068} = {ACC20E50-0E9A-47AE-B6B3-9F1AFE74E470}
|
||||
{F7C5E0CD-6FDA-4118-B419-74377C9CFD27} = {ACC20E50-0E9A-47AE-B6B3-9F1AFE74E470}
|
||||
{06CD34BB-93BF-467D-891A-91C44F0CD423} = {ACC20E50-0E9A-47AE-B6B3-9F1AFE74E470}
|
||||
{FA454D8D-F4CD-4B8F-97EB-AB2BE18AD3AD} = {05B9C173-6441-4DCA-9AC4-E897EF75F331}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {93384647-528D-46C8-922C-8DB36A382F0B}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<CSNoWarn>CS1998;CS1591;CS8002;</CSNoWarn>
|
||||
<SKEXPNoWarn>SKEXP0001;SKEXP0010;SKEXP0020</SKEXPNoWarn>
|
||||
<NoWarn>$(NoWarn);$(CSNoWarn);$(SKEXPNoWarn);NU5104</NoWarn>
|
||||
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<IsPackable>false</IsPackable>
|
||||
|
@ -32,10 +33,6 @@
|
|||
<NoWarn>$(NoWarn);CA1829</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Text.Json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(IsTestProject)' == 'true'">
|
||||
<PackageReference Include="ApprovalTests" />
|
||||
<PackageReference Include="FluentAssertions" />
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
||||
<MicrosoftSemanticKernelVersion>1.22.0</MicrosoftSemanticKernelVersion>
|
||||
<MicrosoftSemanticKernelExperimentalVersion>1.22.0-alpha</MicrosoftSemanticKernelExperimentalVersion>
|
||||
<MicrosoftExtensionsAIVersion>9.0.0-preview.9.24507.7</MicrosoftExtensionsAIVersion>
|
||||
<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" />
|
||||
|
@ -16,6 +18,7 @@
|
|||
<PackageVersion Include="Aspire.Hosting.Orleans" Version="8.2.1" />
|
||||
<PackageVersion Include="Aspire.Hosting.Qdrant" Version="8.2.1" />
|
||||
<PackageVersion Include="Aspire.Hosting.Redis" Version="8.2.0" />
|
||||
<PackageVersion Include="Aspire.Hosting.Python" Version="8.2.0" />
|
||||
<PackageVersion Include="Azure.AI.OpenAI" Version=" 2.1.0-beta.1" />
|
||||
<PackageVersion Include="Azure.AI.Inference" Version="1.0.0-beta.1" />
|
||||
<PackageVersion Include="Azure.Data.Tables" Version="12.9.1" />
|
||||
|
@ -36,7 +39,7 @@
|
|||
<PackageVersion Include="Grpc.Core" Version="2.46.6" />
|
||||
<PackageVersion Include="Grpc.Net.ClientFactory" Version="2.66.0" />
|
||||
<PackageVersion Include="Grpc.Tools" Version="2.67.0" />
|
||||
<PackageVersion Include="Grpc.Net.Client" Version="2.65.0" />
|
||||
<PackageVersion Include="Grpc.Net.Client" Version="2.66.0" />
|
||||
<PackageVersion Include="Google.Protobuf" Version="3.28.2" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.App" Version="8.0.4" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.8" />
|
||||
|
@ -111,6 +114,5 @@
|
|||
<PackageVersion Include="Moq" Version="4.20.72" />
|
||||
<PackageVersion Include="Microsoft.PowerShell.SDK" Version="7.4.5" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="8.0.10" />
|
||||
<PackageVersion Include="System.Text.Json" Version="9.0.0-rc.2.24473.5" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// AgentBaseTests.cs
|
||||
|
||||
using FluentAssertions;
|
||||
using Google.Protobuf.Reflection;
|
||||
using Microsoft.AutoGen.Abstractions;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AutoGen.Agents.Tests;
|
||||
|
||||
public class AgentBaseTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task ItInvokeRightHandlerTestAsync()
|
||||
{
|
||||
var mockContext = new Mock<IAgentContext>();
|
||||
var agent = new TestAgent(mockContext.Object, new EventTypes(TypeRegistry.Empty, [], []));
|
||||
|
||||
await agent.HandleObject("hello world");
|
||||
await agent.HandleObject(42);
|
||||
|
||||
agent.ReceivedItems.Should().HaveCount(2);
|
||||
agent.ReceivedItems[0].Should().Be("hello world");
|
||||
agent.ReceivedItems[1].Should().Be(42);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The test agent is a simple agent that is used for testing purposes.
|
||||
/// </summary>
|
||||
public class TestAgent : AgentBase, IHandle<string>, IHandle<int>
|
||||
{
|
||||
public TestAgent(IAgentContext context, EventTypes eventTypes) : base(context, eventTypes)
|
||||
{
|
||||
}
|
||||
|
||||
public Task Handle(string item)
|
||||
{
|
||||
ReceivedItems.Add(item);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(int item)
|
||||
{
|
||||
ReceivedItems.Add(item);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public List<object> ReceivedItems { get; private set; } = [];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsTestProject>True</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\src\Microsoft.AutoGen\Agents\Microsoft.AutoGen.Agents.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -15,5 +15,6 @@
|
|||
<ProjectReference Include="..\..\src\AutoGen\AutoGen.csproj" />
|
||||
<PackageReference Include="FluentAssertions" />
|
||||
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Web" />
|
||||
<PackageReference Include="Microsoft.Extensions.AI" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// AgentCodeSnippet.cs
|
||||
|
||||
using AutoGen.Core;
|
||||
|
||||
namespace AutoGen.BasicSample.CodeSnippet;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// UserProxyAgentCodeSnippet.cs
|
||||
|
||||
using AutoGen.Core;
|
||||
|
||||
namespace AutoGen.BasicSample.CodeSnippet;
|
||||
|
|
|
@ -6,6 +6,7 @@ using AutoGen.Core;
|
|||
using AutoGen.OpenAI;
|
||||
using AutoGen.OpenAI.Extension;
|
||||
using FluentAssertions;
|
||||
using Microsoft.Extensions.AI;
|
||||
|
||||
/// <summary>
|
||||
/// This example shows how to add type-safe function call to an agent.
|
||||
|
@ -37,13 +38,20 @@ public partial class Example03_Agent_FunctionCall
|
|||
/// </summary>
|
||||
/// <param name="price">price, should be an integer</param>
|
||||
/// <param name="taxRate">tax rate, should be in range (0, 1)</param>
|
||||
[FunctionAttribute]
|
||||
[Function]
|
||||
public async Task<string> CalculateTax(int price, float taxRate)
|
||||
{
|
||||
return $"tax is {price * taxRate}";
|
||||
}
|
||||
|
||||
public static async Task RunAsync()
|
||||
/// <summary>
|
||||
/// This example shows how to add type-safe function call using AutoGen.SourceGenerator.
|
||||
/// The SourceGenerator will automatically generate FunctionDefinition and FunctionCallWrapper during compiling time.
|
||||
///
|
||||
/// For adding type-safe function call from M.E.A.I tools, please refer to <see cref="ToolCallWithMEAITools"/>.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static async Task ToolCallWithSourceGenerator()
|
||||
{
|
||||
var instance = new Example03_Agent_FunctionCall();
|
||||
var gpt4o = LLMConfiguration.GetOpenAIGPT4o_mini();
|
||||
|
@ -101,4 +109,60 @@ public partial class Example03_Agent_FunctionCall
|
|||
// send aggregate message back to llm to get the final result
|
||||
var finalResult = await agent.SendAsync(calculateTaxes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This example shows how to add type-safe function call from M.E.A.I tools.
|
||||
///
|
||||
/// For adding type-safe function call from source generator, please refer to <see cref="ToolCallWithSourceGenerator"/>.
|
||||
/// </summary>
|
||||
public static async Task ToolCallWithMEAITools()
|
||||
{
|
||||
var gpt4o = LLMConfiguration.GetOpenAIGPT4o_mini();
|
||||
var instance = new Example03_Agent_FunctionCall();
|
||||
|
||||
AIFunction[] tools = [
|
||||
AIFunctionFactory.Create(instance.UpperCase),
|
||||
AIFunctionFactory.Create(instance.ConcatString),
|
||||
AIFunctionFactory.Create(instance.CalculateTax),
|
||||
];
|
||||
|
||||
var toolCallMiddleware = new FunctionCallMiddleware(tools);
|
||||
|
||||
var agent = new OpenAIChatAgent(
|
||||
chatClient: gpt4o,
|
||||
name: "agent",
|
||||
systemMessage: "You are a helpful AI assistant")
|
||||
.RegisterMessageConnector()
|
||||
.RegisterStreamingMiddleware(toolCallMiddleware)
|
||||
.RegisterPrintMessage();
|
||||
|
||||
// talk to the assistant agent
|
||||
var upperCase = await agent.SendAsync("convert to upper case: hello world");
|
||||
upperCase.GetContent()?.Should().Be("HELLO WORLD");
|
||||
upperCase.Should().BeOfType<ToolCallAggregateMessage>();
|
||||
upperCase.GetToolCalls().Should().HaveCount(1);
|
||||
upperCase.GetToolCalls().First().FunctionName.Should().Be(nameof(UpperCase));
|
||||
|
||||
var concatString = await agent.SendAsync("concatenate strings: a, b, c, d, e");
|
||||
concatString.GetContent()?.Should().Be("a b c d e");
|
||||
concatString.Should().BeOfType<ToolCallAggregateMessage>();
|
||||
concatString.GetToolCalls().Should().HaveCount(1);
|
||||
concatString.GetToolCalls().First().FunctionName.Should().Be(nameof(ConcatString));
|
||||
|
||||
var calculateTax = await agent.SendAsync("calculate tax: 100, 0.1");
|
||||
calculateTax.GetContent().Should().Be("tax is 10");
|
||||
calculateTax.Should().BeOfType<ToolCallAggregateMessage>();
|
||||
calculateTax.GetToolCalls().Should().HaveCount(1);
|
||||
calculateTax.GetToolCalls().First().FunctionName.Should().Be(nameof(CalculateTax));
|
||||
|
||||
// parallel function calls
|
||||
var calculateTaxes = await agent.SendAsync("calculate tax: 100, 0.1; calculate tax: 200, 0.2");
|
||||
calculateTaxes.GetContent().Should().Be("tax is 10\ntax is 40"); // "tax is 10\n tax is 40
|
||||
calculateTaxes.Should().BeOfType<ToolCallAggregateMessage>();
|
||||
calculateTaxes.GetToolCalls().Should().HaveCount(2);
|
||||
calculateTaxes.GetToolCalls().First().FunctionName.Should().Be(nameof(CalculateTax));
|
||||
|
||||
// send aggregate message back to llm to get the final result
|
||||
var finalResult = await agent.SendAsync(calculateTaxes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Example06_UserProxyAgent.cs
|
||||
|
||||
using AutoGen.Core;
|
||||
using AutoGen.OpenAI;
|
||||
using AutoGen.OpenAI.Extension;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Program.cs
|
||||
|
||||
//await Example07_Dynamic_GroupChat_Calculate_Fibonacci.RunAsync();
|
||||
|
||||
|
@ -10,7 +11,8 @@ var allSamples = new List<(string, Func<Task>)>
|
|||
// When a new sample is created please add them to the allSamples collection
|
||||
("Assistant Agent", Example01_AssistantAgent.RunAsync),
|
||||
("Two-agent Math Chat", Example02_TwoAgent_MathChat.RunAsync),
|
||||
("Agent Function Call", Example03_Agent_FunctionCall.RunAsync),
|
||||
("Agent Function Call With Source Generator", Example03_Agent_FunctionCall.ToolCallWithSourceGenerator),
|
||||
("Agent Function Call With M.E.A.I AI Functions", Example03_Agent_FunctionCall.ToolCallWithMEAITools),
|
||||
("Dynamic Group Chat Coding Task", Example04_Dynamic_GroupChat_Coding_Task.RunAsync),
|
||||
("DALL-E and GPT4v", Example05_Dalle_And_GPT4V.RunAsync),
|
||||
("User Proxy Agent", Example06_UserProxyAgent.RunAsync),
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Connect_To_Azure_OpenAI.cs
|
||||
|
||||
#region using_statement
|
||||
using System.ClientModel;
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"profiles": {
|
||||
"AutoGen.WebAPI.Sample": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:50675;http://localhost:50676"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +1,16 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Runtime\Microsoft.AutoGen.Runtime.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" />
|
||||
</ItemGroup>
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Runtime\Microsoft.AutoGen.Runtime.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
using Microsoft.Extensions.Hosting;
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Program.cs
|
||||
|
||||
var app = await Microsoft.AutoGen.Runtime.Host.StartAsync(local: true);
|
||||
await app.WaitForShutdownAsync();
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"profiles": {
|
||||
"Backend": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:53071;http://localhost:53072"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
|
@ -10,12 +9,12 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspire.Hosting.AppHost"/>
|
||||
<PackageReference Include="Aspire.Hosting"/>
|
||||
<PackageReference Include="Aspire.Hosting.AppHost" />
|
||||
<PackageReference Include="Aspire.Hosting" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Backend\Backend.csproj" />
|
||||
<ProjectReference Include="..\HelloAgent\HelloAgent.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Program.cs
|
||||
|
||||
var builder = DistributedApplication.CreateBuilder(args);
|
||||
var backend = builder.AddProject<Projects.Backend>("backend");
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"profiles": {
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "https://localhost:15887;http://localhost:15888",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"DOTNET_ENVIRONMENT": "Development",
|
||||
//"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:16037",
|
||||
"DOTNET_DASHBOARD_OTLP_HTTP_ENDPOINT_URL": "https://localhost:16038",
|
||||
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:17037",
|
||||
"DOTNET_ASPIRE_SHOW_DASHBOARD_RESOURCES": "true"
|
||||
}
|
||||
},
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:15888",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"DOTNET_ENVIRONMENT": "Development",
|
||||
//"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16031",
|
||||
"DOTNET_DASHBOARD_OTLP_HTTP_ENDPOINT_URL": "http://localhost:16032",
|
||||
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:17031",
|
||||
"DOTNET_ASPIRE_SHOW_DASHBOARD_RESOURCES": "true",
|
||||
"ASPIRE_ALLOW_UNSECURED_TRANSPORT": "true"
|
||||
}
|
||||
},
|
||||
"generate-manifest": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"commandLineArgs": "--publisher manifest --output-path aspire-manifest.json",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"DOTNET_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
},
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json"
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// HelloAIAgent.cs
|
||||
|
||||
using Microsoft.AutoGen.Abstractions;
|
||||
using Microsoft.AutoGen.Agents;
|
||||
using Microsoft.Extensions.AI;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Hello;
|
||||
[TopicSubscription("HelloAgents")]
|
||||
|
@ -18,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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Abstractions\Microsoft.AutoGen.Abstractions.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Agents\Microsoft.AutoGen.Agents.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Runtime\Microsoft.AutoGen.Runtime.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Extensions\AIModelClientHostingExtensions\AIModelClientHostingExtensions.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" />
|
||||
</ItemGroup>
|
||||
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
|
@ -18,4 +6,14 @@
|
|||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Abstractions\Microsoft.AutoGen.Abstractions.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Agents\Microsoft.AutoGen.Agents.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Runtime\Microsoft.AutoGen.Runtime.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Extensions\AIModelClientHostingExtensions\AIModelClientHostingExtensions.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Program.cs
|
||||
|
||||
using Hello;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AutoGen.Abstractions;
|
||||
using Microsoft.AutoGen.Agents;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
// send a message to the agent
|
||||
var builder = WebApplication.CreateBuilder();
|
||||
|
@ -46,14 +46,14 @@ namespace Hello
|
|||
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)
|
||||
{
|
||||
|
@ -61,8 +61,8 @@ namespace Hello
|
|||
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);
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"profiles": {
|
||||
"HelloAIAgents": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:53139;http://localhost:53140"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Abstractions\Microsoft.AutoGen.Abstractions.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Agents\Microsoft.AutoGen.Agents.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Runtime\Microsoft.AutoGen.Runtime.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" />
|
||||
<PackageReference Include="Aspire.Hosting.AppHost" />
|
||||
</ItemGroup>
|
||||
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
|
@ -18,4 +6,14 @@
|
|||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" />
|
||||
<PackageReference Include="Aspire.Hosting.AppHost" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Abstractions\Microsoft.AutoGen.Abstractions.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Agents\Microsoft.AutoGen.Agents.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Runtime\Microsoft.AutoGen.Runtime.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Program.cs
|
||||
|
||||
using Microsoft.AutoGen.Abstractions;
|
||||
using Microsoft.AutoGen.Agents;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
// send a message to the agent
|
||||
// step 1: create in-memory agent runtime
|
||||
|
||||
// step 2: register HelloAgent to that agent runtime
|
||||
|
||||
// step 3: start the agent runtime
|
||||
|
||||
// step 4: send a message to the agent
|
||||
|
||||
// step 5: wait for the agent runtime to shutdown
|
||||
var app = await AgentsApp.PublishMessageAsync("HelloAgents", new NewMessageReceived
|
||||
{
|
||||
Message = "World"
|
||||
|
@ -18,27 +25,26 @@ namespace Hello
|
|||
[TopicSubscription("HelloAgents")]
|
||||
public class HelloAgent(
|
||||
IAgentContext context,
|
||||
[FromKeyedServices("EventTypes")] EventTypes typeRegistry) : ConsoleAgent(
|
||||
[FromKeyedServices("EventTypes")] EventTypes typeRegistry,
|
||||
IHostApplicationLifetime hostApplicationLifetime) : AgentBase(
|
||||
context,
|
||||
typeRegistry),
|
||||
ISayHello,
|
||||
IHandleConsole,
|
||||
IHandle<NewMessageReceived>,
|
||||
IHandle<ConversationClosed>
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
@ -46,13 +52,13 @@ namespace Hello
|
|||
var evt = new Output
|
||||
{
|
||||
Message = goodbye
|
||||
}.ToCloudEvent(this.AgentId.Key);
|
||||
await PublishEvent(evt).ConfigureAwait(false);
|
||||
//sleep
|
||||
await Task.Delay(10000).ConfigureAwait(false);
|
||||
await AgentsApp.ShutdownAsync().ConfigureAwait(false);
|
||||
};
|
||||
await PublishMessageAsync(evt).ConfigureAwait(false);
|
||||
|
||||
// Signal shutdown.
|
||||
hostApplicationLifetime.StopApplication();
|
||||
}
|
||||
|
||||
public async Task<string> SayHello(string ask)
|
||||
{
|
||||
var response = $"\n\n\n\n***************Hello {ask}**********************\n\n\n\n";
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"profiles": {
|
||||
"HelloAgent": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:53113;http://localhost:53114"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Abstractions\Microsoft.AutoGen.Abstractions.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Agents\Microsoft.AutoGen.Agents.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Runtime\Microsoft.AutoGen.Runtime.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" />
|
||||
<PackageReference Include="Aspire.Hosting.AppHost" />
|
||||
</ItemGroup>
|
||||
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
|
@ -18,4 +6,14 @@
|
|||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" />
|
||||
<PackageReference Include="Aspire.Hosting.AppHost" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Abstractions\Microsoft.AutoGen.Abstractions.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Agents\Microsoft.AutoGen.Agents.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Runtime\Microsoft.AutoGen.Runtime.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Program.cs
|
||||
|
||||
using Microsoft.AutoGen.Abstractions;
|
||||
using Microsoft.AutoGen.Agents;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
// send a message to the agent
|
||||
var app = await AgentsApp.PublishMessageAsync("HelloAgents", new NewMessageReceived
|
||||
|
@ -32,20 +31,20 @@ namespace Hello
|
|||
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)
|
||||
{
|
||||
|
@ -55,8 +54,8 @@ namespace Hello
|
|||
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);
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"profiles": {
|
||||
"HelloAgentState": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:53136;http://localhost:53137"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,7 +10,8 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../../src/Microsoft.AutoGen/Runtime/Microsoft.AutoGen.Runtime.csproj" />
|
||||
<ProjectReference Include="../../../src/Microsoft.AutoGen/ServiceDefaults/Microsoft.AutoGen.ServiceDefaults.csproj" />
|
||||
<ProjectReference Include="..\DevTeam.ServiceDefaults\DevTeam.ServiceDefaults.csproj" />
|
||||
<ProjectReference Include="..\DevTeam.Shared\DevTeam.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Program.cs
|
||||
|
||||
using Microsoft.AutoGen.Runtime;
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"profiles": {
|
||||
"DevTeam.AgentHost": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:50670;http://localhost:50673"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,10 +7,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
|
||||
<ProjectReference Include="../../../src/Microsoft.AutoGen/Agents/Microsoft.AutoGen.Agents.csproj" />
|
||||
|
||||
<ProjectReference Include="../../../src/Microsoft.AutoGen/ServiceDefaults/Microsoft.AutoGen.ServiceDefaults.csproj" />
|
||||
<ProjectReference Include="..\DevTeam.Shared\DevTeam.Shared.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Extensions\SemanticKernel\Microsoft.AutoGen.Extensions.SemanticKernel.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Developer.cs
|
||||
|
||||
using DevTeam.Shared;
|
||||
using Microsoft.AutoGen.Abstractions;
|
||||
using Microsoft.AutoGen.Agents;
|
||||
|
@ -21,8 +24,8 @@ public class Dev(IAgentContext context, Kernel kernel, ISemanticTextMemory memor
|
|||
Repo = item.Repo,
|
||||
IssueNumber = item.IssueNumber,
|
||||
Code = code
|
||||
}.ToCloudEvent(this.AgentId.Key);
|
||||
await PublishEvent(evt);
|
||||
};
|
||||
await PublishMessageAsync(evt);
|
||||
}
|
||||
|
||||
public async Task Handle(CodeChainClosed item)
|
||||
|
@ -32,8 +35,8 @@ public class Dev(IAgentContext context, Kernel kernel, ISemanticTextMemory memor
|
|||
var evt = new CodeCreated
|
||||
{
|
||||
Code = lastCode
|
||||
}.ToCloudEvent(this.AgentId.Key);
|
||||
await PublishEvent(evt);
|
||||
};
|
||||
await PublishMessageAsync(evt);
|
||||
}
|
||||
|
||||
public async Task<string> GenerateCode(string ask)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// DeveloperPrompts.cs
|
||||
|
||||
namespace DevTeam.Agents;
|
||||
public static class DeveloperSkills
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// DeveloperLead.cs
|
||||
|
||||
using DevTeam.Shared;
|
||||
using Microsoft.AutoGen.Abstractions;
|
||||
using Microsoft.AutoGen.Agents;
|
||||
|
@ -22,8 +25,8 @@ public class DeveloperLead(IAgentContext context, Kernel kernel, ISemanticTextMe
|
|||
Repo = item.Repo,
|
||||
IssueNumber = item.IssueNumber,
|
||||
Plan = plan
|
||||
}.ToCloudEvent(this.AgentId.Key);
|
||||
await PublishEvent(evt);
|
||||
};
|
||||
await PublishMessageAsync(evt);
|
||||
}
|
||||
|
||||
public async Task Handle(DevPlanChainClosed item)
|
||||
|
@ -33,8 +36,8 @@ public class DeveloperLead(IAgentContext context, Kernel kernel, ISemanticTextMe
|
|||
var evt = new DevPlanCreated
|
||||
{
|
||||
Plan = lastPlan
|
||||
}.ToCloudEvent(this.AgentId.Key);
|
||||
await PublishEvent(evt);
|
||||
};
|
||||
await PublishMessageAsync(evt);
|
||||
}
|
||||
public async Task<string> CreatePlan(string ask)
|
||||
{
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// DeveloperLeadPrompts.cs
|
||||
|
||||
namespace DevTeam.Agents;
|
||||
public static class DevLeadSkills
|
||||
{
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// PMPrompts.cs
|
||||
|
||||
namespace DevTeam.Agents;
|
||||
public static class PMSkills
|
||||
{
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// ProductManager.cs
|
||||
|
||||
using DevTeam.Shared;
|
||||
using Microsoft.AutoGen.Abstractions;
|
||||
using Microsoft.AutoGen.Agents;
|
||||
|
@ -19,8 +22,8 @@ public class ProductManager(IAgentContext context, Kernel kernel, ISemanticTextM
|
|||
var evt = new ReadmeCreated
|
||||
{
|
||||
Readme = lastReadme
|
||||
}.ToCloudEvent(this.AgentId.Key);
|
||||
await PublishEvent(evt);
|
||||
};
|
||||
await PublishMessageAsync(evt);
|
||||
}
|
||||
|
||||
public async Task Handle(ReadmeRequested item)
|
||||
|
@ -32,8 +35,8 @@ public class ProductManager(IAgentContext context, Kernel kernel, ISemanticTextM
|
|||
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)
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Program.cs
|
||||
|
||||
using DevTeam.Agents;
|
||||
using Microsoft.AutoGen.Agents;
|
||||
using Microsoft.AutoGen.Extensions.SemanticKernel;
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"profiles": {
|
||||
"DevTeam.Agents": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:50669;http://localhost:50671"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Program.cs
|
||||
|
||||
var builder = DistributedApplication.CreateBuilder(args);
|
||||
|
||||
builder.AddAzureProvisioning();
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"profiles": {
|
||||
"DevTeam.AppHost": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:17034;http://localhost:15043",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"DOTNET_ENVIRONMENT": "Development",
|
||||
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21249",
|
||||
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22030"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// AzureGenie.cs
|
||||
|
||||
using DevTeam.Backend;
|
||||
using DevTeam.Shared;
|
||||
using Microsoft.AutoGen.Abstractions;
|
||||
|
@ -17,7 +20,7 @@ public class AzureGenie(IAgentContext context, Kernel kernel, ISemanticTextMemor
|
|||
// 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),
|
||||
|
@ -33,7 +36,7 @@ public class AzureGenie(IAgentContext context, Kernel kernel, ISemanticTextMemor
|
|||
// //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),
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Hubber.cs
|
||||
|
||||
using System.Text.Json;
|
||||
using DevTeam;
|
||||
using DevTeam.Backend;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
// TODO: Reimplement using ACA Sessions
|
||||
// using DevTeam.Events;
|
||||
// using Microsoft.AutoGen.Abstractions;
|
||||
// using Microsoft.AutoGen.Agents;
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Sandbox.cs
|
||||
|
||||
// namespace DevTeam.Backend;
|
||||
|
||||
|
@ -52,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),
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../../src/Microsoft.AutoGen/ServiceDefaults/Microsoft.AutoGen.ServiceDefaults.csproj" />
|
||||
<ProjectReference Include="..\DevTeam.Shared\DevTeam.Shared.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AutoGen\Extensions\SemanticKernel\Microsoft.AutoGen.Extensions.SemanticKernel.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Program.cs
|
||||
|
||||
using Azure.Identity;
|
||||
using DevTeam.Backend;
|
||||
using DevTeam.Options;
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"profiles": {
|
||||
"DevTeam.Backend": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:50672;http://localhost:50674"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// AzureService.cs
|
||||
|
||||
using System.Text;
|
||||
using Azure;
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// GithubAuthService.cs
|
||||
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Cryptography;
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// GithubService.cs
|
||||
|
||||
using System.Text;
|
||||
using Azure.Storage.Files.Shares;
|
||||
using DevTeam.Options;
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// GithubWebHookProcessor.cs
|
||||
|
||||
using System.Globalization;
|
||||
using DevTeam.Shared;
|
||||
using Microsoft.AutoGen.Abstractions;
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsAspireSharedProject>true</IsAspireSharedProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
|
||||
<PackageReference Include="Microsoft.Extensions.Http.Resilience" />
|
||||
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" />
|
||||
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" />
|
||||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
|
||||
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />
|
||||
<PackageReference Include="OpenTelemetry.Instrumentation.Http" />
|
||||
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,122 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Extensions.cs
|
||||
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OpenTelemetry;
|
||||
using OpenTelemetry.Metrics;
|
||||
using OpenTelemetry.Trace;
|
||||
|
||||
namespace Microsoft.Extensions.Hosting;
|
||||
|
||||
// Adds common .NET Aspire services: service discovery, resilience, health checks, and OpenTelemetry.
|
||||
// This project should be referenced by each service project in your solution.
|
||||
// To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults
|
||||
public static class Extensions
|
||||
{
|
||||
public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBuilder builder)
|
||||
{
|
||||
builder.ConfigureOpenTelemetry();
|
||||
|
||||
builder.AddDefaultHealthChecks();
|
||||
|
||||
builder.Services.AddServiceDiscovery();
|
||||
|
||||
builder.Services.ConfigureHttpClientDefaults(http =>
|
||||
{
|
||||
// Turn on resilience by default
|
||||
http.AddStandardResilienceHandler();
|
||||
|
||||
// Turn on service discovery by default
|
||||
http.AddServiceDiscovery();
|
||||
});
|
||||
|
||||
// Uncomment the following to restrict the allowed schemes for service discovery.
|
||||
// builder.Services.Configure<ServiceDiscoveryOptions>(options =>
|
||||
// {
|
||||
// options.AllowedSchemes = ["https"];
|
||||
// });
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicationBuilder builder)
|
||||
{
|
||||
builder.Logging.AddOpenTelemetry(logging =>
|
||||
{
|
||||
logging.IncludeFormattedMessage = true;
|
||||
logging.IncludeScopes = true;
|
||||
});
|
||||
|
||||
builder.Services.AddOpenTelemetry()
|
||||
.WithMetrics(metrics =>
|
||||
{
|
||||
metrics.AddAspNetCoreInstrumentation()
|
||||
.AddHttpClientInstrumentation()
|
||||
.AddRuntimeInstrumentation()
|
||||
.AddMeter("Microsoft.Orleans");
|
||||
})
|
||||
.WithTracing(tracing =>
|
||||
{
|
||||
tracing.AddAspNetCoreInstrumentation()
|
||||
//.AddGrpcClientInstrumentation()
|
||||
.AddHttpClientInstrumentation()
|
||||
.AddSource("Microsoft.Orleans.Application")
|
||||
.AddSource("AutoGen.Agent");
|
||||
});
|
||||
|
||||
builder.AddOpenTelemetryExporters();
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostApplicationBuilder builder)
|
||||
{
|
||||
var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]);
|
||||
|
||||
if (useOtlpExporter)
|
||||
{
|
||||
builder.Services.AddOpenTelemetry().UseOtlpExporter();
|
||||
}
|
||||
|
||||
// Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package)
|
||||
//if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]))
|
||||
//{
|
||||
// builder.Services.AddOpenTelemetry()
|
||||
// .UseAzureMonitor();
|
||||
//}
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static IHostApplicationBuilder AddDefaultHealthChecks(this IHostApplicationBuilder builder)
|
||||
{
|
||||
builder.Services.AddHealthChecks()
|
||||
// Add a default liveness check to ensure app is responsive
|
||||
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]);
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static WebApplication MapDefaultEndpoints(this WebApplication app)
|
||||
{
|
||||
// Adding health checks endpoints to applications in non-development environments has security implications.
|
||||
// See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
// All health checks must pass for app to be considered ready to accept traffic after starting
|
||||
app.MapHealthChecks("/health");
|
||||
|
||||
// Only health checks tagged with the "live" tag must pass for app to be considered alive
|
||||
app.MapHealthChecks("/alive", new HealthCheckOptions
|
||||
{
|
||||
Predicate = r => r.Tags.Contains("live")
|
||||
});
|
||||
}
|
||||
|
||||
return app;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../../src/Microsoft.AutoGen/Agents/Microsoft.AutoGen.Agents.csproj" />
|
||||
<ProjectReference Include="..\DevTeam.ServiceDefaults\DevTeam.ServiceDefaults.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// EventExtensions.cs
|
||||
|
||||
using System.Globalization;
|
||||
using Microsoft.AutoGen.Abstractions;
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// DevPlan.cs
|
||||
|
||||
namespace DevTeam;
|
||||
public class DevLeadPlan
|
||||
{
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// AzureOptions.cs
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace DevTeam.Options;
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// GithubOptions.cs
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace DevTeam.Options;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// ParseExtensions.cs
|
||||
|
||||
namespace DevTeam;
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/.infra/
|
||||
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
.yarn/install-state.gz
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# next.js
|
||||
/.next/
|
||||
/out/
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# local env files
|
||||
.env*.local
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
# typescript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
|
@ -0,0 +1,14 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../../src/Microsoft.AutoGen/Runtime/Microsoft.AutoGen.Runtime.csproj" />
|
||||
<ProjectReference Include="..\Marketing.Shared\Marketing.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,6 @@
|
|||
@Marketing.AgentHost_HostAddress = http://localhost:5136
|
||||
|
||||
GET {{Marketing.AgentHost_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Program.cs
|
||||
|
||||
using Microsoft.AutoGen.Runtime;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.AddServiceDefaults();
|
||||
builder.AddAgentService();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.MapDefaultEndpoints();
|
||||
app.MapAgentService();
|
||||
|
||||
app.Run();
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:59666",
|
||||
"sslPort": 44374
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "http://localhost:5136",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:7069;http://localhost:5136",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Auditor.cs
|
||||
|
||||
using Marketing.Shared;
|
||||
using Microsoft.AutoGen.Abstractions;
|
||||
using Microsoft.AutoGen.Agents;
|
||||
using Microsoft.SemanticKernel;
|
||||
using Microsoft.SemanticKernel.Memory;
|
||||
|
||||
namespace Marketing.Agents;
|
||||
|
||||
[TopicSubscription("default")]
|
||||
public class Auditor(IAgentContext context, Kernel kernel, ISemanticTextMemory memory, [FromKeyedServices("EventTypes")] EventTypes typeRegistry, ILogger<Auditor> logger)
|
||||
: SKAiAgent<AuditorState>(context, memory, kernel, typeRegistry),
|
||||
IHandle<AuditText>
|
||||
{
|
||||
public async Task Handle(AuditText item)
|
||||
{
|
||||
logger.LogInformation($"[{nameof(Auditor)}] Event {nameof(AuditText)}. Text: {{Text}}", item.Text);
|
||||
|
||||
var context = new KernelArguments { ["input"] = AppendChatHistory(item.Text) };
|
||||
var auditorAnswer = await CallFunction(AuditorPrompts.AuditText, context);
|
||||
if (auditorAnswer.Contains("NOTFORME", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await SendAuditorAlertEvent(auditorAnswer, item.UserId);
|
||||
}
|
||||
|
||||
private async Task SendAuditorAlertEvent(string auditorAlertMessage, string userId)
|
||||
{
|
||||
var auditorAlert = new AuditorAlert
|
||||
{
|
||||
AuditorAlertMessage = auditorAlertMessage,
|
||||
UserId = userId
|
||||
}.ToCloudEvent(this.AgentId.Key);
|
||||
|
||||
await PublishEvent(auditorAlert);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// AuditorPrompts.cs
|
||||
|
||||
namespace Marketing.Agents;
|
||||
|
||||
public static class AuditorPrompts
|
||||
{
|
||||
public const string AuditText = """
|
||||
You are an Auditor in a Marketing team
|
||||
Audit the text bello and make sure we do not give discounts larger than 10%
|
||||
If the text talks about a larger than 10% discount, reply with a message to the user saying that the discount is too large, and by company policy we are not allowed.
|
||||
If the message says who wrote it, add that information in the response as well
|
||||
In any other case, reply with NOTFORME
|
||||
---
|
||||
Input: {{$input}}
|
||||
---
|
||||
""";
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// CommunityManager.cs
|
||||
|
||||
using Marketing.Shared;
|
||||
using Microsoft.AutoGen.Abstractions;
|
||||
using Microsoft.AutoGen.Agents;
|
||||
using Microsoft.SemanticKernel;
|
||||
using Microsoft.SemanticKernel.Memory;
|
||||
|
||||
namespace Marketing.Agents;
|
||||
|
||||
[TopicSubscription("default")]
|
||||
public class CommunityManager(IAgentContext context, Kernel kernel, ISemanticTextMemory memory, [FromKeyedServices("EventTypes")] EventTypes typeRegistry, ILogger<CommunityManager> logger)
|
||||
: SKAiAgent<CommunityManagerState>(context, memory, kernel, typeRegistry),
|
||||
IHandle<UserConnected>,
|
||||
IHandle<UserChatInput>,
|
||||
IHandle<ArticleCreated>
|
||||
{
|
||||
public async Task Handle(ArticleCreated item)
|
||||
{
|
||||
logger.LogInformation($"Article created: {item.Article}");
|
||||
_state.Data.Article = item.Article;
|
||||
await HandleGeneration(item.UserId, item.UserMessage);
|
||||
}
|
||||
|
||||
public async Task Handle(UserChatInput item)
|
||||
{
|
||||
logger.LogInformation($"UserChatInput: {item.UserMessage}");
|
||||
if (_state.Data.Article == null) { return; }
|
||||
await HandleGeneration(item.UserId, item.UserMessage);
|
||||
}
|
||||
|
||||
private async Task HandleGeneration(string userId, string userMessage)
|
||||
{
|
||||
var input = _state.Data.Article + "| USER REQUEST: " + userMessage;
|
||||
var context = new KernelArguments { ["input"] = AppendChatHistory(input) };
|
||||
var socialMediaPost = await CallFunction(CommunityManagerPrompts.WritePost, context);
|
||||
if (socialMediaPost.Contains("NOTFORME", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
return;
|
||||
}
|
||||
_state.Data.WrittenSocialMediaPost = socialMediaPost;
|
||||
|
||||
await SendDesignedCreatedEvent(socialMediaPost, userId);
|
||||
}
|
||||
|
||||
public async Task Handle(UserConnected item)
|
||||
{
|
||||
//The user reconnected, let's send the last message if we have one
|
||||
var lastMessage = _state.History.LastOrDefault()?.Message;
|
||||
if (string.IsNullOrWhiteSpace(lastMessage))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await SendDesignedCreatedEvent(lastMessage, item.UserId);
|
||||
}
|
||||
|
||||
private async Task SendDesignedCreatedEvent(string socialMediaPost, string userId)
|
||||
{
|
||||
var socialMediaPostCreatedEvent = new SocialMediaPostCreated
|
||||
{
|
||||
SocialMediaPost = socialMediaPost,
|
||||
UserId = userId
|
||||
}.ToCloudEvent(this.AgentId.Key);
|
||||
|
||||
await PublishEvent(socialMediaPostCreatedEvent);
|
||||
}
|
||||
|
||||
// This is just an example on how you can synchronously call an specific agent
|
||||
public Task<string> GetArticle()
|
||||
{
|
||||
return Task.FromResult(_state.Data.WrittenSocialMediaPost);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// CommunityManagerPrompts.cs
|
||||
|
||||
namespace Marketing.Agents;
|
||||
|
||||
public static class CommunityManagerPrompts
|
||||
{
|
||||
public const string WritePost = """
|
||||
You are a Marketing community manager writer.
|
||||
If the request from the user is to write a post to promote a new product, or if it is specifically talking to you (community manager)
|
||||
then you should write a post based on the user request
|
||||
Your writings are going to be posted on Tweeter. So be informal, friendly and add some hashtags and emojis.
|
||||
Remember, the tweet cannot be longer than 280 characters.
|
||||
If the request was not intedend for you. reply with <NOTFORME>"
|
||||
---
|
||||
Input: {{$input}}
|
||||
---
|
||||
""";
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// GraphicDesigner.cs
|
||||
|
||||
using Marketing.Shared;
|
||||
using Microsoft.AutoGen.Abstractions;
|
||||
using Microsoft.AutoGen.Agents;
|
||||
using Microsoft.SemanticKernel;
|
||||
using Microsoft.SemanticKernel.Memory;
|
||||
using Microsoft.SemanticKernel.TextToImage;
|
||||
|
||||
namespace Marketing.Agents;
|
||||
|
||||
[TopicSubscription("default")]
|
||||
public class GraphicDesigner(IAgentContext context, Kernel kernel, ISemanticTextMemory memory, [FromKeyedServices("EventTypes")] EventTypes typeRegistry, ILogger<GraphicDesigner> logger)
|
||||
: SKAiAgent<GraphicDesignerState>(context, memory, kernel, typeRegistry),
|
||||
IHandle<UserConnected>,
|
||||
IHandle<ArticleCreated>
|
||||
{
|
||||
public async Task Handle(UserConnected item)
|
||||
{
|
||||
var lastMessage = _state.History.LastOrDefault()?.Message;
|
||||
if (string.IsNullOrWhiteSpace(lastMessage))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await SendDesignedCreatedEvent(lastMessage, item.UserId);
|
||||
}
|
||||
|
||||
public async Task Handle(ArticleCreated item)
|
||||
{
|
||||
//For demo purposes, we do not recreate images if they already exist
|
||||
if (!string.IsNullOrEmpty(_state.Data.ImageUrl))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
logger.LogInformation($"[{nameof(GraphicDesigner)}] Event {nameof(ArticleCreated)}.");
|
||||
var dallEService = _kernel.GetRequiredService<ITextToImageService>();
|
||||
var imageUri = await dallEService.GenerateImageAsync(item.Article, 1024, 1024);
|
||||
|
||||
_state.Data.ImageUrl = imageUri;
|
||||
|
||||
await SendDesignedCreatedEvent(imageUri, item.UserId);
|
||||
}
|
||||
|
||||
private async Task SendDesignedCreatedEvent(string imageUri, string userId)
|
||||
{
|
||||
var graphicDesignEvent = new GraphicDesignCreated
|
||||
{
|
||||
ImageUri = imageUri,
|
||||
UserId = userId
|
||||
}.ToCloudEvent(this.AgentId.Key);
|
||||
|
||||
await PublishEvent(graphicDesignEvent);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// GraphicDesignerPrompts.cs
|
||||
|
||||
namespace Marketing.Agents;
|
||||
|
||||
public static class GraphicDesignerPrompts
|
||||
{
|
||||
public const string GenerateImage = """
|
||||
You are a Marketing community manager graphic designer.
|
||||
Bellow is a campaign that you need to create a image for.
|
||||
Create an image of maximum 500x500 pixels that could be use in social medias as a marketing image.
|
||||
Only answer if the user is asking for an image to be created or if the user is asking for a new campaign
|
||||
Input: {{$input}}
|
||||
""";
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<PackageReference Include="Google.Protobuf" />
|
||||
<PackageReference Include="Grpc.Net.Client" />
|
||||
<PackageReference Include="Grpc.Tools" PrivateAssets="All" />
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Marketing.ServiceDefaults\Marketing.ServiceDefaults.csproj" />
|
||||
<ProjectReference Include="..\Marketing.Shared\Marketing.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,6 @@
|
|||
@Marketing.Agents_HostAddress = http://localhost:5019
|
||||
|
||||
GET {{Marketing.Agents_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Program.cs
|
||||
|
||||
using Marketing.Agents;
|
||||
using Marketing.Shared;
|
||||
using Microsoft.AutoGen.Agents;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.AddServiceDefaults();
|
||||
|
||||
builder.ConfigureSemanticKernel();
|
||||
|
||||
builder.AddAgentWorker(builder.Configuration["AGENT_HOST"]!)
|
||||
.AddAgent<Writer>("writer")
|
||||
.AddAgent<GraphicDesigner>("graphic-designer")
|
||||
.AddAgent<Auditor>("auditor")
|
||||
.AddAgent<CommunityManager>("community-manager");
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.MapDefaultEndpoints();
|
||||
|
||||
app.Run();
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:2285",
|
||||
"sslPort": 44301
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "http://localhost:5019",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:7150;http://localhost:5019",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Writer.cs
|
||||
|
||||
using Marketing.Shared;
|
||||
using Microsoft.SemanticKernel.Memory;
|
||||
using Microsoft.SemanticKernel;
|
||||
using Microsoft.AutoGen.Agents;
|
||||
using Microsoft.AutoGen.Abstractions;
|
||||
|
||||
namespace Marketing.Agents;
|
||||
|
||||
[TopicSubscription("default")]
|
||||
public class Writer(IAgentContext context, Kernel kernel, ISemanticTextMemory memory, [FromKeyedServices("EventTypes")] EventTypes typeRegistry, ILogger<Writer> logger)
|
||||
: SKAiAgent<WriterState>(context, memory, kernel, typeRegistry),
|
||||
IHandle<UserConnected>,
|
||||
IHandle<UserChatInput>,
|
||||
IHandle<AuditorAlert>
|
||||
{
|
||||
public async Task Handle(UserConnected item)
|
||||
{
|
||||
logger.LogInformation($"User Connected: {item.UserId}");
|
||||
string? lastMessage = _state.History.LastOrDefault()?.Message;
|
||||
if (string.IsNullOrWhiteSpace(lastMessage))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await SendArticleCreatedEvent(lastMessage, item.UserId);
|
||||
}
|
||||
|
||||
public async Task Handle(UserChatInput item)
|
||||
{
|
||||
logger.LogInformation($"UserChatInput: {item.UserMessage}");
|
||||
var context = new KernelArguments { ["input"] = AppendChatHistory(item.UserMessage) };
|
||||
var newArticle = await CallFunction(WriterPrompts.Write, context);
|
||||
|
||||
if (newArticle.Contains("NOTFORME", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// TODO: Implement
|
||||
// var agentState = _state.Data.ToAgentState(this.AgentId, "Etag");
|
||||
// await Store("WrittenArticle", newArticle);
|
||||
await SendArticleCreatedEvent(newArticle, item.UserId);
|
||||
}
|
||||
|
||||
public async Task Handle(AuditorAlert item)
|
||||
{
|
||||
logger.LogInformation($"Auditor feedback: {item.AuditorAlertMessage}");
|
||||
var context = new KernelArguments { ["input"] = AppendChatHistory(item.AuditorAlertMessage) };
|
||||
var newArticle = await CallFunction(WriterPrompts.Adjust, context);
|
||||
|
||||
if (newArticle.Contains("NOTFORME", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
return;
|
||||
}
|
||||
await SendArticleCreatedEvent(newArticle, item.UserId);
|
||||
}
|
||||
private async Task SendArticleCreatedEvent(string article, string userId)
|
||||
{
|
||||
var articleCreatedEvent = new ArticleCreated
|
||||
{
|
||||
Article = article,
|
||||
UserId = userId
|
||||
}.ToCloudEvent(this.AgentId.Key);
|
||||
|
||||
var auditTextEvent = new AuditText
|
||||
{
|
||||
Text = "Article written by the Writer: " + article,
|
||||
UserId = userId
|
||||
}.ToCloudEvent(this.AgentId.Key);
|
||||
|
||||
await PublishEvent(articleCreatedEvent);
|
||||
await PublishEvent(auditTextEvent);
|
||||
}
|
||||
|
||||
//protected override Task<RpcResponse> HandleRequest(RpcRequest request) => request.Method switch
|
||||
//{
|
||||
// "GetArticle" => Task.FromResult(new RpcResponse
|
||||
// {
|
||||
// Payload = new Payload
|
||||
// {
|
||||
// DataContentType = "text/plain",
|
||||
// Data = ByteString.CopyFromUtf8(_state.Data.WrittenArticle),
|
||||
// DataType = "text"
|
||||
// }
|
||||
// }),
|
||||
// _ => Task.FromResult(new RpcResponse { Error = $"Unknown method, '{request.Method}'." }),
|
||||
//};
|
||||
|
||||
public Task<string> GetArticle()
|
||||
{
|
||||
return Task.FromResult(_state.Data.WrittenArticle);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// WriterPrompts.cs
|
||||
|
||||
namespace Marketing.Agents;
|
||||
|
||||
public static class WriterPrompts
|
||||
{
|
||||
public const string Write = """
|
||||
This is a multi agent app. You are a Marketing Campaign writer Agent.
|
||||
If the request is not for you, answer with <NOTFORME>.
|
||||
If the request is about writing or modifying an existing campaign, then you should write a campaign based on the user request.
|
||||
Write up to three paragraphs to promote the product the user is asking for.
|
||||
Bellow are a series of inputs from the user that you can use.
|
||||
If the input talks about twitter or images, dismiss it and return <NOTFORME>
|
||||
Input: {{$input}}
|
||||
""";
|
||||
|
||||
public const string Adjust = """
|
||||
This is a multi agent app. You are a Marketing Campaign writer Agent.
|
||||
If the request is not for you, answer with <NOTFORME>.
|
||||
If the request is about writing or modifying an existing campaign, then you should write a campaign based on the user request.
|
||||
The campaign is not compliant with the company policy, and you need to adjust it. This is the message from the automatic auditor agent regarding what is wrong with the original campaign
|
||||
---
|
||||
Input: {{$input}}
|
||||
---
|
||||
Return only the new campaign text but adjusted to the auditor request
|
||||
""";
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsAspireHost>true</IsAspireHost>
|
||||
<UserSecretsId>f0492827-f837-4305-9a7c-29e61abd4788</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspire.Hosting.AppHost" />
|
||||
<PackageReference Include="Aspire.Hosting.Azure.ApplicationInsights" />
|
||||
<PackageReference Include="Aspire.Hosting.Azure.CognitiveServices" />
|
||||
<PackageReference Include="Aspire.Hosting.NodeJs" />
|
||||
<PackageReference Include="Aspire.Hosting.Orleans" />
|
||||
<PackageReference Include="Aspire.Hosting.Qdrant" />
|
||||
<PackageReference Include="Aspire.Hosting.Redis" />
|
||||
<PackageReference Include="Aspire.Hosting.Python" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Marketing.Agents\Marketing.Agents.csproj" />
|
||||
<ProjectReference Include="..\Marketing.AgentHost\Marketing.AgentHost.csproj" />
|
||||
<ProjectReference Include="..\Marketing.Backend\Marketing.Backend.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Program.cs
|
||||
|
||||
var builder = DistributedApplication.CreateBuilder(args);
|
||||
|
||||
builder.AddAzureProvisioning();
|
||||
|
||||
var orleans = builder.AddOrleans("orleans")
|
||||
.WithDevelopmentClustering();
|
||||
|
||||
var agentHost = builder.AddProject<Projects.Marketing_AgentHost>("agenthost")
|
||||
.WithReference(orleans);
|
||||
var agentHostHttps = agentHost.GetEndpoint("https");
|
||||
|
||||
var backend = builder.AddProject<Projects.Marketing_Backend>("backend")
|
||||
.WithEnvironment("AGENT_HOST", $"{agentHostHttps.Property(EndpointProperty.Url)}")
|
||||
.WithEnvironment("OpenAI__Key", builder.Configuration["OpenAI:Key"])
|
||||
.WithEnvironment("OpenAI__Endpoint", builder.Configuration["OpenAI:Endpoint"]);
|
||||
|
||||
builder.AddProject<Projects.Marketing_Agents>("marketing-agents")
|
||||
.WithEnvironment("AGENT_HOST", $"{agentHostHttps.Property(EndpointProperty.Url)}")
|
||||
.WithEnvironment("OpenAI__Key", builder.Configuration["OpenAI:Key"])
|
||||
.WithEnvironment("OpenAI__Endpoint", builder.Configuration["OpenAI:Endpoint"]);
|
||||
|
||||
//var ep = agentHost.GetEndpoint("http");
|
||||
|
||||
//builder.AddPythonProject("python-worker", "../../../../../python/", "./packages/autogen-core/samples/marketing-team/worker.py")
|
||||
// .WithEnvironment("AGENT_HOST", $"{agentHostHttps.Property(EndpointProperty.Host)}:{agentHostHttps.Property(EndpointProperty.Port)}");
|
||||
|
||||
builder.AddNpmApp("frontend", "../Marketing.Frontend", "dev")
|
||||
.WithReference(backend)
|
||||
.WithEnvironment("NEXT_PUBLIC_BACKEND_URI", backend.GetEndpoint("http"))
|
||||
.WithHttpEndpoint(env: "PORT")
|
||||
.WithExternalHttpEndpoints()
|
||||
.PublishAsDockerFile();
|
||||
|
||||
builder.Build().Run();
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:17034;http://localhost:15043",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"DOTNET_ENVIRONMENT": "Development",
|
||||
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21249",
|
||||
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22030"
|
||||
}
|
||||
},
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "http://localhost:15043",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"DOTNET_ENVIRONMENT": "Development",
|
||||
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19105",
|
||||
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20096"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning",
|
||||
"Aspire.Hosting.Dcp": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// SignalRAgent.cs
|
||||
|
||||
using Marketing.Shared;
|
||||
using Microsoft.SemanticKernel.Memory;
|
||||
using Microsoft.SemanticKernel;
|
||||
using Marketing.Backend.Hubs;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Microsoft.AutoGen.Agents;
|
||||
using Microsoft.AutoGen.Abstractions;
|
||||
|
||||
namespace Marketing.Backend.Agents;
|
||||
|
||||
[TopicSubscription("default")]
|
||||
public class SignalRAgent(IAgentContext context, Kernel kernel, ISemanticTextMemory memory, [FromKeyedServices("EventTypes")] EventTypes typeRegistry, ISignalRService signalRClient)
|
||||
: SKAiAgent<Empty>(context, memory, kernel, typeRegistry),
|
||||
IHandle<ArticleCreated>,
|
||||
IHandle<GraphicDesignCreated>,
|
||||
IHandle<SocialMediaPostCreated>,
|
||||
IHandle<AuditorAlert>
|
||||
{
|
||||
public async Task Handle(SocialMediaPostCreated item)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(item);
|
||||
await signalRClient.SendMessageToSpecificClient(item.UserId, item.SocialMediaPost, Hubs.AgentTypes.CommunityManager);
|
||||
}
|
||||
|
||||
public async Task Handle(ArticleCreated item)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(item);
|
||||
await signalRClient.SendMessageToSpecificClient(item.UserId, item.Article, Hubs.AgentTypes.Chat);
|
||||
}
|
||||
|
||||
public async Task Handle(GraphicDesignCreated item)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(item);
|
||||
await signalRClient.SendMessageToSpecificClient(item.UserId, item.ImageUri, Hubs.AgentTypes.GraphicDesigner);
|
||||
}
|
||||
|
||||
public async Task Handle(AuditorAlert item)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(item);
|
||||
await signalRClient.SendMessageToSpecificClient(item.UserId, item.AuditorAlertMessage, Hubs.AgentTypes.Auditor);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// ArticlesController.cs
|
||||
|
||||
using Marketing.Shared;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AutoGen.Agents;
|
||||
using Microsoft.AutoGen.Runtime;
|
||||
|
||||
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
|
||||
namespace Marketing.Backend.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class Articles(AgentWorker client) : ControllerBase
|
||||
{
|
||||
private readonly AgentWorker _client = client;
|
||||
|
||||
//// GET api/<Post>/5
|
||||
//[HttpGet("{id}")]
|
||||
//public async Task<string> Get(string id)
|
||||
//{
|
||||
// var response = await _client.(new AgentId("writer", id), "GetArticle", []);
|
||||
// return response.Payload.Data.ToStringUtf8();
|
||||
//}
|
||||
|
||||
// PUT api/<Post>/5
|
||||
[HttpPut("{UserId}")]
|
||||
public async Task<string> Put(string userId, [FromBody] string userMessage)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(userId);
|
||||
var evt = new UserChatInput
|
||||
{
|
||||
UserId = userId,
|
||||
UserMessage = userMessage,
|
||||
};
|
||||
await _client.PublishEventAsync(evt.ToCloudEvent(userId));
|
||||
|
||||
return $"Task {userId} accepted";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// AgentTypes.cs
|
||||
|
||||
namespace Marketing.Backend.Hubs;
|
||||
|
||||
public enum AgentTypes
|
||||
{
|
||||
Chat,
|
||||
CommunityManager,
|
||||
GraphicDesigner,
|
||||
Auditor,
|
||||
Accountant,
|
||||
Librarian
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// ArticleHub.cs
|
||||
|
||||
using Marketing.Shared;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.AutoGen.Agents;
|
||||
using Microsoft.AutoGen.Runtime;
|
||||
|
||||
namespace Marketing.Backend.Hubs;
|
||||
|
||||
public class ArticleHub(AgentWorker client) : Hub<IArticleHub>
|
||||
{
|
||||
public override async Task OnConnectedAsync()
|
||||
{
|
||||
await base.OnConnectedAsync();
|
||||
}
|
||||
|
||||
public override async Task OnDisconnectedAsync(Exception? exception)
|
||||
{
|
||||
SignalRConnectionsDB.ConnectionIdByUser.TryRemove(Context.ConnectionId, out _);
|
||||
await base.OnDisconnectedAsync(exception);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is called when a new message from the client arrives.
|
||||
/// </summary>
|
||||
/// <param name="frontEndMessage"></param>
|
||||
/// <returns></returns>
|
||||
public async Task ProcessMessage(FrontEndMessage frontEndMessage)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(frontEndMessage);
|
||||
ArgumentNullException.ThrowIfNull(client);
|
||||
|
||||
var evt = new UserChatInput { UserId = frontEndMessage.UserId, UserMessage = frontEndMessage.Message };
|
||||
|
||||
await client.PublishEventAsync(evt.ToCloudEvent(frontEndMessage.UserId));
|
||||
}
|
||||
|
||||
public async Task ConnectToAgent(string userId)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(userId);
|
||||
ArgumentNullException.ThrowIfNull(client);
|
||||
|
||||
var frontEndMessage = new FrontEndMessage()
|
||||
{
|
||||
UserId = userId,
|
||||
Message = "Connected to agents",
|
||||
Agent = AgentTypes.Chat.ToString()
|
||||
};
|
||||
|
||||
SignalRConnectionsDB.ConnectionIdByUser.AddOrUpdate(userId, Context.ConnectionId, (key, oldValue) => Context.ConnectionId);
|
||||
|
||||
// Notify the agents that a new user got connected.
|
||||
var data = new Dictionary<string, string>
|
||||
{
|
||||
["UserId"] = frontEndMessage.UserId,
|
||||
["userMessage"] = frontEndMessage.Message,
|
||||
};
|
||||
var evt = new UserConnected { UserId = userId };
|
||||
await client.PublishEventAsync(evt.ToCloudEvent(userId));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// FrontEndMessage.cs
|
||||
|
||||
namespace Marketing.Backend.Hubs;
|
||||
|
||||
public class FrontEndMessage
|
||||
{
|
||||
public required string UserId { get; set; }
|
||||
public required string Message { get; set; }
|
||||
public required string Agent { get; set; }
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// IArticleHub.cs
|
||||
|
||||
namespace Marketing.Backend.Hubs;
|
||||
|
||||
public interface IArticleHub
|
||||
{
|
||||
public Task ConnectToAgent(string UserId);
|
||||
|
||||
public Task ChatMessage(FrontEndMessage frontEndMessage);
|
||||
|
||||
public Task SendMessageToSpecificClient(string userId, string message);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue