meshagent-openai 0.0.5__py3-none-any.whl → 0.0.6__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.
Potentially problematic release.
This version of meshagent-openai might be problematic. Click here for more details.
- meshagent/openai/tools/completions_adapter.py +1 -6
- meshagent/openai/tools/responses_adapter.py +31 -28
- {meshagent_openai-0.0.5.dist-info → meshagent_openai-0.0.6.dist-info}/METADATA +6 -5
- meshagent_openai-0.0.6.dist-info/RECORD +9 -0
- {meshagent_openai-0.0.5.dist-info → meshagent_openai-0.0.6.dist-info}/WHEEL +1 -1
- meshagent_openai-0.0.5.dist-info/RECORD +0 -9
- {meshagent_openai-0.0.5.dist-info → meshagent_openai-0.0.6.dist-info/licenses}/LICENSE +0 -0
- {meshagent_openai-0.0.5.dist-info → meshagent_openai-0.0.6.dist-info}/top_level.txt +0 -0
|
@@ -219,13 +219,11 @@ class OpenAICompletionsAdapter(LLMAdapter):
|
|
|
219
219
|
model: str = os.getenv("OPENAI_MODEL"),
|
|
220
220
|
parallel_tool_calls : Optional[bool] = None,
|
|
221
221
|
client: Optional[AsyncOpenAI] = None,
|
|
222
|
-
reasoning_effort: Optional[str] = None,
|
|
223
222
|
):
|
|
224
223
|
self._model = model
|
|
225
224
|
self._parallel_tool_calls = parallel_tool_calls
|
|
226
225
|
self._client = client
|
|
227
|
-
|
|
228
|
-
|
|
226
|
+
|
|
229
227
|
|
|
230
228
|
def create_chat_context(self):
|
|
231
229
|
system_role = "system"
|
|
@@ -303,9 +301,6 @@ class OpenAICompletionsAdapter(LLMAdapter):
|
|
|
303
301
|
}
|
|
304
302
|
}
|
|
305
303
|
|
|
306
|
-
if self._reasoning_effort != None:
|
|
307
|
-
extra["reasoning_effort"] = self._reasoning_effort
|
|
308
|
-
|
|
309
304
|
response : ChatCompletion = await openai.chat.completions.create(
|
|
310
305
|
n=1,
|
|
311
306
|
model = self._model,
|
|
@@ -70,7 +70,7 @@ class ResponsesToolBundle:
|
|
|
70
70
|
|
|
71
71
|
for toolkit in toolkits:
|
|
72
72
|
for v in toolkit.tools:
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
k = v.name
|
|
75
75
|
|
|
76
76
|
name = safe_tool_name(k)
|
|
@@ -235,14 +235,14 @@ class OpenAIResponsesAdapter(LLMAdapter[ResponsesToolBundle]):
|
|
|
235
235
|
model: str = os.getenv("OPENAI_MODEL"),
|
|
236
236
|
parallel_tool_calls : Optional[bool] = None,
|
|
237
237
|
client: Optional[AsyncOpenAI] = None,
|
|
238
|
-
reasoning_effort: Optional[str] = None,
|
|
239
238
|
retries : int = 10,
|
|
239
|
+
response_options : Optional[dict] = None
|
|
240
240
|
):
|
|
241
241
|
self._model = model
|
|
242
242
|
self._parallel_tool_calls = parallel_tool_calls
|
|
243
243
|
self._client = client
|
|
244
|
-
self._reasoning_effort = reasoning_effort
|
|
245
244
|
self._retries = retries
|
|
245
|
+
self._response_options = response_options
|
|
246
246
|
|
|
247
247
|
def create_chat_context(self):
|
|
248
248
|
system_role = "system"
|
|
@@ -252,6 +252,7 @@ class OpenAIResponsesAdapter(LLMAdapter[ResponsesToolBundle]):
|
|
|
252
252
|
system_role = "developer"
|
|
253
253
|
elif self._model.startswith("computer-use"):
|
|
254
254
|
system_role = "developer"
|
|
255
|
+
|
|
255
256
|
|
|
256
257
|
context = AgentChatContext(
|
|
257
258
|
system_role=system_role
|
|
@@ -311,22 +312,27 @@ class OpenAIResponsesAdapter(LLMAdapter[ResponsesToolBundle]):
|
|
|
311
312
|
|
|
312
313
|
openai = self._get_client(room=room)
|
|
313
314
|
|
|
314
|
-
|
|
315
|
-
*toolkits,
|
|
316
|
-
])
|
|
317
|
-
open_ai_tools = tool_bundle.to_json()
|
|
318
|
-
|
|
319
|
-
if open_ai_tools != None:
|
|
320
|
-
logger.info("OpenAI Tools: %s", json.dumps(open_ai_tools))
|
|
321
|
-
else:
|
|
322
|
-
logger.info("OpenAI Tools: Empty")
|
|
323
|
-
open_ai_tools = NOT_GIVEN
|
|
324
|
-
|
|
315
|
+
|
|
325
316
|
response_schema = output_schema
|
|
326
317
|
response_name = "response"
|
|
327
318
|
|
|
328
319
|
|
|
329
320
|
while True:
|
|
321
|
+
|
|
322
|
+
# We need to do this inside the loop because tools can change mid loop
|
|
323
|
+
# for example computer use adds goto tools after the first interaction
|
|
324
|
+
tool_bundle = ResponsesToolBundle(toolkits=[
|
|
325
|
+
*toolkits,
|
|
326
|
+
])
|
|
327
|
+
open_ai_tools = tool_bundle.to_json()
|
|
328
|
+
|
|
329
|
+
if open_ai_tools != None:
|
|
330
|
+
logger.info("OpenAI Tools: %s", json.dumps(open_ai_tools))
|
|
331
|
+
else:
|
|
332
|
+
logger.info("OpenAI Tools: Empty")
|
|
333
|
+
open_ai_tools = NOT_GIVEN
|
|
334
|
+
|
|
335
|
+
|
|
330
336
|
|
|
331
337
|
logger.info("model: %s, context: %s, output_schema: %s", self._model, context.messages, output_schema)
|
|
332
338
|
ptc = self._parallel_tool_calls
|
|
@@ -334,10 +340,6 @@ class OpenAIResponsesAdapter(LLMAdapter[ResponsesToolBundle]):
|
|
|
334
340
|
if ptc != None and self._model.startswith("o") == False:
|
|
335
341
|
extra["parallel_tool_calls"] = ptc
|
|
336
342
|
|
|
337
|
-
trunc = NOT_GIVEN
|
|
338
|
-
if self._model == "computer-use-preview":
|
|
339
|
-
trunc = "auto"
|
|
340
|
-
|
|
341
343
|
text = NOT_GIVEN
|
|
342
344
|
if output_schema != None:
|
|
343
345
|
text = {
|
|
@@ -349,12 +351,7 @@ class OpenAIResponsesAdapter(LLMAdapter[ResponsesToolBundle]):
|
|
|
349
351
|
}
|
|
350
352
|
}
|
|
351
353
|
|
|
352
|
-
|
|
353
|
-
if self._reasoning_effort != None:
|
|
354
|
-
reasoning = {
|
|
355
|
-
"effort" : self._reasoning_effort
|
|
356
|
-
}
|
|
357
|
-
|
|
354
|
+
|
|
358
355
|
previous_response_id = NOT_GIVEN
|
|
359
356
|
if context.previous_response_id != None:
|
|
360
357
|
previous_response_id = context.previous_response_id
|
|
@@ -365,15 +362,19 @@ class OpenAIResponsesAdapter(LLMAdapter[ResponsesToolBundle]):
|
|
|
365
362
|
if range == self._retries:
|
|
366
363
|
raise RoomException("exceeded maximum attempts calling openai")
|
|
367
364
|
try:
|
|
368
|
-
|
|
365
|
+
response_options = self._response_options
|
|
366
|
+
if response_options == None:
|
|
367
|
+
response_options = {}
|
|
368
|
+
|
|
369
|
+
response : Response = await openai.responses.create(
|
|
369
370
|
stream=stream,
|
|
370
371
|
model = self._model,
|
|
371
372
|
input = context.messages,
|
|
372
373
|
tools = open_ai_tools,
|
|
373
374
|
text = text,
|
|
374
375
|
previous_response_id=previous_response_id,
|
|
375
|
-
|
|
376
|
-
|
|
376
|
+
|
|
377
|
+
**response_options
|
|
377
378
|
)
|
|
378
379
|
break
|
|
379
380
|
except Exception as e:
|
|
@@ -513,7 +514,9 @@ class OpenAIResponsesAdapter(LLMAdapter[ResponsesToolBundle]):
|
|
|
513
514
|
all_outputs = []
|
|
514
515
|
|
|
515
516
|
elif event.type == "response.output_item.done":
|
|
516
|
-
|
|
517
|
+
|
|
518
|
+
room.developer.log_nowait(type="llm.output", data={ "context" : context.id, "participant_id" : room.local_participant.id, "participant_name" : room.local_participant.get_attribute("name"), "response" : event.to_dict() })
|
|
519
|
+
|
|
517
520
|
context.previous_messages.append(event.item.to_dict())
|
|
518
521
|
|
|
519
522
|
outputs, done = await handle_message(message=event.item)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: meshagent-openai
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.6
|
|
4
4
|
Summary: OpenAI Building Blocks for Meshagent
|
|
5
5
|
Home-page:
|
|
6
6
|
License: Apache License 2.0
|
|
@@ -14,11 +14,12 @@ Requires-Dist: pyjwt>=2.0.0
|
|
|
14
14
|
Requires-Dist: pytest>=8.3.4
|
|
15
15
|
Requires-Dist: pytest-asyncio>=0.24.0
|
|
16
16
|
Requires-Dist: openai>=1.66.2
|
|
17
|
-
Requires-Dist: meshagent-api>=0.0.
|
|
18
|
-
Requires-Dist: meshagent-agents>=0.0.
|
|
19
|
-
Requires-Dist: meshagent-tools>=0.0.
|
|
17
|
+
Requires-Dist: meshagent-api>=0.0.6
|
|
18
|
+
Requires-Dist: meshagent-agents>=0.0.6
|
|
19
|
+
Requires-Dist: meshagent-tools>=0.0.6
|
|
20
20
|
Dynamic: description-content-type
|
|
21
21
|
Dynamic: license
|
|
22
|
+
Dynamic: license-file
|
|
22
23
|
Dynamic: project-url
|
|
23
24
|
Dynamic: requires-dist
|
|
24
25
|
Dynamic: requires-python
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
meshagent/openai/__init__.py,sha256=qAqthmkQBsTqmrnVbtGOeaWCz9o5N48uEUCX7irzEsg,141
|
|
2
|
+
meshagent/openai/tools/__init__.py,sha256=RBU_J4qRDuBaaUdi6jpgpuMlIbvT30QmTBrZrYLwsUU,185
|
|
3
|
+
meshagent/openai/tools/completions_adapter.py,sha256=Rqq8c9E4lkVKrXkbWFcTPHQFCLcoomdM1nIiU1a_T7w,15123
|
|
4
|
+
meshagent/openai/tools/responses_adapter.py,sha256=fEGj-yIM3Sxv__2aMP7WkVZkQzhElKbHRO9xegRXerI,22080
|
|
5
|
+
meshagent_openai-0.0.6.dist-info/licenses/LICENSE,sha256=eTt0SPW-sVNdkZe9PS_S8WfCIyLjRXRl7sUBWdlteFg,10254
|
|
6
|
+
meshagent_openai-0.0.6.dist-info/METADATA,sha256=sheEI0Otfty9FDawTrFRrxFwEoJ-ssCfnnS_XCcj-lw,774
|
|
7
|
+
meshagent_openai-0.0.6.dist-info/WHEEL,sha256=tTnHoFhvKQHCh4jz3yCn0WPTYIy7wXx3CJtJ7SJGV7c,91
|
|
8
|
+
meshagent_openai-0.0.6.dist-info/top_level.txt,sha256=GlcXnHtRP6m7zlG3Df04M35OsHtNXy_DY09oFwWrH74,10
|
|
9
|
+
meshagent_openai-0.0.6.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
meshagent/openai/__init__.py,sha256=qAqthmkQBsTqmrnVbtGOeaWCz9o5N48uEUCX7irzEsg,141
|
|
2
|
-
meshagent/openai/tools/__init__.py,sha256=RBU_J4qRDuBaaUdi6jpgpuMlIbvT30QmTBrZrYLwsUU,185
|
|
3
|
-
meshagent/openai/tools/completions_adapter.py,sha256=I74OC6JMbGb_C7qCYc0lWpJPs3uwuX9TfIDyn9Jou6U,15340
|
|
4
|
-
meshagent/openai/tools/responses_adapter.py,sha256=WGUCHYXq_ZzvjjUOlD59G0lazRSntQqg6BgU7N18W5M,21766
|
|
5
|
-
meshagent_openai-0.0.5.dist-info/LICENSE,sha256=eTt0SPW-sVNdkZe9PS_S8WfCIyLjRXRl7sUBWdlteFg,10254
|
|
6
|
-
meshagent_openai-0.0.5.dist-info/METADATA,sha256=qPqdpUmXtQEgx01u2edIoWzjNUT85aCb_5VVTUlP9gk,752
|
|
7
|
-
meshagent_openai-0.0.5.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
|
|
8
|
-
meshagent_openai-0.0.5.dist-info/top_level.txt,sha256=GlcXnHtRP6m7zlG3Df04M35OsHtNXy_DY09oFwWrH74,10
|
|
9
|
-
meshagent_openai-0.0.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|