ag2 0.9.6__py3-none-any.whl → 0.9.7__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 ag2 might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ag2
3
- Version: 0.9.6
3
+ Version: 0.9.7
4
4
  Summary: A programming framework for agentic AI
5
5
  Project-URL: Homepage, https://ag2.ai/
6
6
  Project-URL: Documentation, https://docs.ag2.ai
@@ -14,7 +14,7 @@ autogen/retrieve_utils.py,sha256=R3Yp5d8dH4o9ayLZrGn4rCjIaY4glOHIiyQjwClmdi8,200
14
14
  autogen/runtime_logging.py,sha256=yCmZODvwqYR91m8lX3Q4SoPcY-DK48NF4m56CP6Om3c,4692
15
15
  autogen/token_count_utils.py,sha256=n4wTFVNHwrfjZkrErFr8kNig2K-YCGgMLWsjDRS9D6g,10797
16
16
  autogen/types.py,sha256=qu-7eywhakW2AxQ5lYisLLeIg45UoOW-b3ErIuyRTuw,1000
17
- autogen/version.py,sha256=Gx2IBExx_OQsL98JzXZ9G56t2UljGjVfvrmaV4UzVp4,193
17
+ autogen/version.py,sha256=aw3BBOt8HZBovklvFoq90ok-Yb3gkEvbuckRDabaBTs,193
18
18
  autogen/_website/__init__.py,sha256=c8B9TpO07x9neD0zsJWj6AaEdlcP-WvxrvVOGWLtamk,143
19
19
  autogen/_website/generate_api_references.py,sha256=yKqyeSP_NE27wwLYWsZbTYRceEoxzNxPXqn6vsIzEvk,14789
20
20
  autogen/_website/generate_mkdocs.py,sha256=TkmLnUDv1Ms5cGClXPmenA8nxmwg4kR0E-FHCVjw_og,43246
@@ -25,7 +25,7 @@ autogen/agentchat/__init__.py,sha256=d5jPpXeavynP9eh5uMIgJKbK3-3tywJBa6l3L9X4l34
25
25
  autogen/agentchat/agent.py,sha256=HePNJ5BXJTcZtaD2a8CoTeHAoLUUy3scM6Ihm-NsSWk,5828
26
26
  autogen/agentchat/assistant_agent.py,sha256=XTJvD66r4qYkdNAJJLr1CC-wTYFJWvhmD5_G0WbbX2I,5741
27
27
  autogen/agentchat/chat.py,sha256=6Gx2t1-Xa8kP6ZoUihHBNGOqNlrGhhqLPKrckL0n-RI,14003
28
- autogen/agentchat/conversable_agent.py,sha256=-BNwxfqSaHQi428a6xgz_53ThPC8LDsdHzHiWzNsPtc,192671
28
+ autogen/agentchat/conversable_agent.py,sha256=v-vX9HkzJzrOXqzLCxXCow2aND0sjcbqR7h4ECKgNAM,193375
29
29
  autogen/agentchat/groupchat.py,sha256=vdK8zUX2CG8fR5pkPGWX7Zn7DFwLvld0bpaRv3vOBEo,89471
30
30
  autogen/agentchat/user_proxy_agent.py,sha256=-gbDblRvE09FGuVB6-y5ZT9Cpvv--rM3FMi8PnPIFBA,7445
31
31
  autogen/agentchat/utils.py,sha256=2ZweUqe4ynxji0jnvd0r9Uxg3n0elif4a-jZOyeeqcg,8238
@@ -280,7 +280,7 @@ autogen/logger/base_logger.py,sha256=nMR6IqELN8b-TzqL0-pJyJ6CpIejjp45IYh5tsMQHAE
280
280
  autogen/logger/file_logger.py,sha256=EbjDhvPUSP2JX-xAZRplc8JRm6au8ofcjHz-KfXboh4,9796
281
281
  autogen/logger/logger_factory.py,sha256=CeLbW3gN0J5zgvQSsRLCSnaiMYusrDWLWovo_Bk-mK8,1391
282
282
  autogen/logger/logger_utils.py,sha256=H9hcsRyEcUcfxTYWf5cRjtNghF4h3FT8sr4IIuqQumY,2053
283
- autogen/logger/sqlite_logger.py,sha256=sRwMx42zh85QWLz1BqKyVySI8OwEB_NjM3ObLOW-mcI,18685
283
+ autogen/logger/sqlite_logger.py,sha256=rP1He7CJB839Qhn1AvW5C0kQ1c45KJs1lgV16y4LxpQ,18694
284
284
  autogen/mcp/__init__.py,sha256=6BDDmw0sjLZRjyHnd-Gfh9BE-pTKTv5bkow9W6odHtQ,213
285
285
  autogen/mcp/__main__.py,sha256=C7nXbWxG3yGsWKRgFnhSsbQOmshLnz6ZOcCxK2TWWio,2487
286
286
  autogen/mcp/helpers.py,sha256=J5_J6n3jMJUEJH5K8k9BeUb6ymQgRUI0hC1gbY7rlwM,1533
@@ -302,16 +302,16 @@ autogen/oai/__init__.py,sha256=BIwnV6wtHmKgIM4IUdymfPfpdNqos5P7BfRv-7_QL9A,1680
302
302
  autogen/oai/anthropic.py,sha256=AK_Bbcc5I-PqAvoiwB0LaO1ZLugh_wQNAOIFcj7eTtk,29174
303
303
  autogen/oai/bedrock.py,sha256=8AYWZVsDkJS2HmQ0ggoUqlKV_a4H_ON8rks4VW2Jrxk,25719
304
304
  autogen/oai/cerebras.py,sha256=8hiSBq88l2yTXUJPV7AvGXRCtwvW0Y9hIYUnYK2S2os,12462
305
- autogen/oai/client.py,sha256=ZJfax-XdV92xfmIvn-qmJhSwjP-MusU4oDc9_88o-1k,68206
305
+ autogen/oai/client.py,sha256=icTgPuHiO6Q9l3iu34j2JYXLCSzYVuculfMBEm1TeDY,68897
306
306
  autogen/oai/client_utils.py,sha256=lVbHyff7OnpdM-tXskC23xLdFccj2AalTdWA4DxzxS4,7543
307
307
  autogen/oai/cohere.py,sha256=pRcQWjbzKbZ1RfC1vk9WGjgndwjHbIaOVoKEYdV2L6c,19421
308
- autogen/oai/gemini.py,sha256=bc_RQwtoGi7DnwQwPie7ZdvsqpD1AjYwzjVwnIKP39U,43168
308
+ autogen/oai/gemini.py,sha256=PXHLyXJgB35YuRFGnM_8fxg2FDRcQj3szh0PZc9cOKA,43192
309
309
  autogen/oai/gemini_types.py,sha256=i4wT8ytD2cO9nCUWm2FKLKVVxyd31wMhOpnrvnIiKIc,5888
310
310
  autogen/oai/groq.py,sha256=pQWtaAY_AjT30XKbZNHXDzWsawBys3yFWlfy6K4Nqr8,12431
311
311
  autogen/oai/mistral.py,sha256=SlOYPdnNLHuTEHBGCzsemG9sLEgphdUukRurERdMsvI,12677
312
- autogen/oai/ollama.py,sha256=t0fIgDCoIfsQZ3hhpseam5N-fbpI7-fw82bG55mA8nU,29103
312
+ autogen/oai/ollama.py,sha256=39r_dA9Uq_ZcVxxMmaSJ9WgjxspQty7PX6cdx8lOEpQ,29162
313
313
  autogen/oai/openai_responses.py,sha256=W847OTGzlDbII8sYWIXTOc9NEPAM59XmLWvcYbC6bRo,17811
314
- autogen/oai/openai_utils.py,sha256=4kEu50WeTGGG2uh1fOeMxRIZkEoov-YkkTgx2n5DhkM,38131
314
+ autogen/oai/openai_utils.py,sha256=lVWSJsTT_Kpto00423mf0zkDLCVXbiYLxLeiG9QdjQ4,41401
315
315
  autogen/oai/together.py,sha256=Sj4LOk9RrBG3Bb5IVsrjBYz-hDECCyCgofsCdtk6PSM,14867
316
316
  autogen/oai/oai_models/__init__.py,sha256=cILDaaCCvSC3aAX85iLwE1RCpNEokA9925Zse5hX2K4,549
317
317
  autogen/oai/oai_models/_models.py,sha256=jr5nlvk7Be4W7wDVnwyjDL6m2CSj0RY1nOL1W3Kq0xI,478
@@ -324,7 +324,7 @@ autogen/oai/oai_models/completion_usage.py,sha256=WAuvTPlONP3wN1iiWXztp7Zv6e6-ba
324
324
  autogen/tools/__init__.py,sha256=guevGJut7uN2pGpPn9mODaVsTSfeHrGpjjjIEWRBqVo,554
325
325
  autogen/tools/dependency_injection.py,sha256=UaLO9QdaVxPLjbKa5ZRuizPagMfg91pa7ohc54mUkDU,8468
326
326
  autogen/tools/function_utils.py,sha256=J-3u-Ao_kK7PxqiJMea2P-HGfSTeJTXlWTFSI19IndM,13756
327
- autogen/tools/tool.py,sha256=1VM5wkPaWrsndCEEYAuFODby0du3raRWCBAGO-kR2xo,7243
327
+ autogen/tools/tool.py,sha256=VtSYf363Z9vIsSZWgNnYs9REdRuPWJMDZkcklIq9Yh8,7225
328
328
  autogen/tools/toolkit.py,sha256=1tOmTGJ96RhkJrrtAViKUyEcwacA6ztoIbYbnf8NgTU,2558
329
329
  autogen/tools/contrib/__init__.py,sha256=DWEjPK6xCR2ihAXXdquQZmiuqRLA3Pqb8QV8W1RtS3k,202
330
330
  autogen/tools/contrib/time/__init__.py,sha256=dplie5aBJZ8VoKy6EKcQMLTtSgcCkNDYzpdsC2I0YWk,195
@@ -414,8 +414,8 @@ autogen/agentchat/contrib/captainagent/tools/math/modular_inverse_sum.py,sha256=
414
414
  autogen/agentchat/contrib/captainagent/tools/math/simplify_mixed_numbers.py,sha256=iqgpFJdyBHPPNCqkehSIbeuV8Rabr2eDMilT23Wx7PI,1687
415
415
  autogen/agentchat/contrib/captainagent/tools/math/sum_of_digit_factorials.py,sha256=-6T5r6Er4mONPldRxv3F9tLoE7Og3qmeSeTC7Du_tTg,596
416
416
  autogen/agentchat/contrib/captainagent/tools/math/sum_of_primes_below.py,sha256=Xig7K3A3DRnbv-UXfyo5bybGZUQYAQsltthfTYW5eV8,509
417
- ag2-0.9.6.dist-info/METADATA,sha256=Syw0Wb_vvJEdWJ52b0UjycmcDQj0PJtCt8ZRUa-lLeM,35268
418
- ag2-0.9.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
419
- ag2-0.9.6.dist-info/licenses/LICENSE,sha256=GEFQVNayAR-S_rQD5l8hPdgvgyktVdy4Bx5-v90IfRI,11384
420
- ag2-0.9.6.dist-info/licenses/NOTICE.md,sha256=07iCPQGbth4pQrgkSgZinJGT5nXddkZ6_MGYcBd2oiY,1134
421
- ag2-0.9.6.dist-info/RECORD,,
417
+ ag2-0.9.7.dist-info/METADATA,sha256=eFWnorPlwQwD0pmvgJvzwflsiWFZh69HHZq4MgxNxjg,35268
418
+ ag2-0.9.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
419
+ ag2-0.9.7.dist-info/licenses/LICENSE,sha256=GEFQVNayAR-S_rQD5l8hPdgvgyktVdy4Bx5-v90IfRI,11384
420
+ ag2-0.9.7.dist-info/licenses/NOTICE.md,sha256=07iCPQGbth4pQrgkSgZinJGT5nXddkZ6_MGYcBd2oiY,1134
421
+ ag2-0.9.7.dist-info/RECORD,,
@@ -3873,15 +3873,29 @@ class ConversableAgent(LLMAgent):
3873
3873
  **executor_kwargs,
3874
3874
  )
3875
3875
 
3876
- tools = [] if tools is None else tools
3877
- tools = [tools] if isinstance(tools, Tool) else tools
3878
- for tool in tools:
3876
+ # Combine agent's existing tools with passed tools
3877
+ agent_tools = self._tools.copy() # Get agent's pre-registered tools
3878
+ passed_tools = [] if tools is None else tools
3879
+ passed_tools = [passed_tools] if isinstance(passed_tools, Tool) else passed_tools
3880
+
3881
+ # Combine both sets of tools (avoid duplicates)
3882
+ all_tools = agent_tools.copy()
3883
+ for tool in passed_tools:
3884
+ if tool not in all_tools:
3885
+ all_tools.append(tool)
3886
+
3887
+ # Register all tools with the executor
3888
+ for tool in all_tools:
3879
3889
  tool.register_for_execution(self.run_executor)
3890
+
3891
+ # Register only newly passed tools for LLM (agent's pre-existing tools are already registered)
3892
+ for tool in passed_tools:
3880
3893
  tool.register_for_llm(self)
3881
3894
  yield self.run_executor
3882
3895
  finally:
3883
- if tools is not None:
3884
- for tool in tools:
3896
+ # Clean up only newly passed tools (not agent's pre-existing tools)
3897
+ if "passed_tools" in locals():
3898
+ for tool in passed_tools:
3885
3899
  self.update_tool_signature(tool_sig=tool.tool_schema["function"]["name"], is_remove=True)
3886
3900
 
3887
3901
  def _deprecated_run(
@@ -293,7 +293,7 @@ class SqliteLogger(BaseLogger):
293
293
  client_id,
294
294
  wrapper_id,
295
295
  self.session_id,
296
- json.dumps(request),
296
+ json.dumps(to_dict(request)),
297
297
  response_messages,
298
298
  is_cached,
299
299
  cost,
autogen/oai/client.py CHANGED
@@ -246,6 +246,12 @@ class OpenAILLMConfigEntry(LLMConfigEntry):
246
246
  price: Optional[list[float]] = Field(default=None, min_length=2, max_length=2)
247
247
  tool_choice: Optional[Literal["none", "auto", "required"]] = None
248
248
  user: Optional[str] = None
249
+
250
+ # ⏺ The extra_body parameter flows from OpenAILLMConfigEntry to the LLM request through this path:
251
+ # 1. Config Definition: extra_body is defined in OpenAILLMConfigEntry (autogen/oai/client.py:248)
252
+ # 2. Parameter Classification: It's classified as an OpenAI client parameter (not AG2-specific) via the openai_kwargs property (autogen/oai/client.py:752-758)
253
+ # 3. Request Separation: In _separate_create_config() (autogen/oai/client.py:842), extra_body goes into create_config since it's not in the extra_kwargs set.
254
+ # 4. API Call: The create_config becomes params and gets passed directly to OpenAI's create() method via **params (autogen/oai/client.py:551,658)
249
255
  extra_body: Optional[dict[str, Any]] = (
250
256
  None # For VLLM - See here: https://docs.vllm.ai/en/latest/serving/openai_compatible_server.html#extra-parameters
251
257
  )
autogen/oai/gemini.py CHANGED
@@ -126,6 +126,7 @@ class GeminiClient:
126
126
  PARAMS_MAPPING = {
127
127
  "max_tokens": "max_output_tokens",
128
128
  # "n": "candidate_count", # Gemini supports only `n=1`
129
+ "seed": "seed",
129
130
  "stop_sequences": "stop_sequences",
130
131
  "temperature": "temperature",
131
132
  "top_p": "top_p",
autogen/oai/ollama.py CHANGED
@@ -22,6 +22,7 @@ Resources:
22
22
 
23
23
  from __future__ import annotations
24
24
 
25
+ import ast
25
26
  import copy
26
27
  import json
27
28
  import random
@@ -59,6 +60,7 @@ class OllamaLLMConfigEntry(LLMConfigEntry):
59
60
  top_k: int = Field(default=40)
60
61
  top_p: float = Field(default=0.9)
61
62
  hide_tools: Literal["if_all_run", "if_any_run", "never"] = "never"
63
+ native_tool_calls: bool = False
62
64
 
63
65
  def create_client(self):
64
66
  raise NotImplementedError("OllamaLLMConfigEntry.create_client is not implemented.")
@@ -612,7 +614,7 @@ def _object_to_tool_call(data_object: Any) -> list[dict[str, Any]]:
612
614
  is_invalid = False
613
615
  for i, item in enumerate(data_copy):
614
616
  try:
615
- new_item = eval(item)
617
+ new_item = ast.literal_eval(item)
616
618
  if isinstance(new_item, dict):
617
619
  if is_valid_tool_call_item(new_item):
618
620
  data_object[i] = new_item
@@ -467,59 +467,70 @@ def filter_config(
467
467
  filter_dict: Optional[dict[str, Union[list[Union[str, None]], set[Union[str, None]]]]],
468
468
  exclude: bool = False,
469
469
  ) -> list[dict[str, Any]]:
470
- """This function filters `config_list` by checking each configuration dictionary against the criteria specified in
471
- `filter_dict`. A configuration dictionary is retained if for every key in `filter_dict`, see example below.
470
+ """Filter configuration dictionaries based on specified criteria.
471
+
472
+ This function filters a list of configuration dictionaries by applying ALL criteria specified in `filter_dict`.
473
+ A configuration is included in the result if it satisfies every key-value constraint in the filter dictionary.
474
+ For each filter key, the configuration's corresponding field value must match at least one of the acceptable
475
+ values (OR logic within each criteria, AND logic between different criteria).
472
476
 
473
477
  Args:
474
478
  config_list (list of dict): A list of configuration dictionaries to be filtered.
475
- filter_dict (dict): A dictionary representing the filter criteria, where each key is a
476
- field name to check within the configuration dictionaries, and the
477
- corresponding value is a list of acceptable values for that field.
478
- If the configuration's field's value is not a list, then a match occurs
479
- when it is found in the list of acceptable values. If the configuration's
480
- field's value is a list, then a match occurs if there is a non-empty
481
- intersection with the acceptable values.
482
- exclude (bool): If False (the default value), configs that match the filter will be included in the returned
483
- list. If True, configs that match the filter will be excluded in the returned list.
479
+
480
+ filter_dict (dict, optional): A dictionary specifying filter criteria where:
481
+ - Keys are field names to check in each configuration dictionary
482
+ - Values are lists/sets of acceptable values for that field
483
+ - A configuration matches if ALL filter keys are satisfied AND for each key,
484
+ the config's field value matches at least one acceptable value
485
+ - If a filter value includes None, configurations missing that field will match
486
+ - If None, no filtering is applied
487
+
488
+ exclude (bool, optional): If False (default), return configurations that match the filter.
489
+ If True, return configurations that do NOT match the filter.
484
490
 
485
491
  Returns:
486
- list of dict: A list of configuration dictionaries that meet all the criteria specified
487
- in `filter_dict`.
492
+ list of dict: Filtered list of configuration dictionaries.
488
493
 
489
- Example:
494
+ Matching Logic:
495
+ - **Between different filter keys**: AND logic (all criteria must be satisfied)
496
+ - **Within each filter key's values**: OR logic (any acceptable value can match)
497
+ - **For list-type config values**: Match if there's any intersection with acceptable values
498
+ - **For scalar config values**: Match if the value is in the list of acceptable values
499
+ - **Missing fields**: Only match if None is included in the acceptable values for that field
500
+
501
+ Examples:
490
502
  ```python
491
- # Example configuration list with various models and API types
492
503
  configs = [
493
- {"model": "gpt-3.5-turbo"},
494
- {"model": "gpt-4"},
495
- {"model": "gpt-3.5-turbo", "api_type": "azure"},
496
- {"model": "gpt-3.5-turbo", "tags": ["gpt35_turbo", "gpt-35-turbo"]},
504
+ {"model": "gpt-3.5-turbo", "api_type": "openai"},
505
+ {"model": "gpt-4", "api_type": "openai"},
506
+ {"model": "gpt-3.5-turbo", "api_type": "azure", "api_version": "2024-02-01"},
507
+ {"model": "gpt-4", "tags": ["premium", "latest"]},
497
508
  ]
498
- # Define filter criteria to select configurations for the 'gpt-3.5-turbo' model
499
- # that are also using the 'azure' API type
500
- filter_criteria = {
501
- "model": ["gpt-3.5-turbo"], # Only accept configurations for 'gpt-3.5-turbo'
502
- "api_type": ["azure"], # Only accept configurations for 'azure' API type
503
- }
504
- # Apply the filter to the configuration list
505
- filtered_configs = filter_config(configs, filter_criteria)
506
- # The resulting `filtered_configs` will be:
507
- # [{'model': 'gpt-3.5-turbo', 'api_type': 'azure', ...}]
508
- # Define a filter to select a given tag
509
- filter_criteria = {
510
- "tags": ["gpt35_turbo"],
511
- }
512
- # Apply the filter to the configuration list
513
- filtered_configs = filter_config(configs, filter_criteria)
514
- # The resulting `filtered_configs` will be:
515
- # [{'model': 'gpt-3.5-turbo', 'tags': ['gpt35_turbo', 'gpt-35-turbo']}]
509
+
510
+ # Example 1: Single criterion - matches any model in the list
511
+ filter_dict = {"model": ["gpt-4", "gpt-4o"]}
512
+ result = filter_config(configs, filter_dict)
513
+ # Returns: [{"model": "gpt-4", "api_type": "openai"}, {"model": "gpt-4", "tags": ["premium", "latest"]}]
514
+
515
+ # Example 2: Multiple criteria - must satisfy ALL conditions
516
+ filter_dict = {"model": ["gpt-3.5-turbo"], "api_type": ["azure"]}
517
+ result = filter_config(configs, filter_dict)
518
+ # Returns: [{"model": "gpt-3.5-turbo", "api_type": "azure", "api_version": "2024-02-01"}]
519
+
520
+ # Example 3: Tag filtering with list intersection
521
+ filter_dict = {"tags": ["premium"]}
522
+ result = filter_config(configs, filter_dict)
523
+ # Returns: [{"model": "gpt-4", "tags": ["premium", "latest"]}]
524
+
525
+ # Example 4: Exclude matching configurations
526
+ filter_dict = {"api_type": ["openai"]}
527
+ result = filter_config(configs, filter_dict, exclude=True)
528
+ # Returns configs that do NOT have api_type="openai"
516
529
  ```
517
530
  Note:
518
531
  - If `filter_dict` is empty or None, no filtering is applied and `config_list` is returned as is.
519
532
  - If a configuration dictionary in `config_list` does not contain a key specified in `filter_dict`,
520
533
  it is considered a non-match and is excluded from the result.
521
- - If the list of acceptable values for a key in `filter_dict` includes None, then configuration
522
- dictionaries that do not have that key will also be considered a match.
523
534
 
524
535
  """
525
536
  if inspect.stack()[1].function != "where":
@@ -538,18 +549,73 @@ def filter_config(
538
549
  return config_list
539
550
 
540
551
 
541
- def _satisfies_criteria(value: Any, criteria_values: Any) -> bool:
542
- if value is None:
552
+ def _satisfies_criteria(config_value: Any, criteria_values: Any) -> bool:
553
+ """Check if a configuration field value satisfies the filter criteria.
554
+
555
+ This helper function implements the matching logic between a single configuration
556
+ field value and the acceptable values specified in the filter criteria. It handles
557
+ both scalar and list-type configuration values with appropriate matching strategies.
558
+
559
+ Args:
560
+ config_value (Any): The value from a configuration dictionary field.
561
+ Can be None, a scalar value, or a list of values.
562
+ criteria_values (Any): The acceptable values from the filter dictionary.
563
+ Can be a single value or a list/set of acceptable values.
564
+
565
+ Returns:
566
+ bool: True if the config_value satisfies the criteria, False otherwise.
567
+
568
+ Matching Logic:
569
+ - **None config values**: Always return False (missing fields don't match)
570
+ - **List config values**:
571
+ - If criteria is a list: Match if there's any intersection (set overlap)
572
+ - If criteria is scalar: Match if the scalar is contained in the config list
573
+ - **Scalar config values**:
574
+ - If criteria is a list: Match if the config value is in the criteria list
575
+ - If criteria is scalar: Match if the values are exactly equal
576
+
577
+ Examples:
578
+ ```python
579
+ # List config value with list criteria (intersection matching)
580
+ _satisfies_criteria(["gpt-4", "gpt-3.5"], ["gpt-4", "claude"]) # True (gpt-4 intersects)
581
+ _satisfies_criteria(["tag1", "tag2"], ["tag3", "tag4"]) # False (no intersection)
582
+
583
+ # List config value with scalar criteria (containment matching)
584
+ _satisfies_criteria(["premium", "latest"], "premium") # True (premium is in list)
585
+ _satisfies_criteria(["tag1", "tag2"], "tag3") # False (tag3 not in list)
586
+
587
+ # Scalar config value with list criteria (membership matching)
588
+ _satisfies_criteria("gpt-4", ["gpt-4", "gpt-3.5"]) # True (gpt-4 in criteria)
589
+ _satisfies_criteria("claude", ["gpt-4", "gpt-3.5"]) # False (claude not in criteria)
590
+
591
+ # Scalar config value with scalar criteria (equality matching)
592
+ _satisfies_criteria("openai", "openai") # True (exact match)
593
+ _satisfies_criteria("openai", "azure") # False (different values)
594
+
595
+ # None config values (missing fields)
596
+ _satisfies_criteria(None, ["gpt-4"]) # False (missing field)
597
+ _satisfies_criteria(None, "gpt-4") # False (missing field)
598
+ ```
599
+
600
+ Note:
601
+ This is an internal helper function used by `filter_config()`. The function
602
+ assumes that both parameters can be of various types and handles type
603
+ checking internally to determine the appropriate matching strategy.
604
+ """
605
+ if config_value is None:
543
606
  return False
544
607
 
545
- if isinstance(value, list):
546
- return bool(set(value) & set(criteria_values)) # Non-empty intersection
608
+ if isinstance(config_value, list):
609
+ if isinstance(criteria_values, list):
610
+ return bool(set(config_value) & set(criteria_values)) # Non-empty intersection
611
+ else:
612
+ return criteria_values in config_value
547
613
  else:
548
614
  # In filter_dict, filter could be either a list of values or a single value.
549
615
  # For example, filter_dict = {"model": ["gpt-3.5-turbo"]} or {"model": "gpt-3.5-turbo"}
550
616
  if isinstance(criteria_values, list):
551
- return value in criteria_values
552
- return bool(value == criteria_values)
617
+ return config_value in criteria_values
618
+ return bool(config_value == criteria_values)
553
619
 
554
620
 
555
621
  @export_module("autogen")
@@ -620,8 +686,6 @@ def config_list_from_json(
620
686
  with open(config_list_path) as json_file:
621
687
  config_list = json.load(json_file)
622
688
 
623
- config_list = filter_config(config_list, filter_dict)
624
-
625
689
  return filter_config(config_list, filter_dict)
626
690
 
627
691
 
autogen/tools/tool.py CHANGED
@@ -96,8 +96,7 @@ class Tool:
96
96
  """
97
97
  if self._func_schema:
98
98
  agent.update_tool_signature(self._func_schema, is_remove=False)
99
- else:
100
- agent.register_for_llm()(self)
99
+ agent.register_for_llm()(self)
101
100
 
102
101
  def register_for_execution(self, agent: "ConversableAgent") -> None:
103
102
  """Registers the tool for direct execution by a ConversableAgent.
autogen/version.py CHANGED
@@ -4,4 +4,4 @@
4
4
 
5
5
  __all__ = ["__version__"]
6
6
 
7
- __version__ = "0.9.6"
7
+ __version__ = "0.9.7"
File without changes