uipath-openai-agents 0.0.2__py3-none-any.whl → 0.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- uipath_openai_agents/runtime/schema.py +113 -60
- {uipath_openai_agents-0.0.2.dist-info → uipath_openai_agents-0.0.3.dist-info}/METADATA +1 -1
- {uipath_openai_agents-0.0.2.dist-info → uipath_openai_agents-0.0.3.dist-info}/RECORD +5 -5
- {uipath_openai_agents-0.0.2.dist-info → uipath_openai_agents-0.0.3.dist-info}/WHEEL +0 -0
- {uipath_openai_agents-0.0.2.dist-info → uipath_openai_agents-0.0.3.dist-info}/entry_points.txt +0 -0
|
@@ -143,8 +143,9 @@ def get_agent_schema(agent: Agent) -> UiPathRuntimeGraph:
|
|
|
143
143
|
"""
|
|
144
144
|
Extract graph structure from an OpenAI Agent.
|
|
145
145
|
|
|
146
|
-
OpenAI Agents
|
|
147
|
-
|
|
146
|
+
OpenAI Agents are represented as simple nodes. Regular tools are aggregated
|
|
147
|
+
into a single tools node per agent with metadata. Agent-tools and handoff
|
|
148
|
+
agents are represented as separate agent nodes.
|
|
148
149
|
|
|
149
150
|
Args:
|
|
150
151
|
agent: An OpenAI Agent instance
|
|
@@ -154,109 +155,161 @@ def get_agent_schema(agent: Agent) -> UiPathRuntimeGraph:
|
|
|
154
155
|
"""
|
|
155
156
|
nodes: list[UiPathRuntimeNode] = []
|
|
156
157
|
edges: list[UiPathRuntimeEdge] = []
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
158
|
+
visited: set[str] = set() # Track visited agents to avoid circular references
|
|
159
|
+
|
|
160
|
+
def _add_agent_and_tools(current_agent: Agent) -> None:
|
|
161
|
+
"""Recursively add agent, its tools, and nested agents to the graph."""
|
|
162
|
+
agent_name = getattr(current_agent, "name", "agent")
|
|
163
|
+
|
|
164
|
+
# Prevent circular references using agent name
|
|
165
|
+
if agent_name in visited:
|
|
166
|
+
return
|
|
167
|
+
visited.add(agent_name)
|
|
168
|
+
|
|
169
|
+
# Add agent node (first visit always adds the node)
|
|
170
|
+
nodes.append(
|
|
171
|
+
UiPathRuntimeNode(
|
|
172
|
+
id=agent_name,
|
|
173
|
+
name=agent_name,
|
|
174
|
+
type="node",
|
|
175
|
+
subgraph=None,
|
|
176
|
+
metadata=None,
|
|
177
|
+
)
|
|
176
178
|
)
|
|
177
|
-
)
|
|
178
179
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
target=agent_name,
|
|
184
|
-
label="input",
|
|
185
|
-
)
|
|
186
|
-
)
|
|
180
|
+
# Process tools - separate agent-tools from regular tools
|
|
181
|
+
tools = getattr(current_agent, "tools", None) or []
|
|
182
|
+
agent_tools: list[Agent] = []
|
|
183
|
+
regular_tools: list[Any] = []
|
|
187
184
|
|
|
188
|
-
# Add tool nodes if tools are available
|
|
189
|
-
tools = getattr(agent, "tools", None) or []
|
|
190
|
-
if tools:
|
|
191
185
|
for tool in tools:
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
186
|
+
if isinstance(tool, Agent):
|
|
187
|
+
agent_tools.append(tool)
|
|
188
|
+
else:
|
|
189
|
+
regular_tools.append(tool)
|
|
190
|
+
|
|
191
|
+
# Process agent-tools (agents used as tools)
|
|
192
|
+
for tool_agent in agent_tools:
|
|
193
|
+
tool_agent_name = getattr(tool_agent, "name", _get_tool_name(tool_agent))
|
|
194
|
+
if tool_agent_name and tool_agent_name not in visited:
|
|
195
|
+
# Recursively process agent-tool
|
|
196
|
+
_add_agent_and_tools(tool_agent)
|
|
197
|
+
|
|
198
|
+
# Add edges for agent-tool
|
|
199
|
+
edges.append(
|
|
200
|
+
UiPathRuntimeEdge(
|
|
201
|
+
source=agent_name,
|
|
202
|
+
target=tool_agent_name,
|
|
203
|
+
label="tool_call",
|
|
204
|
+
)
|
|
205
|
+
)
|
|
206
|
+
edges.append(
|
|
207
|
+
UiPathRuntimeEdge(
|
|
208
|
+
source=tool_agent_name,
|
|
209
|
+
target=agent_name,
|
|
210
|
+
label="tool_result",
|
|
211
|
+
)
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
# Process regular tools - aggregate into single tools node
|
|
215
|
+
if regular_tools:
|
|
216
|
+
tool_names = [_get_tool_name(tool) for tool in regular_tools]
|
|
217
|
+
tool_names = [name for name in tool_names if name] # Filter out None values
|
|
218
|
+
|
|
219
|
+
if tool_names:
|
|
220
|
+
# Create a single tools node for this agent
|
|
221
|
+
tools_node_id = f"{agent_name}_tools"
|
|
195
222
|
nodes.append(
|
|
196
223
|
UiPathRuntimeNode(
|
|
197
|
-
id=
|
|
198
|
-
name=
|
|
224
|
+
id=tools_node_id,
|
|
225
|
+
name="tools",
|
|
199
226
|
type="tool",
|
|
200
227
|
subgraph=None,
|
|
228
|
+
metadata={
|
|
229
|
+
"tool_names": tool_names,
|
|
230
|
+
"tool_count": len(tool_names),
|
|
231
|
+
},
|
|
201
232
|
)
|
|
202
233
|
)
|
|
203
|
-
|
|
234
|
+
|
|
235
|
+
# Add bidirectional edges for tools node
|
|
204
236
|
edges.append(
|
|
205
237
|
UiPathRuntimeEdge(
|
|
206
238
|
source=agent_name,
|
|
207
|
-
target=
|
|
208
|
-
label=
|
|
239
|
+
target=tools_node_id,
|
|
240
|
+
label=None,
|
|
209
241
|
)
|
|
210
242
|
)
|
|
211
243
|
edges.append(
|
|
212
244
|
UiPathRuntimeEdge(
|
|
213
|
-
source=
|
|
245
|
+
source=tools_node_id,
|
|
214
246
|
target=agent_name,
|
|
215
|
-
label=
|
|
247
|
+
label=None,
|
|
216
248
|
)
|
|
217
249
|
)
|
|
218
250
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
if handoffs:
|
|
251
|
+
# Process handoff agents
|
|
252
|
+
handoffs = getattr(current_agent, "handoffs", None) or []
|
|
222
253
|
for handoff_agent in handoffs:
|
|
223
254
|
handoff_name = getattr(handoff_agent, "name", None)
|
|
224
|
-
if handoff_name:
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
type="model",
|
|
230
|
-
subgraph=None, # Handoff agents are peers, not subgraphs
|
|
231
|
-
)
|
|
232
|
-
)
|
|
233
|
-
# Handoff edges
|
|
255
|
+
if handoff_name and handoff_name not in visited:
|
|
256
|
+
# Recursively process handoff agent
|
|
257
|
+
_add_agent_and_tools(handoff_agent)
|
|
258
|
+
|
|
259
|
+
# Add handoff edges without labels
|
|
234
260
|
edges.append(
|
|
235
261
|
UiPathRuntimeEdge(
|
|
236
262
|
source=agent_name,
|
|
237
263
|
target=handoff_name,
|
|
238
|
-
label=
|
|
264
|
+
label=None,
|
|
239
265
|
)
|
|
240
266
|
)
|
|
241
267
|
edges.append(
|
|
242
268
|
UiPathRuntimeEdge(
|
|
243
269
|
source=handoff_name,
|
|
244
270
|
target=agent_name,
|
|
245
|
-
label=
|
|
271
|
+
label=None,
|
|
246
272
|
)
|
|
247
273
|
)
|
|
248
274
|
|
|
249
|
-
#
|
|
275
|
+
# Add __start__ node
|
|
276
|
+
nodes.append(
|
|
277
|
+
UiPathRuntimeNode(
|
|
278
|
+
id="__start__",
|
|
279
|
+
name="__start__",
|
|
280
|
+
type="__start__",
|
|
281
|
+
subgraph=None,
|
|
282
|
+
metadata=None,
|
|
283
|
+
)
|
|
284
|
+
)
|
|
285
|
+
|
|
286
|
+
# Recursively build graph starting from main agent
|
|
287
|
+
_add_agent_and_tools(agent)
|
|
288
|
+
|
|
289
|
+
# Get the main agent name
|
|
290
|
+
agent_name = getattr(agent, "name", "agent")
|
|
291
|
+
|
|
292
|
+
# Add __end__ node
|
|
250
293
|
nodes.append(
|
|
251
294
|
UiPathRuntimeNode(
|
|
252
295
|
id="__end__",
|
|
253
296
|
name="__end__",
|
|
254
297
|
type="__end__",
|
|
255
298
|
subgraph=None,
|
|
299
|
+
metadata=None,
|
|
300
|
+
)
|
|
301
|
+
)
|
|
302
|
+
|
|
303
|
+
# Connect start to main agent
|
|
304
|
+
edges.append(
|
|
305
|
+
UiPathRuntimeEdge(
|
|
306
|
+
source="__start__",
|
|
307
|
+
target=agent_name,
|
|
308
|
+
label="input",
|
|
256
309
|
)
|
|
257
310
|
)
|
|
258
311
|
|
|
259
|
-
# Connect agent to end
|
|
312
|
+
# Connect main agent to end
|
|
260
313
|
edges.append(
|
|
261
314
|
UiPathRuntimeEdge(
|
|
262
315
|
source=agent_name,
|
|
@@ -16,8 +16,8 @@ uipath_openai_agents/runtime/config.py,sha256=gtDCIMB1fcAry9Tj_xJSR1xVaARMNmrr5H
|
|
|
16
16
|
uipath_openai_agents/runtime/errors.py,sha256=AgUmbikoM53O02CktbZAKVjVmK1ZCl9-EG0gWaYtrn0,1333
|
|
17
17
|
uipath_openai_agents/runtime/factory.py,sha256=rCw521lvUDGLtjrOYn2WwNQ05oxmWjuAxCmoJ_HTzkg,7595
|
|
18
18
|
uipath_openai_agents/runtime/runtime.py,sha256=NJIuIMKNaK3nraEZvYu_1Dkh1CZ0nfBfybEKVgNe090,11229
|
|
19
|
-
uipath_openai_agents/runtime/schema.py,sha256=
|
|
20
|
-
uipath_openai_agents-0.0.
|
|
21
|
-
uipath_openai_agents-0.0.
|
|
22
|
-
uipath_openai_agents-0.0.
|
|
23
|
-
uipath_openai_agents-0.0.
|
|
19
|
+
uipath_openai_agents/runtime/schema.py,sha256=yV5sDHamKKXKm6zUwPiHZTJofnut0lrzuEJY3YCF0cg,13793
|
|
20
|
+
uipath_openai_agents-0.0.3.dist-info/METADATA,sha256=rzfkDeZyHGv97Dbu4WPn5kDNKWZhYX5kTkM1EL1T27M,4938
|
|
21
|
+
uipath_openai_agents-0.0.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
22
|
+
uipath_openai_agents-0.0.3.dist-info/entry_points.txt,sha256=2tY1wvop4ulDwWMUXFZzOREIKyIf5cFYsefLWNA2-9w,183
|
|
23
|
+
uipath_openai_agents-0.0.3.dist-info/RECORD,,
|
|
File without changes
|
{uipath_openai_agents-0.0.2.dist-info → uipath_openai_agents-0.0.3.dist-info}/entry_points.txt
RENAMED
|
File without changes
|