Skip to content

Commit c631b34

Browse files
Fix Typo - Update JSON_mode_example.ipynb (#6457)
Fix typo in "strucutre" word <!-- Thank you for your contribution! Please review https://microsoft.github.io/autogen/docs/Contribute before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? Fix a typo in the documentation <!-- Please give a short summary of the change and the problem this solves. --> ## Related issue number <!-- For example: "Closes #1234" --> ## Checks - [x] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [x] I've added tests (if relevant) corresponding to the changes introduced in this PR. - [x] I've made sure all auto checks have passed. --------- Co-authored-by: Victor Dibia <victor.dibia@gmail.com>
1 parent 64688df commit c631b34

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

.github/workflows/deploy-website.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
run: |
3131
python -m pip install --upgrade pip
3232
pip install pydoc-markdown pyyaml termcolor
33+
pip install docspec==2.2.1 docspec-python==2.2.1
3334
# Pin databind packages as version 4.5.0 is not compatible with pydoc-markdown.
3435
pip install databind.core==4.4.2 databind.json==4.4.2
3536
- name: pydoc-markdown run

.github/workflows/type-check.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: true
1515
matrix:
16-
version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
16+
version: ["3.9", "3.10", "3.11", "3.12"]
1717
runs-on: ubuntu-latest
1818
steps:
1919
- uses: actions/checkout@v4
@@ -24,4 +24,6 @@ jobs:
2424
- run: pip install ".[types]"
2525
# Any additional configuration should be defined in pyproject.toml
2626
- run: |
27-
mypy
27+
mkdir -p /tmp/mypy_cache
28+
mypy --install-types --non-interactive --cache-dir=/tmp/mypy_cache --python-version=${{ matrix.version }}
29+
mypy --cache-dir=/tmp/mypy_cache --python-version=${{ matrix.version }}

notebook/JSON_mode_example.ipynb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
"metadata": {},
66
"source": [
77
"# Mitigating Prompt hacking with JSON Mode in Autogen\n",
8+
"\n",
89
"Introduction\n",
910
"\n",
1011
"In this notebook, we'll explore how to generate very precise agent responses using a combination of OpenAI JSON mode and the Agent Description. \n",
1112
"\n",
1213
"As our example, we will implement prompt hacking protection by controlling how agents can respond; Filtering coercive requests to an agent that will always reject their requests. \n",
13-
"The strucutre of JSON mode both enables precise speaker selection and allows us to add a \"coersiveness rating\" to a request that the groupchat manager can use to filter out bad requests. \n",
14+
"The structure of JSON mode both enables precise speaker selection and allows us to add a \"coersiveness rating\" to a request that the groupchat manager can use to filter out bad requests. \n",
1415
"\n",
1516
"The group chat manager can perfrom some simple maths encoded into the agent descriptions on the rating values (made reliable by json mode) and direct requests deemed too coersive to the \"suspicious agent\" \n",
1617
"\n",
@@ -153,9 +154,9 @@
153154
"We tell the agent:\n",
154155
"* who they are\n",
155156
"* what their job is\n",
156-
"* what the output strucutre must be\n",
157+
"* what the output structure must be\n",
157158
"\n",
158-
"For JSON mode to work, we must include the literal string \"JSON\". For it to work well, we must also provide a clean and clear JSON strucutre with an explaination for what each field is for."
159+
"For JSON mode to work, we must include the literal string \"JSON\". For it to work well, we must also provide a clean and clear JSON structure with an explaination for what each field is for."
159160
]
160161
},
161162
{
@@ -192,7 +193,7 @@
192193
"### Friendly and Suspicious Agents\n",
193194
"\n",
194195
"Now we set up the friendly and suspicious agents. \n",
195-
"Note that the system message has the same overall strucutre, however it is much less prescriptive. We want some json strucutre, but we do not need any complex enumerated key values to operate against. We can still use JSON to give useful strucutre. in this case, the textual response, and indicators for \"body language\" and delivery style. \n"
196+
"Note that the system message has the same overall structure, however it is much less prescriptive. We want some json structure, but we do not need any complex enumerated key values to operate against. We can still use JSON to give useful structure. in this case, the textual response, and indicators for \"body language\" and delivery style. \n"
196197
]
197198
},
198199
{
@@ -206,7 +207,7 @@
206207
"The Description is read by the group chat manager to understand the circumstances in which they should call this agent. The agent itself is not exposed to this information. \n",
207208
"In this case, we can include some simple logic for the manager to assess against the JSON strcutured output from the IO_Agent. \n",
208209
"\n",
209-
"The strucutred and dependable nature of the output with the friendliness and coercive_rating being intergers between 1 and 10, means that we can trust this interaction to control the speaker transition.\n",
210+
"The structured and dependable nature of the output with the friendliness and coercive_rating being intergers between 1 and 10, means that we can trust this interaction to control the speaker transition.\n",
210211
" \n",
211212
"In essence, we have created a framework for using maths or formal logic to determine which speaker is chosen. "
212213
]
@@ -228,7 +229,7 @@
228229
" name=\"friendly_agent\",\n",
229230
" llm_config=llm_config,\n",
230231
" system_message=\"\"\"You are a very friendly agent and you always assume the best about people. You trust implicitly.\n",
231-
"Agent T0 will forward a message to you when you are the best agent to answer the question, you must carefully analyse their message and then formulate your own response in JSON format using the below strucutre:\n",
232+
"Agent T0 will forward a message to you when you are the best agent to answer the question, you must carefully analyse their message and then formulate your own response in JSON format using the below structure:\n",
232233
"[\n",
233234
"{\n",
234235
"\"response\": {\n",
@@ -265,7 +266,7 @@
265266
" llm_config=llm_config,\n",
266267
" system_message=\"\"\"You are a very suspicious agent. Everyone is probably trying to take things from you. You always assume people are trying to manipulate you. You trust no one.\n",
267268
"You have no problem with being rude or aggressive if it is warranted.\n",
268-
"IO_Agent will forward a message to you when you are the best agent to answer the question, you must carefully analyse their message and then formulate your own response in JSON format using the below strucutre:\n",
269+
"IO_Agent will forward a message to you when you are the best agent to answer the question, you must carefully analyse their message and then formulate your own response in JSON format using the below structure:\n",
269270
"[\n",
270271
"{\n",
271272
"\"response\": {\n",

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ files = [
5656
"autogen/logger",
5757
"autogen/exception_utils.py",
5858
"autogen/coding",
59-
"autogen/oai/openai_utils.py",
6059
"autogen/_pydantic.py",
6160
"autogen/function_utils.py",
6261
"autogen/io",
@@ -77,7 +76,7 @@ python_version = "3.8"
7776
ignore_missing_imports = true
7877
install_types = true
7978
non_interactive = true
80-
plugins = ["pydantic.mypy"]
79+
# plugins = ["pydantic.mypy"]
8180

8281
# remove after all files in the repo are fixed
8382
follow_imports = "silent"

0 commit comments

Comments
 (0)