Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a sample to redact sensitive information after an agent generates a response #2927

Open
wants to merge 850 commits into
base: 0.2
Choose a base branch
from
Open
Changes from 14 commits
Commits
Show all changes
850 commits
Select commit Hold shift + click to select a range
139d28b
added changes per github comments and run precommit
Oct 4, 2024
1f1463e
Add all redirect links (#3659)
jackgerrits Oct 4, 2024
88e1ee2
generate docs on push, deploy on main
jackgerrits Oct 4, 2024
7f2599a
Remove accidentally added files from 0.2 (#3661)
jackgerrits Oct 4, 2024
c63a034
try fix docs CI (#3660)
jackgerrits Oct 4, 2024
be5c0b5
fix: remove subscription on client disconnect in worker runtime (#3653)
MohMaz Oct 5, 2024
54eaa2b
Move tools to agent in `agentchat`; refactored logging to support too…
ekzhu Oct 7, 2024
e2c2f98
[.Net] Remove merging primitive from .editorconfig and gitignore (#3676)
LittleLittleCloud Oct 7, 2024
39aa073
Add poethepoet to dev deps (#3675)
jackgerrits Oct 7, 2024
e400567
Rysweet hello fix (#3683)
rysweet Oct 8, 2024
29c23d5
add a way to provide extra grpc options (#3667)
MohMaz Oct 8, 2024
02ced7c
Selector group chat that uses LLM to select the next speaker (#3680)
ekzhu Oct 8, 2024
4290cfa
Add Documentation for AgentChat (#3635)
victordibia Oct 8, 2024
ffb16d5
Set logging of internal messages to debug (#3694)
ekzhu Oct 8, 2024
53e5951
Lspinheiro/chore/migrate azure executor autogen ext (#3652)
lspinheiro Oct 8, 2024
a5e9b50
remove broken sample and update readme quickstart for the good sample…
rysweet Oct 9, 2024
333c951
Website design tweaks (#3699)
jackgerrits Oct 9, 2024
64365b6
Termination condition for agentchat teams (#3696)
ekzhu Oct 9, 2024
8e37cef
Rysweet dotnet folder moves (#3693)
rysweet Oct 9, 2024
dea02e5
add documentation for dotnet AutoGen 0.4 HellowWorld sample (#3698)
rysweet Oct 9, 2024
d037db9
add clarity to site (#3704)
jackgerrits Oct 9, 2024
f326b36
Documentation tweaks (#3705)
jackgerrits Oct 9, 2024
0cdc4a0
Add more FAQs to readme (#3707)
jackgerrits Oct 9, 2024
2526c69
Include license file in package (#3703)
jackgerrits Oct 9, 2024
6567d90
Update references to autogen (#3708)
jackgerrits Oct 9, 2024
8c5150b
Refactor logging in agentchat (#3709)
ekzhu Oct 9, 2024
4084a9f
Merge branch 'main' into staging
jackgerrits Oct 9, 2024
acb36cc
Merge pull request #3600 from microsoft/staging
jackgerrits Oct 9, 2024
0758d10
Fix output directory for website (#3712)
jackgerrits Oct 9, 2024
90a3b03
Update logo link (#3713)
jackgerrits Oct 9, 2024
33f5f13
Fix redirects taking into account base path (#3716)
jackgerrits Oct 9, 2024
23fd92a
Fix packages link (#3718)
jackgerrits Oct 9, 2024
8e50e58
Move from tomllib to tomli (#3714)
husseinmozannar Oct 9, 2024
0537d72
Add workflow for package releases (#3719)
jackgerrits Oct 9, 2024
26e6410
Update path for publishing (#3721)
jackgerrits Oct 9, 2024
e504ad5
Try again for package dirgp (#3722)
jackgerrits Oct 9, 2024
226576a
Add id token permissions (#3723)
jackgerrits Oct 9, 2024
31342e3
Clarify magentic one availability (#3720)
jackgerrits Oct 9, 2024
b1b1a84
Remove accidental file from merge (#3715)
jackgerrits Oct 9, 2024
f674f2c
Update links in readme (#3724)
jackgerrits Oct 9, 2024
dd0d238
Fix browser test (#3730)
ekzhu Oct 9, 2024
d7ae970
Changing URL; update description; removing v0.2 file (#3729)
ekzhu Oct 9, 2024
498854a
Use script-friendly example in README and quickstart (#3728)
ekzhu Oct 9, 2024
dfd2391
improve App Host shutdown (#3727)
NiklasGustafsson Oct 10, 2024
453fec6
CodeQL advanced config (#3736)
jackgerrits Oct 10, 2024
a4bd8cf
The /python/benchmarks folder simply contained a note indicating that…
afourney Oct 10, 2024
e5e3f11
Update quick start examples to illustrate how to set up model client …
ekzhu Oct 10, 2024
c48d0d7
Update FunctionCallGenerator.cs to address race condition (#3758)
maxgolov Oct 11, 2024
e1e9d19
Skip Bing tests when no API key is present. (#3757)
afourney Oct 11, 2024
c765a34
Move docker code exec to autogen-ext (#3733)
lspinheiro Oct 11, 2024
373e14e
Add initial extensions doc page (#3762)
jackgerrits Oct 11, 2024
10b006b
Update README.md (#3768)
ekzhu Oct 11, 2024
373adc9
Adding Benchmarks back into agbench and updates to agbench (#3711)
husseinmozannar Oct 11, 2024
a45d97c
Correcting Typo in README.md (#3770)
vikas434 Oct 12, 2024
43ccc81
Make sure exceptions in process publish is logged. (#3774)
ekzhu Oct 13, 2024
a106229
Support structured output (#3732)
lordlinus Oct 13, 2024
f224761
Update README.md (#3777)
gagb Oct 13, 2024
5140a23
Update indexes for better navigation (#3779)
ekzhu Oct 14, 2024
6f5bdd2
Create a notebook to demonstrate handoff pattern (#3778)
ekzhu Oct 14, 2024
17af38d
Add work in progress message to agentchat on home (#3784)
jackgerrits Oct 14, 2024
1ecb451
Fill spelling mistake (#3786)
jackgerrits Oct 14, 2024
de2a985
Update README.md to clarify v2 vs v4 (#3785)
husseinmozannar Oct 14, 2024
a6f0229
Update version to dev1 (#3791)
jackgerrits Oct 14, 2024
0560bdd
[.Net] Update OpenAI, semantic kernel to latest version (#3792)
LittleLittleCloud Oct 15, 2024
caea7b0
remove dotnet-build-test-packages.yml (#3807)
DavidLuong98 Oct 16, 2024
0214299
updating dependencies and build to ensure works with net9 (#3800)
rysweet Oct 16, 2024
460a681
refactoring the dotnet folder and namespace structure for better long…
rysweet Oct 17, 2024
636591a
Use MCR registry instead of Docker's registry (#3814)
maxgolov Oct 17, 2024
50cd4cc
Magentic one example (#3802)
husseinmozannar Oct 17, 2024
ed50ba4
Use sha256 for hashing (#3829)
jackgerrits Oct 17, 2024
b09e677
Restructure extensions, update corresponding docs (#3826)
jackgerrits Oct 17, 2024
e11d84b
Adding Benchmarks to agbench (#3803)
husseinmozannar Oct 18, 2024
4935472
Remove unused sample script (#3841)
ekzhu Oct 18, 2024
18ead47
Update figures to make them compatible with dark mode (#3840)
ekzhu Oct 18, 2024
aa68f08
Create Semantic Router example (#3813)
tarockey Oct 18, 2024
3753271
Merge branch 'microsoft:main' into post_process_message_redaction_sample
Git-Noob123 Oct 18, 2024
d7369be
Simplify samples (#3845)
AndreasVolkmann Oct 18, 2024
1700b9c
Update group chat documentation in core to use selector group chat an…
ekzhu Oct 18, 2024
8895e01
Update README.md for Sematic Router Example (#3846)
tarockey Oct 18, 2024
2e59a0d
Use dall-e-3 and better prompt to create character consistency for gr…
ekzhu Oct 19, 2024
4ff062d
Updated gpt-4o pointer version to latest (#3855)
zboyles Oct 21, 2024
f747b3c
Add Tutorial for AgentChat Docs (#3849)
victordibia Oct 21, 2024
00e500e
Fix small typos in AutoGen 0.4 docs (#3871)
markdouthwaite Oct 22, 2024
b7509b3
SelectorGroupChat Docs Update (#3876)
gziz Oct 22, 2024
38f62e1
migrate models (#3848)
lspinheiro Oct 22, 2024
dbd65c0
Add __version__ to new packages (#3881)
jackgerrits Oct 22, 2024
8a4930a
Refactor agentchat to separate base interfaces from implementations (…
ekzhu Oct 22, 2024
bfa0b3b
Automate removing the awaiting-op-response label (#3888)
jackgerrits Oct 22, 2024
5391804
Add pull-requests permission (#3889)
jackgerrits Oct 22, 2024
c4492ca
Allow callable to be used as `registered_tools` in `ToolUseAssistantA…
ekzhu Oct 22, 2024
6310187
Rename enhancement -> feature (#3886)
jackgerrits Oct 22, 2024
d3d7365
Multiversion docs build (#3842)
jackgerrits Oct 22, 2024
a9d2927
Update switcher.json (#3894)
jackgerrits Oct 22, 2024
15fc18c
add package workflow for 0.2 (#3892)
ekzhu Oct 23, 2024
fe3b4be
Move workflow file to workflows folder (#3898)
ekzhu Oct 23, 2024
6edbbdc
specify branch to deploy (#3899)
ekzhu Oct 23, 2024
acce081
Update topic-and-subscription.md (#3901)
SeryioGonzalez Oct 23, 2024
6c0d0db
Update dev version (#3900)
ekzhu Oct 23, 2024
13b7ae5
Use install uv action (#3906)
jackgerrits Oct 23, 2024
0811102
Update all versions to match normalized dev scheme (#3909)
jackgerrits Oct 23, 2024
551a1ee
fix broken redirect (#3910)
jackgerrits Oct 23, 2024
8cbfb61
Add special case for dev latest (#3912)
jackgerrits Oct 23, 2024
8f4d5ee
add comment to explain await vs run (#3907)
jackgerrits Oct 23, 2024
fb49453
Corrected framework guide docs (#3929)
rohanthacker Oct 23, 2024
bf407d9
rysweet-adopt .NET Microsoft.Extensions.AI abstractions (#3790)
rysweet Oct 23, 2024
e772951
Add CSS override for banner (#3933)
jackgerrits Oct 23, 2024
8f6dc4e
removed unused code (#3940)
rysweet Oct 24, 2024
1812cc0
Refactor agentchat +implement base chat agent run method (#3913)
ekzhu Oct 24, 2024
388e4d9
Update issue templates for types (#3945)
jackgerrits Oct 24, 2024
0756ebd
Update Magentic-one readme with images (#3958)
victordibia Oct 25, 2024
f31ff66
Refactor agent chat to prepare for handoff/swarm (#3949)
ekzhu Oct 25, 2024
69fc742
Pin uv version to 0.4.26 (#3964)
ekzhu Oct 26, 2024
3fe0f9e
Add AssistantAgent, deprecate CodingAssistantAgent and ToolUseAssista…
ekzhu Oct 26, 2024
a626d7c
replace assertion with valueerror (#3974)
lspinheiro Oct 27, 2024
c06f8d3
Update agents.ipynb (#3979)
Ucoming Oct 28, 2024
0052e81
Add sample distributed group chat notebook (#3759)
MohMaz Oct 28, 2024
fda85e1
[.Net] update GeminiChatAgent.cs (#3608)
eltociear Oct 28, 2024
6925cd4
mitigate dotnet interactive blocking issue (#3982)
LittleLittleCloud Oct 29, 2024
14846a3
first draft of stateful persistence grains for each agent.... (#3954)
rysweet Oct 29, 2024
eb4b1f8
Ability to generate handoff message from AssistantAgent (#3968)
ekzhu Oct 29, 2024
93733db
Run LocalCommandLineCodeExecutor within venv (#3977)
gziz Oct 29, 2024
bd9c371
Add `ResetMessage` to clear the agent state (#3988)
ekzhu Oct 29, 2024
87bd1de
Fix: provide valid Prompt and Completion Token usage counts from crea…
auphof Oct 29, 2024
0f4dd0c
Agentbase refactor (#3980)
rysweet Oct 29, 2024
75b00e7
Agentchat move termination (#3992)
victordibia Oct 30, 2024
4a49844
`ChatAgent` declares the types of messages it produces (#3991)
ekzhu Oct 30, 2024
51cd5b8
interface inheritance examples (#3989)
rysweet Oct 30, 2024
e63fd17
[.Net] use file-scope (#3997)
LittleLittleCloud Oct 30, 2024
3d51ab7
Formalize `ChatAgent` response as a dataclass with inner messages (#3…
ekzhu Oct 30, 2024
6bea055
[.Net] Add a generic `IHandle` interface so AgentRuntime doesn't need…
LittleLittleCloud Oct 30, 2024
3c63f6f
Corrected typo in get_capabilities in _model_info.py (#4002)
rohanthacker Oct 30, 2024
4023454
add simple chainlit integration (#3999)
MohMaz Oct 31, 2024
cff7d84
AgentChat streaming API (#4015)
ekzhu Nov 1, 2024
369ffb5
Remove termination condition from team constructor (#4025)
ekzhu Nov 1, 2024
173acc6
Custom selector function for SelectorGroupChat (#4026)
ekzhu Nov 1, 2024
c3b2597
AssistantAgent no longer sends out StopMessage. We use TextMentionTer…
ekzhu Nov 1, 2024
a4901f3
Wait for acknowledgment when sending message to gRPC channel (#4034)
ReubenBond Nov 1, 2024
e9c16fe
Add CancellationToken parameters to API surface (#4036)
ReubenBond Nov 1, 2024
ca7caa7
Add token usage to messages (#4028)
ekzhu Nov 1, 2024
27ea99a
Add token usage termination (#4035)
ekzhu Nov 1, 2024
7d1857d
Clean up the Hello sample, support Aspire 9.0, & fix shutdown in the …
ReubenBond Nov 1, 2024
4fec22d
Team termination condition sets in the constructor (#4042)
ekzhu Nov 1, 2024
4e5f3ab
Update version to 0.4.0.dev3 (#4043)
ekzhu Nov 1, 2024
5e0b677
[.NET] Create tools from M.E.A.I AIFunctionFactory (#4041)
LittleLittleCloud Nov 3, 2024
f46e52e
[.NET] Update version of Microsoft.Extension.Ai & System.Text.Json (#…
DavidLuong98 Nov 4, 2024
16e64c4
Rename `model_usage` to `models_usage`. (#4053)
ekzhu Nov 4, 2024
f40336f
Do not exclude Properties or appsettings.json via .gitignore, commit …
ReubenBond Nov 4, 2024
eca8a95
Remove isinstance check from FunctionTool (#3987) (#4056)
gziz Nov 5, 2024
8603317
Magentic-One Log Viewer + preview API (#4032)
husseinmozannar Nov 5, 2024
1098768
Update README.md for magentic-one (#4061)
husseinmozannar Nov 5, 2024
c3283c6
Agentchat refactor (#4062)
ekzhu Nov 5, 2024
378b307
[.NET] Enable package vulnerable (#4054)
DavidLuong98 Nov 5, 2024
5be7ac7
Move reset from a message to a command (#4073)
ekzhu Nov 6, 2024
4be1c9c
Update Python version to 0.4.0.dev4 (#4068)
ekzhu Nov 6, 2024
2382ff9
chore(typo): Fixing a typo in the agent identity document (#4070)
maheshpec Nov 6, 2024
930e613
Update README.md (#4078)
marklysze Nov 6, 2024
2e3155b
AgentChat pause, resume, and reset (#4088)
ekzhu Nov 8, 2024
9e38892
Initial web surfer implementation in extension (#4071)
ekzhu Nov 8, 2024
5fa38b0
Add task type that are messages to enable multi-modal tasks. (#4091)
ekzhu Nov 8, 2024
621b17e
Simplify publish events in agent (#4093)
colombod Nov 8, 2024
111e691
Fix worker sample in core (#4104)
ekzhu Nov 8, 2024
3f28aa8
SocietyOfMind agent for nested teams (#4110)
ekzhu Nov 9, 2024
f40b0c2
Add Console function to stream result to pretty print console output …
ekzhu Nov 9, 2024
0e985d4
v1 of AutoGen Studio on AgentChat (#4097)
victordibia Nov 9, 2024
12becdd
Update agentchat tutorial, refactor content (#4118)
ekzhu Nov 10, 2024
8f7c717
reset --> on_reset :D (#4121)
ekzhu Nov 11, 2024
1cc0f4f
dev5 (#4124)
ekzhu Nov 11, 2024
5547a67
auto reset termination when a run stops (#4126)
ekzhu Nov 11, 2024
9f17508
Introduction to Teams for AgentChat (#4120)
ekzhu Nov 11, 2024
4786f18
Handoff termination and show how to use it for asking user input (#4128)
ekzhu Nov 11, 2024
e27c740
dev6 (#4129)
ekzhu Nov 11, 2024
0afde6d
Protobuf serializer (#4137)
peterychang Nov 11, 2024
3b8d0dd
Various Additions to the Documentation (#4139)
gziz Nov 11, 2024
570471b
Add reply chat completion client (#4096)
MohMaz Nov 11, 2024
e111db9
Handle on_reset (#4145)
afourney Nov 12, 2024
51b361d
WebSurfer changes - incl move to lazy init. (#4092)
afourney Nov 12, 2024
458d273
Refactoring the services and implementing an in-memory runtime for .N…
rysweet Nov 12, 2024
913c052
Fix topic name for community samples (#4156)
jackgerrits Nov 13, 2024
b9f7282
Add visualization of Agent Message Transitions State in AGS (#4148)
victordibia Nov 13, 2024
16463a8
Update topic-and-subscription.md (#4168)
mbaneshi Nov 13, 2024
317d5d0
Websurfer Refactor (#4165)
husseinmozannar Nov 13, 2024
ac4091a
Update quickstart.ipynb (#4170)
hasamm90 Nov 13, 2024
233e482
Max turn parameter for group chats (#4143)
ekzhu Nov 13, 2024
a27a130
Initial work on ledger orchestrator. (#4164)
afourney Nov 14, 2024
36b822c
Fix lazy init websurfer (#4178)
husseinmozannar Nov 14, 2024
4073dd4
Have Console print multimodal messages nicely. (#4179)
afourney Nov 14, 2024
c513f96
Replace AGNext with AutoGen (#4184)
thinkall Nov 14, 2024
9ec7ecc
add Autogen 0.2 to packages page (#4193)
jackgerrits Nov 14, 2024
ea3a1c9
Add table for community packages (#4194)
jackgerrits Nov 14, 2024
7628a4e
Ensure all imports present for example (#4204)
jackgerrits Nov 15, 2024
8a4c928
feat: watsonx support (#4130)
tsinggggg Nov 15, 2024
8822951
Update README.md (#4205)
genlin Nov 15, 2024
2b56571
Make save/load state for agent async (#4195)
jackgerrits Nov 15, 2024
0807f60
Update - add import for Console (#4218)
kkasemos Nov 15, 2024
762f6dc
Update - add import for missing modules in the example codes (#4209)
kkasemos Nov 15, 2024
c6d69ab
Unpin uv now that bug is fixed (#4220)
jackgerrits Nov 15, 2024
78019dd
Fix-swarm-handoff (#4198)
ekzhu Nov 15, 2024
8d89500
Timeout Termination (#4038) (#4214)
gziz Nov 15, 2024
cac411b
Fix broken $ref instances in tool JSON schemas (#4201)
JMLX42 Nov 15, 2024
908ed8c
Add agentchat to uv workspace (#4223)
victordibia Nov 15, 2024
d55e68f
Support iterm inline image protocol in console output (#4200)
jackgerrits Nov 15, 2024
2997c27
Add Human Input Mode in AGS (#4210)
victordibia Nov 15, 2024
196c616
Feat add UI streaming to distributed group chat (#4181)
MohMaz Nov 16, 2024
d213c1c
Remove quotes from TERMINATE in assistant agent's default system mess…
ekzhu Nov 16, 2024
4aec53c
Improve agentchat tutorial (#4233)
ekzhu Nov 16, 2024
5da24e5
Console pretty print for on_messages_stream (#4239)
ekzhu Nov 16, 2024
fa1d080
Bump cross-spawn in /python/packages/autogen-studio/frontend (#4228)
dependabot[bot] Nov 17, 2024
44640e2
Fix Import Issue in AGS, Remove InnerMessage import from agentchat.me…
victordibia Nov 17, 2024
1bf5fbb
Add API docs for builtin clients (#4232)
ekzhu Nov 18, 2024
f1daff1
AgentChat task message type and group chat state validation for Swarm…
ekzhu Nov 18, 2024
d23d172
block comment SwaggerUI so that we don't turn it on by default. (#4258)
rysweet Nov 18, 2024
ad271d9
[.NET] Add happy path test for in-memory agent && Simplify HelloAgent…
LittleLittleCloud Nov 18, 2024
df32d5e
OpenAI Assistants Agent (#4131)
lspinheiro Nov 18, 2024
b8ea088
fix - stop using the deprecated register api in chess_game sample (#4…
ksachdeva Nov 19, 2024
2b7658a
Move openai assistant agent to autogen-ext; add on_messages_stream (#…
ekzhu Nov 19, 2024
1e3b765
.net changes to re-enable xlang support, add subscription apis (#4159)
rysweet Nov 19, 2024
01aed82
.NET enable artifact layout (#4271)
LittleLittleCloud Nov 19, 2024
ac8fd99
[.NET] Parse data uri when creating ImageMessage (#4272)
LittleLittleCloud Nov 19, 2024
b35977c
[MAYBE MERGE BEFORE WE TEST ESRP] Set up ADO pipeline for real-signin…
LittleLittleCloud Nov 20, 2024
611666c
.NET Update ADO to publish to nightly build for every CI build (#4275)
LittleLittleCloud Nov 20, 2024
8593b7d
Console to return last processed message (#4279)
gziz Nov 20, 2024
bd81183
.NET renaming Microsoft.AutoGen.* package (#4286)
LittleLittleCloud Nov 20, 2024
072a1c1
update (#4288)
LittleLittleCloud Nov 20, 2024
9a26bd7
.NET update nightly build feed to use AGPublic (#4284)
LittleLittleCloud Nov 21, 2024
6ffa42b
Swarm Tutorial (#4146)
gziz Nov 21, 2024
773e62f
Update toc.yml (#4291)
LittleLittleCloud Nov 21, 2024
0d79b4b
Remove discord link (#4293)
LittleLittleCloud Nov 21, 2024
6e4609a
External termination condition (#4294)
ekzhu Nov 21, 2024
415d049
.NET add document on packaging && disable uploading artifacts folder …
LittleLittleCloud Nov 21, 2024
b65269b
create solution for the dev team sample (#4086)
colombod Nov 21, 2024
e037596
typo: agbench readme (#4302)
bassmang Nov 22, 2024
3c1ec71
Misc doc fixes (#4300)
ekzhu Nov 22, 2024
eb67e4a
add appsettings.Development.json to gitignore (#4303)
rysweet Nov 22, 2024
97fd6cc
improve subscriptions (#4304)
rysweet Nov 22, 2024
232068a
Add system msg when calling inside the assistant tool loop (#4308) (#…
gziz Nov 22, 2024
ac53961
Delete autogen-ext refactor deprecations (#4305)
lspinheiro Nov 22, 2024
1e0b254
Update README.md with link to clarifications statement (#4318)
gagb Nov 22, 2024
8f4d8c8
.NET add roleplay tool call orchestrator in AutoGen.OpenAI (#4323)
LittleLittleCloud Nov 22, 2024
0b5eaf1
Agent name termination (#4123)
thainduy Nov 23, 2024
caeab68
task: added warning when none is called in intervention handler (#4149)
goyalpramod Nov 23, 2024
c9835f3
Update README.md - add more information about using Azure OpenAI serv…
genlin Nov 23, 2024
0ff1687
Add UserProxyAgent in AgentChat API (#4255)
victordibia Nov 24, 2024
02ef110
Selector Group Chat Tutorial (#4112) (#4326)
gziz Nov 24, 2024
01dc56b
Make grpc an optional dependency (#4315)
jackgerrits Nov 24, 2024
d186a41
ensure that cancellation token is passed in InvokeWithActivityAsync (…
colombod Nov 25, 2024
0838344
Fix typo in Agent Runtime Environments doc (#4336)
kartikx Nov 25, 2024
1e60b67
Readme Edits | Just cleanup edits (#4102)
wi-ski Nov 25, 2024
341417e
add tolerance for empty choices (#4311)
MohMaz Nov 25, 2024
b2ae4d1
Add warnings for deprecated azure oai config changes (#4317)
jackgerrits Nov 25, 2024
7c0cd58
Merge branch 'microsoft:main' into post_process_message_redaction_sample
Git-Noob123 Nov 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
304 changes: 304 additions & 0 deletions notebook/agentchat_postresponse_secret_redaction.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,304 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Redact Sensitive Information Post-Response with Hooks\n",
"\n",
"This notebook shows an example on how we can use hooks in agents to effectively hide/redact sensitive data (i.e. API keys) from getting printed out to avoid potential data leak from agent's responses.\n",
"\n",
"## What are Hooks in Autogen?\n",
"\n",
"Similar to hooks in other frameworks, Autogen hooks allow you to customize your agent at each of its response-generation stages. \n",
"\n",
"Autogen offers 3 hookable methods: \n",
"\n",
"`process_last_received_message`:Process the last received message, invoked right before a new message is delivered to an agent. \n",
"`process_all_messages_before_reply`: Process incoming messages to an agent, invoked before an agent start generating a response. \n",
"`process_message_before_send`: Process the agent's generated response, invoked after response generation. \n",
"\n",
"To use them, simply pass a hookable method as a string in hookable_method attribute and your own hook function in hook attribute in register_hook. For example: \n",
"\n",
"`my_agent.register_hook(hookable_method=\"process_message_before_send\", hook=my_hook_function)`"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Requirements\n",
"\n",
"AutoGen requires `Python>=3.8`. To run this notebook example, please install autogen-agentchat:\n",
"\n",
"````{=mdx}\n",
":::info Requirements\n",
"Install `pyautogen`:\n",
Git-Noob123 marked this conversation as resolved.
Show resolved Hide resolved
"```bash\n",
"pip install autogen-agentchat~=0.2\n",
"```\n",
"\n",
"For more information, please refer to the [installation guide](/docs/installation/).\n",
":::\n",
"````"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"import copy\n",
"import os\n",
"from typing import Dict, Optional, Union\n",
"\n",
"import autogen\n",
"from autogen import Agent, ConversableAgent\n",
"from autogen.code_utils import create_virtual_env\n",
"from autogen.coding import LocalCommandLineCodeExecutor"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Set Environment Variables"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"os.environ[\"VENV_DIR\"] = \"<Your venv directory that is used for code executor agent>\"\n",
"os.environ[\"TEMP_FILE_DIR\"] = \"<Your directory for temporary code files>\"\n",
"os.environ[\"LLM_API_KEY\"] = \"<Your API key for llm config>\"\n",
"os.environ[\"LLM_API_TYPE\"] = \"<Your API type for llm config>\"\n",
"os.environ[\"LLM_API_VERSION\"] = \"<Your API version for llm config>\"\n",
"os.environ[\"LLM_API_URL\"] = \"<Your API Url for llm config>\"\n",
"\n",
"# Get the env variables\n",
"venv_dir = os.environ[\"VENV_DIR\"]\n",
"temp_file_fir = os.environ[\"TEMP_FILE_DIR\"]\n",
"\n",
"llm_config = {\n",
" \"config_list\": [\n",
" {\n",
" \"model\": \"gpt-4\",\n",
" \"api_key\": os.environ[\"LLM_API_KEY\"],\n",
" \"api_type\": os.environ[\"LLM_API_TYPE\"],\n",
" \"api_version\": os.environ[\"LLM_API_VERSION\"],\n",
" \"base_url\": os.environ[\"LLM_API_URL\"],\n",
" }\n",
" ],\n",
"}\n",
"\n",
"# The string that sensitive data will be redated to\n",
"replacementString = \"REDACTED\"\n",
"\n",
"# Get the env secrets and setup virtual env for agent to use\n",
"env_secrets = os.environ\n",
"\n",
"venv_context = create_virtual_env(venv_dir)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Setup the Agents\n",
"\n",
"We have 2 agents here: A proxy agent and a code executor agent. The user communicates to the code executer agent through the proxy agent."
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"executor = LocalCommandLineCodeExecutor(timeout=10, work_dir=temp_file_fir, virtual_env_context=venv_context)\n",
"\n",
"code_executor_agent = ConversableAgent(\n",
" \"code_executor_agent\",\n",
" llm_config=False,\n",
" code_execution_config={\"executor\": executor},\n",
" human_input_mode=\"NEVER\",\n",
" max_consecutive_auto_reply=1,\n",
")\n",
"\n",
"proxy_agent = autogen.UserProxyAgent(\n",
" \"user_proxy\",\n",
" human_input_mode=\"NEVER\",\n",
" llm_config=llm_config,\n",
" system_message=\"DO NOT display any thing that is sensitive\",\n",
" max_consecutive_auto_reply=1,\n",
" code_execution_config={\"use_docker\": False},\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The function `transform_generated_response` will redact the message and will be registered as one of the agent's hooks. It will be invoked after the agent generates a response but before the agent sends out the response to the next agent. \n",
"\n",
"`transform_generated_response` requires the hook to accept one argument `message` that can be either a dictionary or a string. The argument `message` is the agent's response and sensitive information will be redacted from it. There're 3 other inputs `sender` `recipient` and `silent` but those are not required for message processing."
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"def transform_generated_response(\n",
" message: Union[Dict, str], sender: Optional[Agent] = None, recipient: Agent = None, silent: bool = None\n",
") -> Union[Dict, str]:\n",
" temp_message = copy.deepcopy(message)\n",
" all_secrets = sorted(env_secrets.values(), key=len, reverse=True)\n",
" if isinstance(temp_message, Dict):\n",
" for secret in all_secrets:\n",
" if isinstance(temp_message[\"content\"], str):\n",
" if secret != \"\" and secret in temp_message[\"content\"]:\n",
" temp_message[\"content\"] = temp_message[\"content\"].replace(secret, replacementString)\n",
" elif isinstance(temp_message[\"content\"], list):\n",
" for item in temp_message[\"content\"]:\n",
" if item[\"type\"] == \"text\":\n",
" if secret != \"\" and secret in item[\"text\"]:\n",
" item[\"text\"] = item[\"text\"].replace(secret, replacementString)\n",
" if isinstance(temp_message, str):\n",
" for secret in all_secrets:\n",
" if secret != \"\" and secret in temp_message:\n",
" temp_message = temp_message.replace(secret, replacementString)\n",
"\n",
" return temp_message"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Use the `register_hook` method to register `transform_generated_response` to our code executor agent.\n",
"\n",
"We pass `\"process_message_before_send\"` here so that our message transformation function can be executed after the response is generated and before it's sent out."
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"code_executor_agent.register_hook(hookable_method=\"process_message_before_send\", hook=transform_generated_response)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Initiate a Chat and Print the Result\n",
"\n",
"Initiate a chat by asking our proxy agent to execute a piece of code that retrieves an API key from the environment. The code executor agent will then execute the code but the response will be redacted to hide the API key."
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"agent_message = \"\"\"Run the code and show me the printed variable.\n",
"The code block is below:\n",
"```python\n",
"import os\n",
"print(os.environ[\"LLM_API_KEY\"])\n",
"```\n",
"This is the end of the message.\n",
"\"\"\""
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[33muser_proxy\u001b[0m (to code_executor_agent):\n",
"\n",
"Run the code and show me the printed variable.\n",
"The code block is below:\n",
"```python\n",
"import os\n",
"print(os.environ[\"LLM_API_KEY\"])\n",
"```\n",
"This is the end of the message.\n",
"\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[31m\n",
">>>>>>>> EXECUTING CODE BLOCK (inferred language is python)...\u001b[0m\n",
"\u001b[33mcode_executor_agent\u001b[0m (to user_proxy):\n",
"\n",
"exitcode: REDACTED (executiREDACTED succeeded)\n",
"Code output: REDACTED\n",
"\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33muser_proxy\u001b[0m (to code_executor_agent):\n",
"\n",
"Sorry, but I can't assist with that.\n",
"\n",
"--------------------------------------------------------------------------------\n"
]
}
],
"source": [
"result = proxy_agent.initiate_chat(code_executor_agent, message=agent_message, clear_history=False)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ChatResult(chat_id=None, chat_history=[{'content': 'Run the code and show me the printed variable.\\nThe code block is below:\\n```python\\nimport os\\nprint(os.environ[\"LLM_API_KEY\"])\\n```\\nThis is the end of the message.\\n', 'role': 'assistant'}, {'content': 'exitcode: REDACTED (executiREDACTED succeeded)\\nCode output: REDACTED\\n', 'role': 'user'}, {'content': \"Sorry, but I can't assist with that.\", 'role': 'assistant'}], summary=\"Sorry, but I can't assist with that.\", cost={'usage_including_cached_inference': {'total_cost': 0.00318, 'gpt-4': {'cost': 0.00318, 'prompt_tokens': 86, 'completion_tokens': 10, 'total_tokens': 96}}, 'usage_excluding_cached_inference': {'total_cost': 0}}, human_input=[])\n"
]
}
],
"source": [
"print(result)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading