aixtools 0.0.0__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.

Files changed (88) hide show
  1. aixtools/.chainlit/config.toml +113 -0
  2. aixtools/.chainlit/translations/bn.json +214 -0
  3. aixtools/.chainlit/translations/en-US.json +214 -0
  4. aixtools/.chainlit/translations/gu.json +214 -0
  5. aixtools/.chainlit/translations/he-IL.json +214 -0
  6. aixtools/.chainlit/translations/hi.json +214 -0
  7. aixtools/.chainlit/translations/ja.json +214 -0
  8. aixtools/.chainlit/translations/kn.json +214 -0
  9. aixtools/.chainlit/translations/ml.json +214 -0
  10. aixtools/.chainlit/translations/mr.json +214 -0
  11. aixtools/.chainlit/translations/nl.json +214 -0
  12. aixtools/.chainlit/translations/ta.json +214 -0
  13. aixtools/.chainlit/translations/te.json +214 -0
  14. aixtools/.chainlit/translations/zh-CN.json +214 -0
  15. aixtools/__init__.py +11 -0
  16. aixtools/_version.py +34 -0
  17. aixtools/a2a/app.py +126 -0
  18. aixtools/a2a/google_sdk/__init__.py +0 -0
  19. aixtools/a2a/google_sdk/card.py +27 -0
  20. aixtools/a2a/google_sdk/pydantic_ai_adapter/agent_executor.py +199 -0
  21. aixtools/a2a/google_sdk/pydantic_ai_adapter/storage.py +26 -0
  22. aixtools/a2a/google_sdk/remote_agent_connection.py +88 -0
  23. aixtools/a2a/google_sdk/utils.py +59 -0
  24. aixtools/a2a/utils.py +115 -0
  25. aixtools/agents/__init__.py +12 -0
  26. aixtools/agents/agent.py +164 -0
  27. aixtools/agents/agent_batch.py +71 -0
  28. aixtools/agents/prompt.py +97 -0
  29. aixtools/app.py +143 -0
  30. aixtools/chainlit.md +14 -0
  31. aixtools/compliance/__init__.py +9 -0
  32. aixtools/compliance/private_data.py +138 -0
  33. aixtools/context.py +17 -0
  34. aixtools/db/__init__.py +17 -0
  35. aixtools/db/database.py +110 -0
  36. aixtools/db/vector_db.py +115 -0
  37. aixtools/google/client.py +25 -0
  38. aixtools/log_view/__init__.py +17 -0
  39. aixtools/log_view/app.py +195 -0
  40. aixtools/log_view/display.py +285 -0
  41. aixtools/log_view/export.py +51 -0
  42. aixtools/log_view/filters.py +41 -0
  43. aixtools/log_view/log_utils.py +26 -0
  44. aixtools/log_view/node_summary.py +229 -0
  45. aixtools/logfilters/__init__.py +7 -0
  46. aixtools/logfilters/context_filter.py +67 -0
  47. aixtools/logging/__init__.py +30 -0
  48. aixtools/logging/log_objects.py +227 -0
  49. aixtools/logging/logging_config.py +161 -0
  50. aixtools/logging/mcp_log_models.py +102 -0
  51. aixtools/logging/mcp_logger.py +172 -0
  52. aixtools/logging/model_patch_logging.py +87 -0
  53. aixtools/logging/open_telemetry.py +36 -0
  54. aixtools/mcp/__init__.py +9 -0
  55. aixtools/mcp/client.py +375 -0
  56. aixtools/mcp/example_client.py +30 -0
  57. aixtools/mcp/example_server.py +22 -0
  58. aixtools/mcp/fast_mcp_log.py +31 -0
  59. aixtools/mcp/faulty_mcp.py +319 -0
  60. aixtools/model_patch/model_patch.py +63 -0
  61. aixtools/server/__init__.py +29 -0
  62. aixtools/server/app_mounter.py +90 -0
  63. aixtools/server/path.py +72 -0
  64. aixtools/server/utils.py +70 -0
  65. aixtools/server/workspace_privacy.py +65 -0
  66. aixtools/testing/__init__.py +9 -0
  67. aixtools/testing/aix_test_model.py +149 -0
  68. aixtools/testing/mock_tool.py +66 -0
  69. aixtools/testing/model_patch_cache.py +279 -0
  70. aixtools/tools/doctor/__init__.py +3 -0
  71. aixtools/tools/doctor/tool_doctor.py +61 -0
  72. aixtools/tools/doctor/tool_recommendation.py +44 -0
  73. aixtools/utils/__init__.py +35 -0
  74. aixtools/utils/chainlit/cl_agent_show.py +82 -0
  75. aixtools/utils/chainlit/cl_utils.py +168 -0
  76. aixtools/utils/config.py +131 -0
  77. aixtools/utils/config_util.py +69 -0
  78. aixtools/utils/enum_with_description.py +37 -0
  79. aixtools/utils/files.py +17 -0
  80. aixtools/utils/persisted_dict.py +99 -0
  81. aixtools/utils/utils.py +167 -0
  82. aixtools/vault/__init__.py +7 -0
  83. aixtools/vault/vault.py +137 -0
  84. aixtools-0.0.0.dist-info/METADATA +669 -0
  85. aixtools-0.0.0.dist-info/RECORD +88 -0
  86. aixtools-0.0.0.dist-info/WHEEL +5 -0
  87. aixtools-0.0.0.dist-info/entry_points.txt +2 -0
  88. aixtools-0.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,669 @@
1
+ Metadata-Version: 2.4
2
+ Name: aixtools
3
+ Version: 0.0.0
4
+ Summary: Tools for AI exploration and debugging
5
+ Requires-Python: >=3.11.2
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: a2a-sdk>=0.3.1
8
+ Requires-Dist: cachebox>=5.0.1
9
+ Requires-Dist: chainlit>=2.5.5
10
+ Requires-Dist: colorlog>=6.9.0
11
+ Requires-Dist: fasta2a>=0.5.0
12
+ Requires-Dist: fastmcp>=2.10.2
13
+ Requires-Dist: hvac>=2.3.0
14
+ Requires-Dist: ipykernel>=6.29.5
15
+ Requires-Dist: langchain-chroma>=0.2.3
16
+ Requires-Dist: langchain-ollama>=0.3.2
17
+ Requires-Dist: langchain-openai>=0.3.14
18
+ Requires-Dist: mcp>=1.11.0
19
+ Requires-Dist: mypy>=1.18.2
20
+ Requires-Dist: pandas>=2.2.3
21
+ Requires-Dist: pydantic-ai>=0.4.10
22
+ Requires-Dist: pylint>=3.3.7
23
+ Requires-Dist: rich>=14.0.0
24
+ Requires-Dist: ruff>=0.11.6
25
+ Requires-Dist: streamlit>=1.44.1
26
+ Requires-Dist: watchdog>=6.0.0
27
+ Provides-Extra: test
28
+ Requires-Dist: pyyaml; extra == "test"
29
+ Provides-Extra: feature
30
+ Requires-Dist: logfire; extra == "feature"
31
+
32
+ # AIXtools
33
+
34
+ AIXtools is a comprehensive Python library for AI agent development, debugging, and deployment. It provides a complete toolkit for building, testing, and monitoring AI agents with support for multiple model providers, advanced logging, and agent-to-agent communication.
35
+
36
+ ## Capabilities
37
+
38
+ Agents
39
+ - Agent Development & Management - `aixtools/agents/`
40
+ - Agent Batch Processing - `aixtools/agents/agent_batch.py`
41
+ - Agent Prompting System - `aixtools/agents/prompt.py`
42
+
43
+ A2A
44
+ - Agent-to-Agent Communication (A2A) - `aixtools/a2a/`
45
+ - Google SDK Integration for A2A - `aixtools/a2a/google_sdk/`
46
+ - PydanticAI Adapter for Google SDK - `aixtools/a2a/google_sdk/pydantic_ai_adapter/`
47
+
48
+ Databases
49
+ - Database Integration - `aixtools/db/`
50
+ - Vector Database Support - `aixtools/db/vector_db.py`
51
+
52
+ Logging & Debugging
53
+ - Log Viewing Application - `aixtools/log_view/`
54
+ - Object Logging System - `aixtools/logging/`
55
+ - Model Patch Logging - `aixtools/logging/model_patch_logging.py`
56
+ - Log Filtering System - `aixtools/logfilters/`
57
+ - FastMCP Logging - `aixtools/mcp/fast_mcp_log.py`
58
+ - Command Line Interface for Log Viewing - Entry point: `log_view`
59
+ - MCP (Model Context Protocol) Support - `aixtools/logging/mcp_log_models.py`, `aixtools/logging/mcp_logger.py`
60
+
61
+ Testing & Tools
62
+ - Testing Utilities - `aixtools/testing/`
63
+ - Mock Tool System - `aixtools/testing/mock_tool.py`
64
+ - Model Patch Caching - `aixtools/testing/model_patch_cache.py`
65
+ - Tool Doctor System - `aixtools/tools/doctor/`
66
+ - Tool Recommendation Engine - `aixtools/tools/doctor/tool_recommendation.py`
67
+ - FaultyMCP - `aixtools/mcp/faulty_mcp.py`
68
+
69
+ Chainlit & HTTP Server
70
+ - Chainlit Integration - `aixtools/app.py`, `aixtools/chainlit.md`
71
+ - Chainlit Utilities - `aixtools/utils/chainlit/`
72
+ - HTTP Server Framework - `aixtools/server/`
73
+ - App Mounting System - `aixtools/server/app_mounter.py`
74
+
75
+ Programming utils
76
+ - Persisted Dictionary - `aixtools/utils/persisted_dict.py`
77
+ - Enum with Description - `aixtools/utils/enum_with_description.py`
78
+ - Context Management - `aixtools/context.py`
79
+ - Configuration Management - `aixtools/utils/config.py`, `aixtools/utils/config_util.py`
80
+ - File Utilities - `aixtools/utils/files.py`
81
+
82
+ ## Installation
83
+
84
+ ### From GitHub
85
+
86
+ ```bash
87
+ uv add aixtools
88
+ ```
89
+
90
+ ### Development Setup
91
+
92
+ ```bash
93
+ # Create a new project
94
+ uv init MyNewProject
95
+ cd MyNewProject
96
+
97
+ # Add virtual environment and activate it
98
+ uv venv .venv
99
+ source .venv/bin/activate
100
+
101
+ # Add this package
102
+ uv add aixtools
103
+ ```
104
+
105
+ ### Updating
106
+
107
+ ```bash
108
+ uv add --upgrade aixtools
109
+ ```
110
+
111
+ ## Environment Configuration
112
+
113
+ AIXtools requires environment variables for model providers.
114
+
115
+ **IMPORTANT:** Create a `.env` file based on [`.env_template`](./.env_template):
116
+
117
+ ```bash
118
+ # Model family (azure, openai, or ollama)
119
+ MODEL_FAMILY=azure
120
+ MODEL_TIMEOUT=120
121
+
122
+ # Azure OpenAI
123
+ AZURE_OPENAI_ENDPOINT=https://your_endpoint.openai.azure.com
124
+ AZURE_OPENAI_API_VERSION=2024-06-01
125
+ AZURE_OPENAI_API_KEY=your_secret_key
126
+ AZURE_MODEL_NAME=gpt-4o
127
+
128
+ # OpenAI
129
+ OPENAI_MODEL_NAME=gpt-4.5-preview
130
+ OPENAI_API_KEY=openai_api_key
131
+
132
+ # Ollama
133
+ OLLAMA_MODEL_NAME=llama3.2:3b-instruct-fp16
134
+ OLLAMA_LOCAL_URL=http://localhost:11434/v1
135
+ ```
136
+
137
+ ## Agents
138
+
139
+ ### Basic Agent Usage
140
+
141
+ ```python
142
+ from aixtools.agents.agent import get_agent, run_agent
143
+
144
+ async def main():
145
+ agent = get_agent(system_prompt="You are a helpful assistant.")
146
+ result, nodes = await run_agent(agent, "Explain quantum computing")
147
+ print(result)
148
+ ```
149
+
150
+ ### Agent Development & Management
151
+
152
+ The agent system provides a unified interface for creating and managing AI agents across different model providers.
153
+
154
+ ```python
155
+ from aixtools.agents.agent import get_agent, run_agent
156
+
157
+ # Create an agent with default model
158
+ agent = get_agent(system_prompt="You are a helpful assistant.")
159
+
160
+ # Run the agent
161
+ result, nodes = await run_agent(agent, "Tell me about AI")
162
+ ```
163
+
164
+ ### Agent Batch Processing
165
+
166
+ Process multiple agent queries simultaneously with built-in concurrency control and result aggregation.
167
+
168
+ ```python
169
+ from aixtools.agents.agent_batch import agent_batch, AgentQueryParams
170
+
171
+ # Create query parameters
172
+ query_parameters = [
173
+ AgentQueryParams(prompt="What is the meaning of life"),
174
+ AgentQueryParams(prompt="Who is the prime minister of Canada")
175
+ ]
176
+
177
+ # Run queries in batches
178
+ async for result in agent_batch(query_parameters):
179
+ print(result)
180
+ ```
181
+
182
+ ## A2A (Agent-to-Agent Communication)
183
+
184
+ The A2A module provides a comprehensive framework for enabling sophisticated communication between AI agents across different environments and platforms. It includes Google SDK integration, PydanticAI adapters, and FastA2A application conversion capabilities.
185
+
186
+ ### Core Features
187
+
188
+ **Agent Application Conversion**
189
+ - Convert PydanticAI agents into FastA2A applications
190
+ - Support for session metadata extraction and context management
191
+ - Custom worker classes with enhanced data part support
192
+ - Automatic handling of user and session identification
193
+
194
+ **Remote Agent Connections**
195
+ - Establish connections between agents across different environments
196
+ - Asynchronous message sending with task polling capabilities
197
+ - Terminal state detection and error handling
198
+ - Support for various message types including text, files, and data
199
+
200
+ **Google SDK Integration**
201
+ - Native integration with Google's A2A SDK
202
+ - Card-based agent representation and discovery
203
+ - PydanticAI adapter for seamless Google SDK compatibility
204
+ - Storage and execution management for agent interactions
205
+
206
+ ### Agent-to-Agent Communication (A2A)
207
+
208
+ Enable sophisticated agent interactions with Google SDK integration and PydanticAI adapters.
209
+
210
+ ```python
211
+ from aixtools.a2a.google_sdk.remote_agent_connection import RemoteAgentConnection
212
+ from aixtools.a2a.app import agent_to_a2a
213
+
214
+ # Convert a PydanticAI agent to FastA2A application
215
+ a2a_app = agent_to_a2a(
216
+ agent=my_agent,
217
+ name="MyAgent",
218
+ description="A helpful AI assistant",
219
+ skills=[{"name": "chat", "description": "General conversation"}]
220
+ )
221
+
222
+ # Connect agents across different environments
223
+ connection = RemoteAgentConnection(card=agent_card, client=a2a_client)
224
+ response = await connection.send_message_with_polling(message)
225
+ ```
226
+
227
+ ## Databases
228
+
229
+ ### Database Integration
230
+
231
+ Support for both traditional and vector databases with seamless integration.
232
+
233
+ ```python
234
+ from aixtools.db.database import Database
235
+ from aixtools.db.vector_db import VectorDB
236
+
237
+ # Traditional database
238
+ db = Database("sqlite:///app.db")
239
+
240
+ # Vector database for embeddings
241
+ vector_db = VectorDB()
242
+ vector_db.add_documents(documents)
243
+ ```
244
+
245
+ ## Logging & Debugging
246
+
247
+ AixTools provides functionality for logging and debugging.
248
+
249
+ ### Basic Logging and Debugging
250
+
251
+ ```python
252
+ from aixtools.agents.agent import get_agent, run_agent
253
+
254
+ async def main():
255
+ # Create an agent
256
+ agent = get_agent(system_prompt="You are a helpful assistant.")
257
+
258
+ # Run agent - logging is automatic via ObjectLogger
259
+ result, nodes = await run_agent(
260
+ agent,
261
+ "Explain quantum computing",
262
+ debug=True, # Enable debug logging
263
+ log_model_requests=True # Log model requests/responses
264
+ )
265
+
266
+ print(f"Result: {result}")
267
+ print(f"Logged {len(nodes)} nodes")
268
+ ```
269
+
270
+ ### Log Viewing Application
271
+
272
+ Interactive Streamlit application for analyzing logged objects and debugging agent behavior.
273
+
274
+ **Features:**
275
+ - Log file selection and filtering
276
+ - Node visualization with expand/collapse
277
+ - Export capabilities to JSON
278
+ - Regex pattern matching
279
+ - Real-time log monitoring
280
+
281
+ ```bash
282
+ # Run the log viewer
283
+ log_view
284
+
285
+ # Or specify custom log directory
286
+ log_view /path/to/logs
287
+ ```
288
+
289
+ ### Object Logging & Debugging
290
+
291
+ Advanced logging system with object serialization and visual debugging tools.
292
+
293
+ ```python
294
+ from aixtools.logging.log_objects import ObjectLogger
295
+
296
+ # Log any pickleable object
297
+ with ObjectLogger() as logger:
298
+ logger.log({"message": "Hello, world!"})
299
+ logger.log(agent_response)
300
+ ```
301
+
302
+ ### MCP Logger
303
+
304
+ This is an MCP server that can log MCP requests and responses.
305
+
306
+ ```python
307
+ from aixtools.mcp.fast_mcp_log import FastMcpLog
308
+
309
+ # Use FastMCP server with logging
310
+ mcp = FastMcpLog("Demo")
311
+ ```
312
+
313
+ ### Model Patching System
314
+
315
+ Dynamic model behavior modification for testing and debugging.
316
+
317
+ ```python
318
+ from aixtools.model_patch.model_patch import ModelPatch
319
+
320
+ # Apply patches to models for testing
321
+ with ModelPatch() as patch:
322
+ patch.apply_response_override("test response")
323
+ result = await agent.run("test prompt")
324
+ ```
325
+
326
+ ### FaultyMCP
327
+
328
+ A specialized MCP server designed for testing error handling and resilience in MCP client implementations. FaultyMCP simulates various failure scenarios including network errors, server crashes, and random exceptions.
329
+
330
+ **Features:**
331
+ - Configurable error probabilities for different request types
332
+ - HTTP 404 error injection for POST/DELETE requests
333
+ - Server crash simulation on GET requests
334
+ - Random exception throwing in tool operations
335
+ - MCP-specific error simulation (ValidationError, ResourceError, etc.)
336
+ - Safe mode for controlled testing
337
+
338
+ ```python
339
+ from aixtools.mcp.faulty_mcp import run_server_on_port, config
340
+
341
+ # Configure error probabilities
342
+ config.prob_on_post_404 = 0.3 # 30% chance of 404 on POST
343
+ config.prob_on_get_crash = 0.1 # 10% chance of crash on GET
344
+ config.prob_in_list_tools_throw = 0.2 # 20% chance of exception in tools/list
345
+
346
+ # Run the faulty server
347
+ run_server_on_port()
348
+ ```
349
+
350
+ **Command Line Usage:**
351
+ ```bash
352
+ # Run with default error probabilities
353
+ python -m aixtools.mcp.faulty_mcp
354
+
355
+ # Run in safe mode (no errors by default)
356
+ python -m aixtools.mcp.faulty_mcp --safe-mode
357
+
358
+ # Custom configuration
359
+ python -m aixtools.mcp.faulty_mcp \
360
+ --port 8888 \
361
+ --prob-on-post-404 0.2 \
362
+ --prob-on-get-crash 0.1 \
363
+ --prob-in-list-tools-throw 0.3
364
+ ```
365
+
366
+ By default, the "FaultyMCP" includes several tools you can use in your tests:
367
+ - `add(a, b)` - Basic addition (reliable)
368
+ - `multiply(a, b)` - Basic multiplication (reliable)
369
+ - `always_error()` - Always throws an exception
370
+ - `random_throw_exception(a, b, prob)` - Randomly throws exceptions
371
+ - `freeze_server(seconds)` - Simulates server freeze
372
+ - `throw_404_exception()` - Throws HTTP 404 error
373
+
374
+ ## Testing & Tools
375
+
376
+ AIXtools provides comprehensive testing utilities and diagnostic tools for AI agent development and debugging.
377
+
378
+ ### Testing Utilities
379
+
380
+ The testing module provides mock tools, model patching, and test utilities for comprehensive agent testing.
381
+
382
+ ```python
383
+ from aixtools.testing.mock_tool import MockTool
384
+ from aixtools.testing.model_patch_cache import ModelPatchCache
385
+ from aixtools.testing.aix_test_model import AixTestModel
386
+
387
+ # Create mock tools for testing
388
+ mock_tool = MockTool(name="test_tool", response="mock response")
389
+
390
+ # Use model patch caching for consistent test results
391
+ cache = ModelPatchCache()
392
+ cached_response = cache.get_cached_response("test_prompt")
393
+
394
+ # Test model for controlled testing scenarios
395
+ test_model = AixTestModel()
396
+ ```
397
+
398
+ ### Tool Doctor System
399
+
400
+ Automated tool analysis and recommendation system for optimizing agent tool usage.
401
+
402
+ ```python
403
+ from aixtools.tools.doctor.tool_doctor import ToolDoctor
404
+ from aixtools.tools.doctor.tool_recommendation import ToolRecommendation
405
+
406
+ # Analyze tool usage patterns
407
+ doctor = ToolDoctor()
408
+ analysis = doctor.analyze_tools(agent_logs)
409
+
410
+ # Get tool recommendations
411
+ recommendation = ToolRecommendation()
412
+ suggestions = recommendation.recommend_tools(agent_context)
413
+ ```
414
+
415
+ ### Mock Tool System
416
+
417
+ Create and manage mock tools for testing agent behavior without external dependencies.
418
+
419
+ ```python
420
+ from aixtools.testing.mock_tool import MockTool
421
+
422
+ # Create a mock tool with predefined responses
423
+ mock_calculator = MockTool(
424
+ name="calculator",
425
+ description="Performs mathematical calculations",
426
+ response_map={
427
+ "2+2": "4",
428
+ "10*5": "50"
429
+ }
430
+ )
431
+
432
+ # Use in agent testing
433
+ agent = get_agent(tools=[mock_calculator])
434
+ result = await run_agent(agent, "What is 2+2?")
435
+ ```
436
+
437
+ ### Model Patch Caching
438
+
439
+ Cache model responses for consistent testing and development workflows.
440
+
441
+ ```python
442
+ from aixtools.testing.model_patch_cache import ModelPatchCache
443
+
444
+ # Initialize cache
445
+ cache = ModelPatchCache(cache_dir="./test_cache")
446
+
447
+ # Cache responses for specific prompts
448
+ cache.cache_response("test prompt", "cached response")
449
+
450
+ # Retrieve cached responses
451
+ response = cache.get_cached_response("test prompt")
452
+ ```
453
+
454
+ ### FaultyMCP Testing Server
455
+
456
+ Specialized MCP server for testing error handling and resilience in MCP implementations.
457
+
458
+ ```python
459
+ from aixtools.mcp.faulty_mcp import run_server_on_port, config
460
+
461
+ # Configure error probabilities for testing
462
+ config.prob_on_post_404 = 0.3 # 30% chance of 404 on POST
463
+ config.prob_on_get_crash = 0.1 # 10% chance of crash on GET
464
+ config.prob_in_list_tools_throw = 0.2 # 20% chance of exception
465
+
466
+ # Run the faulty server for testing
467
+ run_server_on_port(port=8888)
468
+ ```
469
+
470
+ **Available Test Tools:**
471
+ - `add(a, b)` - Reliable addition operation
472
+ - `multiply(a, b)` - Reliable multiplication operation
473
+ - `always_error()` - Always throws an exception
474
+ - `random_throw_exception(a, b, prob)` - Randomly throws exceptions
475
+ - `freeze_server(seconds)` - Simulates server freeze
476
+ - `throw_404_exception()` - Throws HTTP 404 error
477
+
478
+ **Command Line Usage:**
479
+ ```bash
480
+ # Run with default error probabilities
481
+ python -m aixtools.mcp.faulty_mcp
482
+
483
+ # Run in safe mode (no errors)
484
+ python -m aixtools.mcp.faulty_mcp --safe-mode
485
+
486
+ # Custom configuration
487
+ python -m aixtools.mcp.faulty_mcp \
488
+ --port 8888 \
489
+ --prob-on-post-404 0.2 \
490
+ --prob-on-get-crash 0.1
491
+ ```
492
+
493
+ ### Running Tests
494
+
495
+ Execute the test suite using the provided scripts:
496
+
497
+ ```bash
498
+ # Run all tests
499
+ ./scripts/test.sh
500
+
501
+ # Run unit tests only
502
+ ./scripts/test_unit.sh
503
+
504
+ # Run integration tests only
505
+ ./scripts/test_integration.sh
506
+ ```
507
+
508
+ ## Chainlit & HTTP Server
509
+
510
+ ### Chainlit Integration
511
+
512
+ Ready-to-use Chainlit application for interactive agent interfaces.
513
+
514
+ ```python
515
+ # Run the Chainlit app
516
+ # Configuration in aixtools/chainlit.md
517
+ # Main app in aixtools/app.py
518
+ ```
519
+
520
+ ## Programming Utils
521
+
522
+ AIXtools provides essential programming utilities for configuration management, data persistence, file operations, and context handling.
523
+
524
+ ### Persisted Dictionary
525
+
526
+ Persistent key-value storage with automatic serialization and file-based persistence.
527
+
528
+ ```python
529
+ from aixtools.utils.persisted_dict import PersistedDict
530
+
531
+ # Create a persistent dictionary
532
+ cache = PersistedDict("cache.json")
533
+
534
+ # Store and retrieve data
535
+ cache["user_preferences"] = {"theme": "dark", "language": "en"}
536
+ cache["session_data"] = {"last_login": "2024-01-01"}
537
+
538
+ # Data is automatically saved to file
539
+ print(cache["user_preferences"]) # Persists across program restarts
540
+ ```
541
+
542
+ ### Enum with Description
543
+
544
+ Enhanced enum classes with built-in descriptions for better documentation and user interfaces.
545
+
546
+ ```python
547
+ from aixtools.utils.enum_with_description import EnumWithDescription
548
+
549
+ class ModelType(EnumWithDescription):
550
+ GPT4 = ("gpt-4", "OpenAI GPT-4 model")
551
+ CLAUDE = ("claude-3", "Anthropic Claude-3 model")
552
+ LLAMA = ("llama-2", "Meta LLaMA-2 model")
553
+
554
+ # Access enum values and descriptions
555
+ print(ModelType.GPT4.value) # "gpt-4"
556
+ print(ModelType.GPT4.description) # "OpenAI GPT-4 model"
557
+
558
+ # Get all descriptions
559
+ for model in ModelType:
560
+ print(f"{model.value}: {model.description}")
561
+ ```
562
+
563
+ ### Context Management
564
+
565
+ Centralized context management for sharing state across components.
566
+
567
+ ```python
568
+ from aixtools.context import Context
569
+
570
+ # Create and use context
571
+ context = Context()
572
+ context.set("user_id", "12345")
573
+ context.set("session_data", {"preferences": {"theme": "dark"}})
574
+
575
+ # Retrieve context data
576
+ user_id = context.get("user_id")
577
+ session_data = context.get("session_data")
578
+
579
+ # Context can be passed between components
580
+ def process_request(ctx: Context):
581
+ user_id = ctx.get("user_id")
582
+ # Process with user context
583
+ ```
584
+
585
+ ### Configuration Management
586
+
587
+ Robust configuration handling with environment variable support and validation.
588
+
589
+ ```python
590
+ from aixtools.utils.config import Config
591
+ from aixtools.utils.config_util import load_config
592
+
593
+ # Load configuration from environment and files
594
+ config = load_config()
595
+
596
+ # Access configuration values
597
+ model_name = config.get("MODEL_NAME", "gpt-4")
598
+ api_key = config.get("API_KEY")
599
+ timeout = config.get("TIMEOUT", 30, int)
600
+
601
+ # Configuration with validation
602
+ class AppConfig(Config):
603
+ model_name: str = "gpt-4"
604
+ max_tokens: int = 1000
605
+ temperature: float = 0.7
606
+
607
+ app_config = AppConfig()
608
+ ```
609
+
610
+ ### File Utilities
611
+
612
+ Enhanced file operations with Path support and utility functions.
613
+
614
+ ```python
615
+ from aixtools.utils.files import read_file, write_file, ensure_directory
616
+ from pathlib import Path
617
+
618
+ # Read and write files with automatic encoding handling
619
+ content = read_file("data.txt")
620
+ write_file("output.txt", "Hello, world!")
621
+
622
+ # Ensure directories exist
623
+ data_dir = Path("data/logs")
624
+ ensure_directory(data_dir)
625
+
626
+ # Work with file paths
627
+ config_path = Path("config") / "settings.json"
628
+ if config_path.exists():
629
+ config_data = read_file(config_path)
630
+ ```
631
+
632
+ ### Chainlit Utilities
633
+
634
+ Specialized utilities for Chainlit integration and agent display.
635
+
636
+ ```python
637
+ from aixtools.utils.chainlit.cl_agent_show import show_agent_response
638
+ from aixtools.utils.chainlit.cl_utils import format_message
639
+
640
+ # Display agent responses in Chainlit
641
+ await show_agent_response(
642
+ response="Hello, how can I help you?",
643
+ metadata={"model": "gpt-4", "tokens": 150}
644
+ )
645
+
646
+ # Format messages for Chainlit display
647
+ formatted_msg = format_message(
648
+ content="Processing your request...",
649
+ message_type="info"
650
+ )
651
+ ```
652
+
653
+ ### General Utilities
654
+
655
+ Common utility functions for everyday programming tasks.
656
+
657
+ ```python
658
+ from aixtools.utils.utils import safe_json_loads, timestamp_now, hash_string
659
+
660
+ # Safe JSON parsing
661
+ data = safe_json_loads('{"key": "value"}', default={})
662
+
663
+ # Get current timestamp
664
+ now = timestamp_now()
665
+
666
+ # Generate hash for strings
667
+ file_hash = hash_string("content to hash")
668
+ ```
669
+