Overview
The Python AI Builder is an intelligent coding assistant integrated directly into your Airia agents. It helps you write, debug, and optimize Python code with instant, context-aware assistance, eliminating the need to switch tools or search online.Key Capabilities
The Python AI Builder provides four core capabilities to accelerate your Python development:Fix Errors in Your Code
The AI Builder analyzes your code, error messages, and execution logs to identify root causes and suggest precise fixes. It helps with:- Syntax errors and typos
- Runtime exceptions and logic errors
- Type mismatches and validation
- Variable scope and reference problems
- Import and dependency errors
Explain Your Code
Get clear, plain-language explanations of your Python code, its purpose, and structure. It explains:- Overall code purpose and workflow
- Individual function and class behavior
- Complex algorithms and logic patterns
- Data transformations and processing
- Library usage and best practices
Optimize Performance
Improve your code’s speed and memory usage with AI-driven optimization suggestions. It optimizes:- Algorithm efficiency and complexity
- Data structure selection
- Loop and iteration patterns
- Memory usage and object creation
- Library and built-in function usage
- Unnecessary operations and redundancy
Add New Features
Extend your code with new functionality while maintaining quality and consistency. It helps build:- Input validation and error handling
- Data processing and transformation logic
- Integration with external libraries
- Conditional logic and business rules
- Output formatting and structure
- Utility functions and helper methods
Feature Availability
Check if the AI Builder is Enabled
The Python AI Builder must be enabled by your administrator. If you do not see the Agentic tab in your Python code blocks, the feature may not be enabled for your organization.Request Access
If the Python AI Builder is not available in your environment:- Contact your Airia administrator. Reach out to the team responsible for managing your Airia platform settings.
- Explain your use case. Share how the AI Builder would benefit your work, such as:
- Faster development and debugging
- Improved code quality and optimization
- Easier onboarding and learning
- Reduced time spent searching for solutions
- Reference this documentation. Direct your administrator to this guide.
- Ask about enablement. Your administrator can enable the Python AI Builder through the platform settings.
For Administrators: Enable Python AI Builder
How to Enable Python AI Builder (Admin Guide)
How to Enable Python AI Builder (Admin Guide)
To enable the Python AI Builder for your users:
- Navigate to Settings in your Airia platform.
- Look for Components > Build with AI
- Find the “Python Code Block Vibe Experience” setting.
- Toggle it ON to enable the feature.
Access the Python AI Builder
Once enabled, the Python AI Builder is integrated directly into Python code blocks in your Agent Studio:- Create or open a Python code block in your agent.
- Look for and click the Agentic tab next to the code editor.
- The Python Coding Assistant interface will open, ready for you to start chatting.
Use the Python Coding Assistant
Quick Start with Action Cards
When you open the Python AI Builder, you’ll see four action cards:- Fix errors in my code: Resolve bugs and errors.
- Explain this code: Understand your code’s functionality.
- Optimize performance: Improve efficiency and speed.
- Add a new feature: Extend functionality.
Natural Conversation
You can ask the AI Builder questions about your Python code using natural language. The assistant maintains conversation context, allowing for back-and-forth discussions to refine solutions. Example questions:- “Why is this loop running so slowly?”
- “How can I handle the case where the input is empty?”
- “Add error handling for API timeouts.”
- “What does this function return when
xis negative?” - “Make this code more readable.”
- “How do I parse JSON from this string?”
Code Context Awareness
The Python AI Builder automatically understands:- Your current code: The exact Python code in your editor.
- Execution results: Output from recent test runs.
- Error messages: Full stack traces and error details.
- Debug logs: Any logging output from your code.
- Available variables: Input data and context variables accessible in your code.
Apply Code Changes
When the AI Builder suggests code changes:- Review the suggestion. The assistant explains what changed and why.
- Code updates automatically. Suggested code appears in your editor in real-time.
- Test the changes. Click Run Code to execute and verify.
- Iterate if needed. Continue the conversation to refine or adjust.
Execute and Test Your Code
Run Your Code
Test your Python code directly within the editor using the Run Code button. Your code executes in a secure, isolated environment with access to:- Input data: Output from the previous agent step, available as the
inputvariable. - User context: Information about the current user, roles, and permissions.
- Previous results: Data from earlier steps in your agent.
- Custom variables: Any variables configured in your agent.
Understand Output
After execution, view results in the tabbed output panel:- Output: Standard output from your code (e.g., what
print()displays). - Debug Logs: Detailed logging for troubleshooting.
- Stack Trace: Error details if execution failed.
- Return Code: Execution status (
0for success, non-zero for errors).
Set Output Variables
Your Python code must assign its final result to theoutput variable:
output variable becomes available to subsequent steps in your agent.
Code Version History
Every time you or the AI Builder modifies the code, a new version is saved. You can access version history to:- View all changes over time.
- See attribution for each change (you or the AI).
- Restore previous versions if needed.
Best Practices
- Be Specific in Your Requests: Provide detailed context.
- ❌ “Fix this”
- ✅ “Fix the
TypeErroron line 15 wheninputisNone.”
- Test Frequently: Run your code after each significant change to verify suggestions, catch errors early, and provide up-to-date execution context.
- Iterate and Refine: Ask follow-up questions to explore alternatives or clarify solutions.
- “Can you explain that approach differently?”
- “What are the trade-offs with this solution?”
- “Is there a simpler way to do this?”
- Review AI Suggestions: Always review suggested code to ensure it meets requirements, handles edge cases, follows coding standards, and is fully understood.
Common Use Cases
Debug Data Transformation Errors
Scenario: Your code processes JSON data but fails with certain input formats. Approach:- Run your code with the problematic input.
- Open the AI Builder and click Fix errors in my code.
- The assistant analyzes the error and suggests input validation.
- Test the fix with various inputs.
Understand Inherited Code
Scenario: You’ve taken over a agent with complex Python logic you didn’t write. Approach:- Open the Python code block.
- Ask the AI Builder to Explain this code.
- Request clarification on specific sections or functions.
- Ask, “What would happen if
inputis empty?” to understand edge case handling.
Improve Slow agent Steps
Scenario: A Python step takes too long to process large datasets. Approach:- Click Optimize performance in the AI Builder.
- Review suggested optimizations (e.g., using list comprehensions, better data structures).
- Apply changes and test with your typical data volume.
- Compare execution times before and after.
Add Input Validation
Scenario: Your code crashes when users provide unexpected input. Approach:- Ask the AI Builder to Add input validation for required fields.
- Specify validation rules (type checking, range validation, etc.).
- The assistant adds validation logic and error handling.
- Test with various valid and invalid inputs.
