aixtools 0.1.4__py3-none-any.whl → 0.1.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (50) hide show
  1. aixtools/_version.py +2 -2
  2. aixtools/a2a/app.py +1 -1
  3. aixtools/a2a/google_sdk/__init__.py +0 -0
  4. aixtools/a2a/google_sdk/card.py +27 -0
  5. aixtools/a2a/google_sdk/pydantic_ai_adapter/agent_executor.py +199 -0
  6. aixtools/a2a/google_sdk/pydantic_ai_adapter/storage.py +26 -0
  7. aixtools/a2a/google_sdk/remote_agent_connection.py +88 -0
  8. aixtools/a2a/google_sdk/utils.py +59 -0
  9. aixtools/agents/prompt.py +97 -0
  10. aixtools/context.py +5 -0
  11. aixtools/google/client.py +25 -0
  12. aixtools/logging/logging_config.py +45 -0
  13. aixtools/mcp/client.py +274 -0
  14. aixtools/server/utils.py +3 -3
  15. aixtools/utils/config.py +13 -0
  16. aixtools/utils/files.py +17 -0
  17. aixtools/utils/utils.py +7 -0
  18. aixtools/vault/__init__.py +7 -0
  19. aixtools/vault/vault.py +73 -0
  20. aixtools-0.1.6.dist-info/METADATA +668 -0
  21. {aixtools-0.1.4.dist-info → aixtools-0.1.6.dist-info}/RECORD +48 -13
  22. {aixtools-0.1.4.dist-info → aixtools-0.1.6.dist-info}/top_level.txt +1 -0
  23. scripts/test.sh +23 -0
  24. tests/__init__.py +0 -0
  25. tests/unit/__init__.py +0 -0
  26. tests/unit/a2a/__init__.py +0 -0
  27. tests/unit/a2a/google_sdk/__init__.py +0 -0
  28. tests/unit/a2a/google_sdk/pydantic_ai_adapter/__init__.py +0 -0
  29. tests/unit/a2a/google_sdk/pydantic_ai_adapter/test_agent_executor.py +188 -0
  30. tests/unit/a2a/google_sdk/pydantic_ai_adapter/test_storage.py +156 -0
  31. tests/unit/a2a/google_sdk/test_card.py +114 -0
  32. tests/unit/a2a/google_sdk/test_remote_agent_connection.py +413 -0
  33. tests/unit/a2a/google_sdk/test_utils.py +208 -0
  34. tests/unit/agents/__init__.py +0 -0
  35. tests/unit/agents/test_prompt.py +363 -0
  36. tests/unit/google/__init__.py +1 -0
  37. tests/unit/google/test_client.py +233 -0
  38. tests/unit/mcp/__init__.py +0 -0
  39. tests/unit/mcp/test_client.py +242 -0
  40. tests/unit/server/__init__.py +0 -0
  41. tests/unit/server/test_path.py +225 -0
  42. tests/unit/server/test_utils.py +362 -0
  43. tests/unit/utils/__init__.py +0 -0
  44. tests/unit/utils/test_files.py +146 -0
  45. tests/unit/vault/__init__.py +0 -0
  46. tests/unit/vault/test_vault.py +114 -0
  47. aixtools/a2a/__init__.py +0 -5
  48. aixtools-0.1.4.dist-info/METADATA +0 -355
  49. {aixtools-0.1.4.dist-info → aixtools-0.1.6.dist-info}/WHEEL +0 -0
  50. {aixtools-0.1.4.dist-info → aixtools-0.1.6.dist-info}/entry_points.txt +0 -0
@@ -1,355 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: aixtools
3
- Version: 0.1.4
4
- Summary: Tools for AI exploration and debugging
5
- Requires-Python: >=3.11.2
6
- Description-Content-Type: text/markdown
7
- Requires-Dist: chainlit>=2.5.5
8
- Requires-Dist: colorlog>=6.9.0
9
- Requires-Dist: fasta2a>=0.5.0
10
- Requires-Dist: fastmcp>=2.10.2
11
- Requires-Dist: ipykernel>=6.29.5
12
- Requires-Dist: langchain-chroma>=0.2.3
13
- Requires-Dist: langchain-ollama>=0.3.2
14
- Requires-Dist: langchain-openai>=0.3.14
15
- Requires-Dist: mcp>=1.11.0
16
- Requires-Dist: pandas>=2.2.3
17
- Requires-Dist: pydantic-ai>=0.4.10
18
- Requires-Dist: pylint>=3.3.7
19
- Requires-Dist: rich>=14.0.0
20
- Requires-Dist: ruff>=0.11.6
21
- Requires-Dist: streamlit>=1.44.1
22
- Requires-Dist: watchdog>=6.0.0
23
- Provides-Extra: test
24
- Requires-Dist: pyyaml; extra == "test"
25
- Provides-Extra: feature
26
- Requires-Dist: logfire; extra == "feature"
27
-
28
- # AiXplore-tools
29
-
30
- AiXplore-tools (`axitools` for short) is a Python library to support AI agent development and debugging. It serves two main purposes:
31
-
32
- 1. **Utility Library**: A collection of utility functions and classes for agent projects
33
- 2. **Debugging Tool**: A Streamlit app (`log_view`) for visualizing and debugging agent applications by viewing messages logged by `ObjectLogger`
34
-
35
-
36
- ## `.venv`
37
-
38
- ```
39
- # Create a new environment
40
- uv venv .venv
41
- source .venv/bin/activate
42
-
43
- # Add packages
44
- uv add pydantic-ai
45
- uv add mcp[cli]
46
- uv add chainlit
47
- uv add streamlit
48
-
49
- # Add langchain
50
- uv add langchain-chroma
51
- uv add langchain-ollama
52
- uv add langchain-openai
53
-
54
- # Other packages
55
- uv add colorlog
56
- uv add pandas
57
- uv add rich
58
- uv add ruff
59
- uv add watchdog
60
- uv add ipykernel
61
-
62
- # Install this code as a package
63
- uv pip install -e .
64
- ```
65
-
66
- ## Installation
67
-
68
- Installing the package from GitHub, you can use `uv add` (prefered)
69
- ```
70
- uv add https://github.com/your-org/aixtools.git
71
- ```
72
-
73
- or using the `pip` commamnd
74
- ```
75
- uv pip install https://github.com/your-org/aixtools.git
76
- ```
77
-
78
- Remember to set up your [`.env` file](#environment-configuration).
79
-
80
- ### Updating
81
-
82
- This package is in active development and changes often.
83
-
84
- You'll want to force uv to re-install or update it to the latest commit, even if the version hasn’t changed.
85
-
86
- ```
87
- uv add --upgrade https://github.com/your-org/aixtools.git
88
- ```
89
-
90
- ### Example: Creatng a new project
91
-
92
- ```
93
- # Create a new project
94
- uv init MyNewProject
95
- cd MyNewProject
96
-
97
- # Add a virtual environemnt and activate it
98
- uv venv .venv
99
- source .venv/bin/activate
100
-
101
- # Add this package
102
- uv add https://github.com/your-org/aixtools.git
103
- ```
104
-
105
- ### Environment Configuration
106
-
107
- AIXtools requires specific environment variables to be set for proper operation, especially when working with different model providers.
108
-
109
- Here is a [template of an `.env`](./.env_template) file you can use as reference.
110
-
111
- #### Setting Up Environment Variables
112
-
113
- 1. Create a `.env` file in your project root based on the template below:
114
-
115
- ```
116
- # Model family (azure, openai, or ollama)
117
- MODEL_FAMILY=azure
118
- VDB_EMBEDDINGS_MODEL_FAMILY=azure
119
-
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
- AZURE_OPENAI_PROVIDER_ID=azure
128
- AZURE_VDB_EMBEDDINGS_MODEL_NAME=text-embedding-3-small
129
-
130
- # OpenAI
131
- OPENAI_MODEL_NAME=gpt-4.5-preview
132
- OPENAI_API_KEY=openai_api_key
133
- OPENAI_VDB_EMBEDDINGS_MODEL_NAME=text-embedding-3-small
134
-
135
- # Ollama models
136
- OLLAMA_MODEL_NAME=llama3.2:3b-instruct-fp16
137
- OLLAMA_LOCAL_URL=http://localhost:11434/v1
138
- OLLAMA_VDB_EMBEDDINGS_MODEL_NAME=snowflake-arctic-embed2:latest
139
- ```
140
-
141
- 2. Configure the variables according to your needs:
142
- - Set `MODEL_FAMILY` to your preferred model provider (`azure`, `openai`, or `ollama`)
143
- - Provide the appropriate API keys and endpoints for your chosen provider
144
- - Adjust model names and timeouts as needed
145
-
146
- #### Important Environment Variables
147
-
148
- | Variable | Description | Required |
149
- |----------|-------------|----------|
150
- | `MODEL_FAMILY` | The model provider to use (azure, openai, ollama) | Yes |
151
- | `MODEL_TIMEOUT` | Timeout in seconds for model requests | Yes |
152
- | `AZURE_*` | Azure OpenAI configuration (if using Azure) | If MODEL_FAMILY=azure |
153
- | `OPENAI_*` | OpenAI configuration (if using OpenAI) | If MODEL_FAMILY=openai |
154
- | `OLLAMA_*` | Ollama configuration (if using Ollama) | If MODEL_FAMILY=ollama |
155
-
156
- ## Debugging tools: `log_view` and `ObjectLogger`
157
-
158
- The `ObjectLogger` provides a simple logging facility, these logs can then be visualized with `log_view` app.
159
-
160
-
161
- ### `ObjectLogger`
162
-
163
- The `ObjectLogger` class allows you to log objects to a file for later analysis. This is particularly useful for debugging agent interactions.
164
-
165
- `ObjectLogger` simply serializes objects to a pickle file. It first removes unserializeable parts of the objects (e.g. like `async` managers).
166
-
167
- #### Basic Usage
168
-
169
- ```python
170
- from aixtools.utils.log_objects import ObjectLogger
171
-
172
- # Create a logger as a context manager
173
- with ObjectLogger() as logger:
174
- # Log any pickleable object
175
- logger.log({"message": "Hello, world!"})
176
-
177
- # Log agent responses or any other objects
178
- logger.log(agent_response)
179
- ```
180
-
181
- #### Logging Agent Interactions
182
-
183
- The function `run_agent` logs each node from the agent run, roughtly it looks like this:
184
-
185
- ```python
186
- async def run_agent(agent: Agent, prompt: str | list[str]):
187
- nodes = []
188
- async with agent.iter(prompt) as agent_run:
189
- with ObjectLogger(debug=debug) as agent_logger:
190
- async for node in agent_run:
191
- agent_logger.log(node)
192
- nodes.append(node)
193
- result = agent_run.result
194
- return result.data, nodes
195
- ```
196
-
197
- #### Saving Multiple Objects
198
-
199
- ```python
200
- from aixtools.utils.log_objects import save_objects_to_logfile
201
-
202
- # Save a list of objects to a log file
203
- objects = [obj1, obj2, obj3]
204
- save_objects_to_logfile(objects)
205
- ```
206
-
207
- ### log_view App
208
-
209
- The `log_view` app allows you to visualize and analyze the objects logged by `ObjectLogger`.
210
-
211
- It is a simple Streamlit app that you can run locally and view the log files.
212
-
213
- #### Running the App
214
-
215
- You can run the app using the command-line script installed with the package:
216
-
217
- ```bash
218
- log_view
219
- ```
220
-
221
- Or specify a custom log directory:
222
-
223
- ```bash
224
- log_view /path/to/logs
225
- ```
226
-
227
- #### Features
228
-
229
- The log_view app provides several features for analyzing logged objects:
230
-
231
- - **Log File Selection**: Choose from available log files
232
- - **Filtering**: Filter nodes by text, type, attributes, or regex patterns
233
- - **Visualization**: Expand/collapse nodes to view details
234
- - **Export**: Export filtered nodes to JSON
235
-
236
- #### Example Workflow
237
-
238
- 1. Log agent interactions using `ObjectLogger`
239
- 2. Run the `log_view` app to analyze the logs
240
- 3. Filter and explore the logged objects
241
- 4. Export interesting findings for further analysis
242
-
243
- ## Additional Utilities
244
-
245
- AIXtools provides several other utilities to support agent development:
246
-
247
- ### PersistedDict
248
-
249
- A dictionary that persists to a file on disk as JSON or pickle:
250
-
251
- ```python
252
- from aixtools.utils.persisted_dict import PersistedDict
253
-
254
- # Create a persisted dictionary
255
- data = PersistedDict("data.json")
256
-
257
- # Use it like a regular dictionary
258
- data["key"] = "value" # Automatically saved to disk
259
- ```
260
-
261
- ## Agent Utilities
262
-
263
- Functions for creating and running agents with different model providers:
264
-
265
- ```python
266
- from aixtools.agents.agent import get_agent, run_agent
267
-
268
- # Create an agent with the default model (from MODEL_FAMILY)
269
- agent = get_agent(system_prompt="You are a helpful assistant.")
270
-
271
- # Create an agent with a specific model
272
- from aixtools.agents.agent import get_model_openai
273
- model = get_model_openai()
274
- agent = get_agent(system_prompt="You are a helpful assistant.", model=model)
275
-
276
- # Run the agent
277
- result, nodes = await run_agent(agent, "Tell me about AI")
278
- ```
279
-
280
- ### Batch Processing
281
-
282
- Run multiple agent queries simultaneously:
283
-
284
- ```python
285
- from aixtools.agents.agent_batch import agent_batch, AgentQueryParams
286
-
287
- # Create query parameters
288
- query_parameters = [
289
- AgentQueryParams(prompt="What is the meaning of life"),
290
- AgentQueryParams(prompt="Who is the prime minister of Canada")
291
- ]
292
-
293
- # Run queries in batches
294
- async for result in agent_batch(query_parameters):
295
- print(result)
296
- ```
297
-
298
- ## Project Structure
299
-
300
- ```
301
- aixtools/
302
- ├── __init__.py # Package initialization
303
- ├── log_view.py # Entry point for log_view app
304
- ├── agents/ # Agent-related functionality
305
- │ ├── agent.py # Core agent functions
306
- │ └── agent_batch.py # Batch processing for agents
307
- ├── log_view/ # Log viewer application
308
- │ ├── app.py # Main Streamlit application
309
- │ ├── display.py # Node display utilities
310
- │ ├── export.py # Export functionality
311
- │ ├── filters.py # Node filtering
312
- │ ├── log_utils.py # Log file utilities
313
- │ └── node_utils.py # Node processing utilities
314
- └── utils/ # Utility functions and classes
315
- ├── config.py # Configuration utilities
316
- ├── log_objects.py # Object logging functionality
317
- ├── persisted_dict.py # Persistent dictionary
318
- └── utils.py # General utilities
319
-
320
- ## Logging
321
-
322
- The logging system is configured using a standard Python `dictConfig` schema. By default, it will look for a `logging.yaml` or `logging.json` file in your project's root directory. You can also specify a custom path using the `LOGGING_CONFIG_PATH` environment variable.
323
-
324
- If no configuration file is found, a default colorized console logger will be used.
325
-
326
- ### Example `logging.yaml`
327
-
328
- ```yaml
329
- version: 1
330
- disable_existing_loggers: false
331
- formatters:
332
- default:
333
- format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
334
- color:
335
- "()": "colorlog.ColoredFormatter"
336
- "format": "%(log_color)s%(levelname)-8s%(reset)s [%(name)s] %(message)s"
337
- handlers:
338
- console:
339
- class: colorlog.StreamHandler
340
- formatter: color
341
- level: DEBUG
342
- file:
343
- class: logging.handlers.RotatingFileHandler
344
- formatter: default
345
- filename: app.log
346
- maxBytes: 10485760 # 10MB
347
- backupCount: 5
348
- level: INFO
349
- root:
350
- handlers: [console, file]
351
- level: DEBUG
352
- loggers:
353
- aixtools:
354
- level: INFO
355
- ```