Add custom Python logic to your agent with pre-installed libraries. The Python Code Block lets you process data, integrate with external services, perform calculations, and implement custom business logic within your agent’s workflow.Documentation Index
Fetch the complete documentation index at: https://explore.airia.com/llms.txt
Use this file to discover all available pages before exploring further.
Adding a Python Code Block
Navigate to your agent’s workflow editor- Drag the Python Code Block from the components panel
- Connect it to your desired step in the workflow
- Use the code editor to implement your custom logic
Access the available variables
Access the available variables
Available Variables:
- input (str): Input from previous steps.
- client_data (dict): Contains user context with the following keys:
- user_id (str): The user’s unique identifier.
- user_name (str): The user’s display name.
- conversation_id (str): The conversation’s unique identifier.
- user_input (str): The user’s input text.
- user_roles (list[str]): The user’s roles.
- user_groups (list[str]): The user’s groups.
- images (list[str]): An array of image URLs.
- additional_info (list[Any]): An array of objects containing additional information passed to the agent.
- step_inputs (list[Any]): The inputs for the current step.
- files (list[str]): The files associated with the request.
- parsed_files (list[dict]): Parsed file content from the Intelligent Parser (available when Include Parsed Files is enabled). Each entry contains:
- file_id (str): Blob storage identifier.
- name (str): Original file name.
- content (str): Parsed text output (markdown or structured content).
- content_type (str): MIME type of the original file.
- variables (dict[str, str]): Custom variables configured in the agent.
- execution_parameters (dict): Contains the following keys:
- execution_id (str): The unique identifier for the execution.
- step_results_by_type (dict): A dictionary containing the results of the previous steps, ordered by completion, with the following keys:
- model (list[Any]): The results of the model steps.
- data_source (list[Any]): The results of the data search steps.
- memory_load (list[Any]): The results of the memory load steps.
- memory_store (list[Any]): The results of the memory store steps.
- python (list[Any]): The results of the python steps.
- router (list[Any]): The results of the router steps.
- tool_action (list[Any]): The results of the tool action steps.
- agent (list[Any]): The results of the agent steps.
Accessing Parsed File Content
Python code blocks can access the content of files processed by the Intelligent Parser earlier in your agent pipeline. This allows you to programmatically manipulate, transform, or extract data from uploaded documents (PDFs, spreadsheets, etc.) directly in Python, without routing them through an LLM step.Enable Include Parsed Files
The feature is opt-in because file payloads can be large. To enable it:- Open your Python code block in the Agent Studio.
- Toggle “Include Parsed Files” in the code block toolbar.
Access Parsed Files in Your Code
When enabled, parsed file content is available inclient_data["parsed_files"] as a list of objects. Each entry contains:
| Field | Description | Example |
|---|---|---|
name | Original file name | "report.pdf" |
content | Parsed text output (markdown or structured content) | "# Report\n\nData..." |
file_id | Blob storage identifier | "a1b2c3d4-e5f6-7890-abcd-ef1234567890" |
content_type | MIME type of the original file | "application/pdf" |
Example: Extract and Process Parsed Documents
Parsed Files vs. LLM Step Attachments
If your pipeline also uses LLM steps with the Include Attachments option, here is how the two approaches compare:| Python Code Block (Include Parsed Files) | LLM Step (Include Attachments) | |
|---|---|---|
| Content delivery | Full content in a single entry per file | Chunked into ~8 KB pieces |
| Processing | Programmatic (your Python code) | Model-driven (prompt-based) |
| Best for | Data extraction, transformation, filtering | Summarization, Q&A, analysis |
Access the available libraries
Access the available libraries
airia==0.1.39aiohappyeyeballs==2.6.1aiohttp==3.13.4aiosignal==1.4.0annotated-types==0.7.0anyio==4.12.1asgiref==3.8.1asn1crypto==1.5.1atpublic==7.0.0attrs==25.3.0azure-ai-vision-imageanalysis==1.0.0azure-core==1.38.0azure-cli==2.83.0azure-identity==1.25.1azure-storage-blob==12.28.0b1azure-keyvault==4.2.0beautifulsoup4==4.13.4boto3==1.42.30botocore==1.42.30Brotli==1.2.0cachetools==7.0.0certifi==2025.4.26cffi==2.0.0charset-normalizer==3.4.1click==8.1.8cloudpickle==3.0.0cmdstanpy==1.3.0contourpy==1.3.2cryptography==46.0.7cycler==0.12.1Cython==3.0.12dataclasses-json==0.6.7decorator==5.2.1defusedxml==0.7.1Deprecated==1.3.1distro==1.9.0duckdb==1.4.4dnspython==2.7.0email_validator==2.2.0et_xmlfile==2.0.0fastapi==0.129.0fastapi-cli==0.0.20filelock==3.20.3filetype==1.2.0fonttools==4.61.0frozendict==2.4.6frozenlist==1.6.0gevent==25.4.2geventhttpclient==2.3.3googleapis-common-protos==1.70.0google-api-python-client==2.189.0greenlet==3.2.1grpcio==1.71.0gurobipy==12.0.2h11==0.16.0holidays==0.71html5lib==1.1httpcore==1.0.9httptools==0.7.1httpx==0.28.1idna==3.11imageio==2.37.2imageio-ffmpeg==0.6.0importlib_metadata==8.6.1importlib_resources==6.5.2iniconfig==2.1.0isodate==0.7.2Jinja2==3.1.6jiter==0.12.0jmespath==1.0.1joblib==1.5.3json_repair==0.43.0jsonpatch==1.33jsonpointer==3.0.0kiwisolver==1.4.8langchain-core==1.2.28langchain-openai==1.0.2langchain-text-splitters==1.0.0langsmith==0.7.31lxml==6.1.0markdown-it-py==4.0.0MarkupSafe==3.0.2marshmallow==3.26.2matplotlib==3.10.1mdurl==0.1.2moviepy @ git+https://github.com/Zulko/moviepy@c5b2423 # pinned to commit with Pillow 11.2+ supportmultidict==6.4.3multitasking==0.0.12mypy_extensions==1.1.0nltk==3.9.4numpy==1.26.4docxtpl==0.20.2openai==2.7.1opencv-python==4.11.0.86opencv-python-headless==4.11.0.86openpyxl==3.1.5opentelemetry-api==1.39.1opentelemetry-exporter-otlp==1.39.1opentelemetry-exporter-otlp-proto-common==1.39.1opentelemetry-exporter-otlp-proto-grpc==1.39.1opentelemetry-exporter-otlp-proto-http==1.39.1opentelemetry-instrumentation==0.60b1opentelemetry-instrumentation-asgi==0.60b1opentelemetry-instrumentation-fastapi==0.60b1opentelemetry-proto==1.39.1opentelemetry-sdk==1.39.1opentelemetry-semantic-conventions==0.60b1opentelemetry-util-http==0.60b1orjson==3.11.7packaging==24.2pandas==2.2.3pdf2image==1.17.0peewee==3.18.2pgeocode==0.5.0pillow==12.2.0pillow-avif-plugin==1.5.2pip-upgrade==0.0.6platformdirs==4.5.1playwright==1.58.0pluggy==1.5.0proglog==0.1.11prometheus_client==0.21.1propcache==0.3.1prophet==1.1.6protobuf==6.33.5psycopg2-binary==2.9.11pybase64==1.4.2pycparser==2.22pydantic==2.11.3pydantic-settings==2.9.1pydantic_core==2.33.1pyee==13.0.0Pygments==2.20.0PyJWT==2.12.0PyMuPDF==1.27.1pymupdf4llm==0.3.4PyMySQL==1.1.2pyodbc==5.3.0pyOpenSSL==26.0.0pyparsing==3.3.1pytesseract==0.3.13pytest==9.0.3pytest-asyncio==1.3.0python-dateutil==2.9.0.post0python-docx==1.1.2python-docx-replace==0.4.4python-dotenv==1.2.2python-multipart==0.0.26python-pptx==1.0.2python-rapidjson==1.20pytz==2025.2PyYAML==6.0.2regex==2025.10.23requests==2.33.0requests-toolbelt==1.0.0rich==14.3.3rich-toolkit==0.14.8s3transfer==0.16.0scipy==1.15.2shellingham==1.5.4simple-salesforce==1.12.6slack-sdk==3.35.0six==1.17.0sniffio==1.3.1snowflake-connector-python==4.4.0snowflake-snowpark-python==1.45.0snowflake.core==1.4.0sortedcontainers==2.4.0soupsieve==2.8.3SQLAlchemy==2.0.40stanio==0.5.1starlette==0.52.1tenacity==9.1.2tomlkit==0.13.2tqdm==4.67.1tritonclient==2.56.0typer==0.21.1typing-inspect==0.9.0typing-inspection==0.4.2typing_extensions==4.13.2tzdata==2025.3tzlocal==5.3.1ujson==5.12.0urllib3==2.6.3uvicorn==0.34.2uvloop==0.21.0watchfiles==1.0.5weaviate-client==4.16.9webencodings==0.5.1websockets==15.0.1wrapt==1.17.2XlsxWriter==3.2.9yarl==1.22.0yfinance==0.2.57youtube-transcript-api==1.0.3zipp==3.23.0zope.event==6.1zope.interface==7.2zstandard==0.23.0
