aixtools 0.1.1__py3-none-any.whl → 0.1.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.

Potentially problematic release.


This version of aixtools might be problematic. Click here for more details.

aixtools/_version.py CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.1.1'
32
- __version_tuple__ = version_tuple = (0, 1, 1)
31
+ __version__ = version = '0.1.3'
32
+ __version_tuple__ = version_tuple = (0, 1, 3)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -5,7 +5,7 @@ Batch processing functionality for running multiple agent queries in parallel.
5
5
  import asyncio
6
6
  from typing import Any
7
7
 
8
- from pydantic import BaseModel
8
+ from pydantic import BaseModel, ConfigDict
9
9
 
10
10
  from aixtools.agents.agent import get_agent, run_agent
11
11
 
@@ -13,10 +13,7 @@ from aixtools.agents.agent import get_agent, run_agent
13
13
  class AgentQueryParams(BaseModel):
14
14
  """Parameters for configuring agent queries in batch processing."""
15
15
 
16
- class Config: # pylint: disable=too-few-public-methods
17
- """Configuration for the model."""
18
-
19
- arbitrary_types_allowed = True
16
+ model_config = ConfigDict(arbitrary_types_allowed=True)
20
17
 
21
18
  id: str = "" # Unique identifier for the query
22
19
  prompt: str | list[str]
@@ -48,11 +48,11 @@ class Config:
48
48
  """Global configuration for the faulty MCP server."""
49
49
 
50
50
  port: int = 9999
51
- prob_throw_in_list_handle: float = 0.5 # Probability of throwing an exception in list tools handling
52
- prob_delete_404: float = 0.5 # Probability of injecting a 404 error for DELETE requests
53
- prob_general_404: float = 0.5 # Probability of injecting a 404 error for other requests
54
- prob_terminate_on_empty_request: float = 0.3 # Probability of terminating the process on empty request
55
- prob_terminate_in_list_handle: float = 0.3 # Probability of terminating the process in list tools handling
51
+ prob_on_post_404: float = 0.5 # Probability of injecting a 404 error for POST requests
52
+ prob_on_get_crash: float = 0.3 # Probability of terminating the process on GET request
53
+ prob_on_delete_404: float = 0.5 # Probability of injecting a 404 error for DELETE requests
54
+ prob_in_list_tools_throw: float = 0.5 # Probability of throwing an exception in list tools handling
55
+ prob_in_list_tools_crash: float = 0.3 # Probability of terminating the process in list tools handling
56
56
 
57
57
 
58
58
  # Global configuration
@@ -69,11 +69,11 @@ class McpErrorMiddleware(McpMiddleware):
69
69
  if context.method == "tools/list":
70
70
  random_number = random()
71
71
  logger.info("[McpErrorMiddleware] random number: %f", random_number)
72
- if random_number < config.prob_terminate_in_list_handle:
72
+ if random_number < config.prob_in_list_tools_crash:
73
73
  logger.warning("[McpErrorMiddleware] Simulating server crash!")
74
74
  os.kill(os.getpid(), 9)
75
75
 
76
- if random_number < config.prob_throw_in_list_handle:
76
+ if random_number < config.prob_in_list_tools_throw:
77
77
  exception_class = choice(
78
78
  [
79
79
  ValidationError,
@@ -102,11 +102,11 @@ class StarletteErrorMiddleware: # pylint: disable=too-few-public-methods
102
102
  self.app = app
103
103
  logger.info("[StarletteErrorMiddleware] Middleware initialized!")
104
104
  logger.info("Current configuration:")
105
- logger.info("Exception in list tools handling probability: %f", config.prob_throw_in_list_handle)
106
- logger.info("DELETE 404 probability: %f", config.prob_delete_404)
107
- logger.info("General 404 probability: %f", config.prob_general_404)
108
- logger.info("Terminate on empty request probability: %f", config.prob_terminate_on_empty_request)
109
- logger.info("Terminate in list handle probability: %f", config.prob_terminate_in_list_handle)
105
+ logger.info("HTTP 404 on POST request probability: %f", config.prob_on_post_404)
106
+ logger.info("Terminate on GET request probability: %f", config.prob_on_get_crash)
107
+ logger.info("HTTP 404 on DELETE request probability: %f", config.prob_on_delete_404)
108
+ logger.info("Exception in list tools handling probability: %f", config.prob_in_list_tools_throw)
109
+ logger.info("Terminate in list handle probability: %f", config.prob_in_list_tools_crash)
110
110
 
111
111
  async def __call__(self, scope: Scope, receive: Receive, send: Send): # noqa: PLR0915 # pylint: disable=too-many-statements
112
112
  # Log all the condition variables for debugging
@@ -124,23 +124,22 @@ class StarletteErrorMiddleware: # pylint: disable=too-few-public-methods
124
124
  if http_method == "DELETE":
125
125
  random_number = random()
126
126
  logger.info("[StarletteErrorMiddleware] random number: %f", random_number)
127
- if random_number < config.prob_delete_404:
128
- logger.info("[StarletteErrorMiddleware] Simulating 404 error for DELETE request")
127
+ if random_number < config.prob_on_delete_404:
128
+ logger.info("[StarletteErrorMiddleware] Simulating 404 error on DELETE request")
129
129
  should_inject_404 = True
130
130
 
131
+ if http_method == "GET":
132
+ random_number = random()
133
+ logger.info("[StarletteErrorMiddleware] random number: %f", random_number)
134
+ if random_number < config.prob_on_get_crash:
135
+ logger.warning("[StarletteErrorMiddleware] Simulating server crash on GET request!")
136
+ os.kill(os.getpid(), 9)
137
+
131
138
  async def logging_receive():
132
139
  nonlocal should_inject_404
133
140
  message = await receive()
134
141
  logger.info("[StarletteErrorMiddleware] Received message: %s", str(message))
135
142
 
136
- # Check for empty request and possibly terminate the process
137
- if message["type"] == "http.request" and message["body"] == b"" and not message.get("more_body", False):
138
- random_number = random()
139
- logger.info("[StarletteErrorMiddleware] Empty request received, random number: %f", random_number)
140
- if random_number < config.prob_terminate_on_empty_request:
141
- logger.warning("[StarletteErrorMiddleware] Simulating server crash on empty request!")
142
- os.kill(os.getpid(), 9)
143
-
144
143
  if message["type"] == "http.request": # pylint: disable=too-many-nested-blocks
145
144
  body = message.get("body", b"")
146
145
  if body:
@@ -165,7 +164,7 @@ class StarletteErrorMiddleware: # pylint: disable=too-few-public-methods
165
164
  # Check if we should inject 404
166
165
  random_number = random()
167
166
  logger.info("[StarletteErrorMiddleware] random number: %f", random_number)
168
- if random_number < config.prob_general_404:
167
+ if random_number < config.prob_on_post_404:
169
168
  should_inject_404 = True
170
169
  logger.info("[StarletteErrorMiddleware] %s - will inject 404!", method_name)
171
170
  except (UnicodeDecodeError, json.JSONDecodeError) as e:
@@ -275,29 +274,29 @@ if __name__ == "__main__":
275
274
  help=f"Port to run the server on (default: {config.port})",
276
275
  )
277
276
  parser.add_argument(
278
- "--prob-throw-in-list-handle",
277
+ "--prob-on-post-404",
279
278
  type=float,
280
- help=f"Probability of exception in list tools handling (default: {config.prob_throw_in_list_handle})",
279
+ help=f"Probability of injecting a 404 error for POST requests (default: {config.prob_on_post_404})",
281
280
  )
282
281
  parser.add_argument(
283
- "--prob-delete-404",
282
+ "--prob-on-get-crash",
284
283
  type=float,
285
- help=f"Probability of injecting a 404 error for DELETE requests (default: {config.prob_delete_404})",
284
+ help=f"Probability of terminating on GET request (default: {config.prob_on_get_crash})",
286
285
  )
287
286
  parser.add_argument(
288
- "--prob-general-404",
287
+ "--prob-on-delete-404",
289
288
  type=float,
290
- help=f"Probability of injecting a 404 error for other requests (default: {config.prob_general_404})",
289
+ help=f"Probability of injecting a 404 error for DELETE requests (default: {config.prob_on_delete_404})",
291
290
  )
292
291
  parser.add_argument(
293
- "--prob-terminate-on-empty-request",
292
+ "--prob-in-list-tools-throw",
294
293
  type=float,
295
- help=f"Probability of terminating on empty request (default: {config.prob_terminate_on_empty_request})",
294
+ help=f"Probability of exception in list tools handling (default: {config.prob_in_list_tools_throw})",
296
295
  )
297
296
  parser.add_argument(
298
- "--prob-terminate-in-list-handle",
297
+ "--prob-in-list-tools-crash",
299
298
  type=float,
300
- help=f"Probability of terminating in list tools handling (default: {config.prob_terminate_in_list_handle})",
299
+ help=f"Probability of terminating in list tools handling (default: {config.prob_in_list_tools_crash})",
301
300
  )
302
301
 
303
302
  args = parser.parse_args()
@@ -310,11 +309,11 @@ if __name__ == "__main__":
310
309
 
311
310
  # Update the global configuration with command line arguments
312
311
  config.port = args.port or config.port
313
- _update_config_value("prob_throw_in_list_handle")
314
- _update_config_value("prob_delete_404")
315
- _update_config_value("prob_general_404")
316
- _update_config_value("prob_terminate_on_empty_request")
317
- _update_config_value("prob_terminate_in_list_handle")
312
+ _update_config_value("prob_on_post_404")
313
+ _update_config_value("prob_on_get_crash")
314
+ _update_config_value("prob_on_delete_404")
315
+ _update_config_value("prob_in_list_tools_throw")
316
+ _update_config_value("prob_in_list_tools_crash")
318
317
 
319
318
  # Run the server
320
319
  run_server_on_port()
@@ -1,6 +1,6 @@
1
1
  from typing import Any
2
2
 
3
- from pydantic import BaseModel
3
+ from pydantic import BaseModel, ConfigDict
4
4
 
5
5
  from aixtools.logging.logging_config import get_logger
6
6
 
@@ -19,8 +19,7 @@ class ModelRawRequestResult(BaseModel):
19
19
  request_id: str # Unique request ID
20
20
  result: Any # Method's result
21
21
 
22
- class Config:
23
- arbitrary_types_allowed = True
22
+ model_config = ConfigDict(arbitrary_types_allowed=True)
24
23
 
25
24
 
26
25
  class ModelRawRequestYieldItem(BaseModel):
@@ -29,8 +28,7 @@ class ModelRawRequestYieldItem(BaseModel):
29
28
  item_num: int # Item number in the stream
30
29
  item: Any # Yielded item
31
30
 
32
- class Config:
33
- arbitrary_types_allowed = True
31
+ model_config = ConfigDict(arbitrary_types_allowed=True)
34
32
 
35
33
 
36
34
  def get_request_fn(model):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aixtools
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: Tools for AI exploration and debugging
5
5
  Requires-Python: >=3.11.2
6
6
  Description-Content-Type: text/markdown
@@ -1,5 +1,5 @@
1
1
  aixtools/__init__.py,sha256=9NGHm7LjsQmsvjTZvw6QFJexSvAU4bCoN_KBk9SCa00,260
2
- aixtools/_version.py,sha256=m8HxkqoKGw_wAJtc4ZokpJKNLXqp4zwnNhbnfDtro7w,704
2
+ aixtools/_version.py,sha256=q5nF98G8SoVeJqaknL0xdyxtv0egsqb0fK06_84Izu8,704
3
3
  aixtools/app.py,sha256=JzQ0nrv_bjDQokllIlGHOV0HEb-V8N6k_nGQH-TEsVU,5227
4
4
  aixtools/chainlit.md,sha256=yC37Ly57vjKyiIvK4oUvf4DYxZCwH7iocTlx7bLeGLU,761
5
5
  aixtools/context.py,sha256=XuvSGjG8f-QHBJlI_yCPdjYo4rm_WrswmUE8GjLoRqI,491
@@ -22,7 +22,7 @@ aixtools/a2a/app.py,sha256=VQAKJHYJJr5-qJRLXvRgc2pZtH_SPXvB293nJaEDXTw,5071
22
22
  aixtools/a2a/utils.py,sha256=EHr3IyyBJn23ni-JcfAf6i3VpQmPs0g1TSnAZazvY_8,4039
23
23
  aixtools/agents/__init__.py,sha256=MAW196S2_G7uGqv-VNjvlOETRfuV44WlU1leO7SiR0A,282
24
24
  aixtools/agents/agent.py,sha256=E1zu70t53RqIbcLI_R09wUtsiYZR1bTnElCQ5PrsrKw,6127
25
- aixtools/agents/agent_batch.py,sha256=QHRXh7X1VdzLX9JcgIIvU06E46orhv3R7uJyj9TfIlo,2322
25
+ aixtools/agents/agent_batch.py,sha256=0Zu9yNCRPAQZPjXQ-dIUAmP1uGTVbxVt7xvnMpoJMjU,2251
26
26
  aixtools/db/__init__.py,sha256=b8vRhme3egV-aUZbAntnOaDkSXB8UT0Xy5oqQhU_z0Q,399
27
27
  aixtools/db/database.py,sha256=caWe95GlxZYlxn2ubDmR-_cQUW0ulkpR3BHunKIaOsw,3369
28
28
  aixtools/db/vector_db.py,sha256=be4JGyXj3o8VEfy9L6SO1aAoDET_zazMJkYfjlYHTYQ,4133
@@ -46,8 +46,8 @@ aixtools/mcp/__init__.py,sha256=tLo2KZ1Ojo-rgEEJBGtZfUw-iOoopWoHDnYQTq3IzfE,163
46
46
  aixtools/mcp/example_client.py,sha256=QCFGP3NCNJMOKWjUOnFwjnbJhUSb879IA1ZYmwjRnmc,889
47
47
  aixtools/mcp/example_server.py,sha256=1SWCyrLWsAnOa81HC4QbPJo_lBVu0b3SZBWI-qDh1vQ,458
48
48
  aixtools/mcp/fast_mcp_log.py,sha256=XYOS406dVjn5YTHyGRsRvVNQ0SKlRObfrKj6EeLFjHg,1057
49
- aixtools/mcp/faulty_mcp.py,sha256=7wPjw0w0eSKpwuqkIYIRCD9iSGGb5IDQpCgcpMOLBmg,13044
50
- aixtools/model_patch/model_patch.py,sha256=My1BHp9pIdnEdJ_yXNnwCgrLRJ04g9CDG7-HUfC4IjY,1795
49
+ aixtools/mcp/faulty_mcp.py,sha256=IzayVeElQZRw-sw_QwOwHHh2PuK2T9NKikEi_tt8SPU,12759
50
+ aixtools/model_patch/model_patch.py,sha256=JT-oHubIn2LeoSwWbzEQ5vLH7crJmFUecHyQfaAFHa0,1813
51
51
  aixtools/server/__init__.py,sha256=rwPx020YpOzCnrxA80Lc4yLLcIp-Mpe9hNqVO9wDPv0,448
52
52
  aixtools/server/app_mounter.py,sha256=0tJ0tC140ezAjnYdlhpLJQjY-TO8NVw7D8LseYCCVY8,3336
53
53
  aixtools/server/path.py,sha256=SaIJxvmhJy3kzx5zJ6d4cKP6kKu2wFFciQkOLGTA4gg,3056
@@ -78,8 +78,8 @@ scripts/log_view.sh,sha256=bp8oXFRRbbHpyvHAN85wfDHTVK7vMJOYsBx_-bgECQc,511
78
78
  scripts/run_example_mcp_server.sh,sha256=f7m7h7O_wo6-nAsYlOXVWIASCOh3Qbuu0XWizlxMhl8,355
79
79
  scripts/run_faulty_mcp_server.sh,sha256=u_-8NbPDnJQt6IinNSjh8tc2ed-_MjGyipJXrUXaGR8,291
80
80
  scripts/run_server.sh,sha256=5iiB9bB5M2MuOgxVQqu7Oa_tBVtJpt0uB4z9uLu2J50,720
81
- aixtools-0.1.1.dist-info/METADATA,sha256=nuPN9YtQDx4QOYIGC4flAoG-rt4j0o4faWr9Zmsl__4,10109
82
- aixtools-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
83
- aixtools-0.1.1.dist-info/entry_points.txt,sha256=dHoutULEZx7xXSqJrZdViSVjfInJibfLibi2nRXL3SE,56
84
- aixtools-0.1.1.dist-info/top_level.txt,sha256=IPyw70hj9gVDyugaIr3LRlanLYXzostW4azlTgdlALo,34
85
- aixtools-0.1.1.dist-info/RECORD,,
81
+ aixtools-0.1.3.dist-info/METADATA,sha256=EjMCZ1tNjNpNF95J0h08jI3Rb19Phe9-fDei7S1Syg0,10109
82
+ aixtools-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
83
+ aixtools-0.1.3.dist-info/entry_points.txt,sha256=dHoutULEZx7xXSqJrZdViSVjfInJibfLibi2nRXL3SE,56
84
+ aixtools-0.1.3.dist-info/top_level.txt,sha256=IPyw70hj9gVDyugaIr3LRlanLYXzostW4azlTgdlALo,34
85
+ aixtools-0.1.3.dist-info/RECORD,,