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