Skip to content

Commit 79ddd7d

Browse files
authored
FIX: Bug with responses integration test (microsoft#1121)
1 parent 3f77fe2 commit 79ddd7d

2 files changed

Lines changed: 27 additions & 16 deletions

File tree

doc/code/targets/8_openai_responses_target.ipynb

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
"\u001b[33m────────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n",
4141
"\u001b[1m\u001b[33m🔸 ASSISTANT\u001b[0m\n",
4242
"\u001b[33m────────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n",
43-
"\u001b[33m Why did the scarecrow win an award?\u001b[0m\n",
44-
"\u001b[33m Because he was outstanding in his field!\u001b[0m\n",
43+
"\u001b[33m Why don’t scientists trust atoms?\u001b[0m\n",
44+
"\u001b[33m Because they make up everything!\u001b[0m\n",
4545
"\n",
4646
"\u001b[34m────────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n"
4747
]
@@ -185,22 +185,19 @@
185185
"name": "stdout",
186186
"output_type": "stream",
187187
"text": [
188-
"2 | assistant: {\"id\":\"ws_68b78ebf92b481a299ee79eda74c5ae80cc9740a19fd8e2f\",\"type\":\"web_search_call\",\"status\":\"completed\",\"action\":{\"type\":\"search\",\"query\":\"positive news September 3 2025\"}}\n",
189-
"4 | assistant: {\"id\":\"ws_68b78ec2147081a2b2078a9bcda00f9e0cc9740a19fd8e2f\",\"type\":\"web_search_call\",\"status\":\"completed\",\"action\":{\"type\":\"open_page\",\"url\":\"https://newsroom.ocfl.net/media-advisories/press-releases/2025/09/a-spontaneous-sale-for-a-happy-tail-orange-county-animal-services-reduced-adoption-fees-for-three-days/\"}}\n",
190-
"6 | assistant: {\"id\":\"ws_68b78ec4823881a2a18c0ed68897d5fd0cc9740a19fd8e2f\",\"type\":\"web_search_call\",\"status\":\"completed\",\"action\":{\"type\":\"search\",\"query\":\"site:apnews.com good news September 3 2025\"}}\n",
191-
"8 | assistant: {\"id\":\"ws_68b78ec7107081a28908f0f4997dfc5c0cc9740a19fd8e2f\",\"type\":\"web_search_call\",\"status\":\"completed\",\"action\":{\"type\":\"search\",\"query\":\"AP News One Good Thing September 3 2025\"}}\n",
192-
"10 | assistant: {\"id\":\"ws_68b78ec99cb881a28420fdd84cf98b540cc9740a19fd8e2f\",\"type\":\"web_search_call\",\"status\":\"completed\",\"action\":{\"type\":\"open_page\",\"url\":\"https://apnews.com/article/biden-charleston-west-virginia-715c1faa116d4285c77f0095d37a714a\"}}\n",
193-
"12 | assistant: {\"id\":\"ws_68b78ecb17a481a2a08b8d38954539580cc9740a19fd8e2f\",\"type\":\"web_search_call\",\"status\":\"completed\",\"action\":{\"type\":\"find_in_page\",\"pattern\":\"South Charleston\"}}\n",
194-
"14 | assistant: {\"id\":\"ws_68b78ece497081a2a6633cdd4403ddcb0cc9740a19fd8e2f\",\"type\":\"web_search_call\",\"status\":\"completed\",\"action\":{\"type\":\"search\",\"query\":\"West Virginia electric school buses plant September Charleston GreenPower Motor Co. AP News\"}}\n",
195-
"16 | assistant: A Canadian electric-school-bus manufacturer, GreenPower Motor Co., will begin producing zero-emission buses at its new South Charleston, West Virginia, facility in September, Gov. Jim Justice announced today. The 9.5-acre plant will initially create about 200 jobs, with the capacity to expand to roughly 900 positions once full production is reached in two years ([apnews.com](https://apnews.com/article/biden-charleston-west-virginia-715c1faa116d4285c77f0095d37a714a?utm_source=openai)).\n",
196-
"\n",
197-
"This expansion is supported by President Biden’s $1 trillion infrastructure law, under which the Environmental Protection Agency’s Clean School Bus Program offers rebates of up to $375,000 for larger electric buses and $285,000 for smaller models, plus an extra $20,000 per bus to fund charging infrastructure. GreenPower plans to leverage these rebates to help school districts transition away from diesel-powered fleets, with buses capable of 140 miles on a single charge and a recharge time as short as 3.5 hours ([apnews.com](https://apnews.com/article/biden-charleston-west-virginia-715c1faa116d4285c77f0095d37a714a?utm_source=openai)).\n",
198-
"\n",
199-
"This development represents a win on multiple fronts: it accelerates the shift toward cleaner school transportation, reduces local air pollution, and brings significant employment opportunities to the Charleston area—all announced on September 3, 2025.\n"
188+
"1 | assistant: {\"id\":\"ws_0db630c93406f5080068e5e961dad481a28a31d658c8353572\",\"type\":\"web_search_call\",\"status\":\"completed\",\"action\":{\"type\":\"search\",\"query\":\"October 8 2025 positive news story\"}}\n",
189+
"3 | assistant: {\"id\":\"ws_0db630c93406f5080068e5e964e01481a29e827eea62d80001\",\"type\":\"web_search_call\",\"status\":\"completed\",\"action\":{\"type\":\"search\",\"query\":\"Reuters Oct 8 2025 positive news climate education health\"}}\n",
190+
"5 | assistant: {\"id\":\"ws_0db630c93406f5080068e5e9685ff481a2910eecac2a26c206\",\"type\":\"web_search_call\",\"status\":\"completed\",\"action\":{\"type\":\"search\",\"query\":\"Date Wed Oct 8 2025 Reuters positive\"}}\n",
191+
"7 | assistant: {\"id\":\"ws_0db630c93406f5080068e5e96b262481a28862db6b0394e644\",\"type\":\"web_search_call\",\"status\":\"completed\",\"action\":{\"type\":\"search\",\"query\":\"AP News October 8 2025 positive news\"}}\n",
192+
"9 | assistant: {\"id\":\"ws_0db630c93406f5080068e5e96fa97c81a2b48a8f6c93125190\",\"type\":\"web_search_call\",\"status\":\"completed\",\"action\":{\"type\":\"search\",\"query\":\"Reuters Oct 8 2025 children school Africa positive Reuters 2025-10-08\"}}\n",
193+
"11 | assistant: {\"id\":\"ws_0db630c93406f5080068e5e972624481a2b08b4104a6adb6e8\",\"type\":\"web_search_call\",\"status\":\"completed\",\"action\":{\"type\":\"search\",\"query\":\"Oct 8 2025 Reuters environment ban polystyrene local positive\"}}\n",
194+
"13 | assistant: One uplifting story today comes from Bangladesh’s flood-prone heartland, where solar-powered “floating schools” are keeping education afloat. As seasonal inundations submerge roads and isolate villages, boat-based classrooms stocked with books and staffed by teachers sail directly to students’ doorsteps, ensuring that hundreds of children like 10-year-old Safikul Islam don’t miss a day of learning despite rising waters ([reuters.com](https://www.reuters.com/world/asia-pacific/bangladeshs-flooded-plains-schools-boats-keep-learning-afloat-2025-10-07/?utm_source=openai))\n"
200195
]
201196
}
202197
],
203198
"source": [
199+
"import os\n",
200+
"\n",
204201
"from pyrit.common import IN_MEMORY, initialize_pyrit\n",
205202
"from pyrit.common.tool_configs import web_search_tool\n",
206203
"from pyrit.models import PromptRequestPiece, PromptRequestResponse\n",
@@ -209,6 +206,10 @@
209206
"initialize_pyrit(memory_db_type=IN_MEMORY)\n",
210207
"\n",
211208
"target = OpenAIResponseTarget(\n",
209+
" endpoint=os.getenv(\"PLATFORM_OPENAI_RESPONSES_ENDPOINT\"),\n",
210+
" api_key=os.getenv(\"PLATFORM_OPENAI_RESPONSES_KEY\"),\n",
211+
" model_name=os.getenv(\"PLATFORM_OPENAI_RESPONSES_MODEL\", \"gpt-4o-mini\"),\n",
212+
" api_version=None,\n",
212213
" extra_body_parameters={\n",
213214
" \"tools\": [web_search_tool()],\n",
214215
" \"tool_choice\": \"auto\",\n",
@@ -242,7 +243,7 @@
242243
"name": "python",
243244
"nbconvert_exporter": "python",
244245
"pygments_lexer": "ipython3",
245-
"version": "3.11.9"
246+
"version": "3.12.11"
246247
}
247248
},
248249
"nbformat": 4,

doc/code/targets/8_openai_responses_target.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
# extension: .py
66
# format_name: percent
77
# format_version: '1.3'
8-
# jupytext_version: 1.17.2
8+
# jupytext_version: 1.17.3
9+
# kernelspec:
10+
# display_name: pyrit-312
11+
# language: python
12+
# name: python3
913
# ---
1014

1115
# %% [markdown]
@@ -127,6 +131,8 @@ async def get_current_weather(args):
127131
# NOTE that web search is NOT supported through an Azure OpenAI endpoint, only through the OpenAI platform endpoint (i.e. api.openai.com)
128132

129133
# %%
134+
import os
135+
130136
from pyrit.common import IN_MEMORY, initialize_pyrit
131137
from pyrit.common.tool_configs import web_search_tool
132138
from pyrit.models import PromptRequestPiece, PromptRequestResponse
@@ -135,6 +141,10 @@ async def get_current_weather(args):
135141
initialize_pyrit(memory_db_type=IN_MEMORY)
136142

137143
target = OpenAIResponseTarget(
144+
endpoint=os.getenv("PLATFORM_OPENAI_RESPONSES_ENDPOINT"),
145+
api_key=os.getenv("PLATFORM_OPENAI_RESPONSES_KEY"),
146+
model_name=os.getenv("PLATFORM_OPENAI_RESPONSES_MODEL", "gpt-4o-mini"),
147+
api_version=None,
138148
extra_body_parameters={
139149
"tools": [web_search_tool()],
140150
"tool_choice": "auto",

0 commit comments

Comments
 (0)