NazareAI - Python Programmer 3B - Version 1
Overview
NazareAI is redefining the workforce with its Autonomous AI Workforce solution—tackling scalability, cost, and efficiency challenges in one fell swoop. This demo spotlights the Python Programmer AI, a specialized agent engineered to deliver expert-level coding solutions, technical architecture guidance, and implementation best practices for Python-based projects.
NarazeAI AI Workforce: https://seedgularity.com/nazareai-ai-workforce/
Need system prompt? You can download it from here: https://github.com/seedgularity/NazareAI-Python-Programmer-3B
Features
- Technical Expertise
Draws from comprehensive knowledge of Python programming, design patterns, and software architecture principles. - Intelligent Code Generation
Produces clean, efficient, and well-documented code that follows best practices and industry standards. - Problem-Solving Capability
Analyzes requirements and provides optimal technical solutions while considering performance and scalability.
Use Cases
- Application Development
Build complete Python applications with proper structure, error handling, and documentation. - Code Optimization
Analyze existing code and recommend improvements for better performance and maintainability. - API Development
Design and implement RESTful APIs using modern Python frameworks like FastAPI or Flask. - Technical Documentation
Generate comprehensive documentation including API specs, setup guides, and code documentation.
Response Format
NazareAI Python Programmer provides two types of responses:
Default Mode: Provides detailed explanations along with the code, including:
- Problem analysis
- Solution approach
- Code explanation
- Implementation considerations
- Best practices and recommendations
- Usage examples
Code-Only Mode: When users add
[CODE ONLY]
at the end of their prompt, it provides:- Clean, production-ready code without explanations
- Necessary comments and docstrings
- Complete implementation focused on the requested functionality
Example Interactions
Default Mode
User: Create a function to calculate Fibonacci numbers recursively
AI: To create a recursive function for calculating Fibonacci numbers, we need to understand that the sequence is defined as:
- F(0) = 0
- F(1) = 1
- For n > 1, F(n) = F(n-1) + F(n-2)
Below is a Python implementation of such a function:
```python
def fibonacci_recursive(n):
"""
Calculate the nth Fibonacci number recursively.
Args:
n (int): The index of the Fibonacci sequence (0-indexed).
Returns:
int: The nth Fibonacci number.
Raises:
ValueError: If n is negative or not an integer.
"""
# Error handling for invalid input
if not isinstance(n, int):
raise TypeError("Input must be an integer.")
if n < 0:
raise ValueError("Input must be a non-negative integer.")
# Base cases
if n == 0:
return 0
elif n == 1:
return 1
# Recursive case
return fibonacci_recursive(n - 1) + fibonacci_recursive(n - 2)
# Example usage with error handling
if __name__ == "__main__":
try:
print(fibonacci_recursive(10)) # Output: 55 (Fibonacci number at index 10)
print(fibonacci_recursive(-5)) # Raises ValueError
except Exception as e:
print("Error:", e)
### Key Technical Notes:
1. **Recursion**: This implementation uses the recursive definition of Fibonacci numbers to calculate each term by adding two preceding terms.
2. **Time Complexity**: The time complexity for calculating `fibonacci_recursive` is exponential, O(2^n), due to its recursive nature and constant space used per
call (`O(n)`). For large inputs, this can lead to performance issues.
3. **Space Complexity**: Space usage is also linear in terms of recursion depth (since each function call has a stack frame).
4. **Memoization or Iteration**: To improve efficiency, consider using memoization or an iterative approach like the "Matrix Exponentiation" method which would
reduce time complexity to O(log n) and space complexity to O(1). Here’s how you could implement it iteratively:
```python
def fibonacci_iterative(n):
if not isinstance(n, int):
raise TypeError("Input must be an integer.")
if n < 0:
raise ValueError("Input must be a non-negative integer.")
# Initialize variables to store previous two Fibonacci numbers
prev1, prev2 = 0, 1
for _ in range(2, n + 1):
curr = prev1 + prev2
prev1 = prev2
prev2 = curr
return curr
# Example usage with error handling remains unchanged.
This iterative approach is more efficient and suitable for larger inputs while retaining the same functionality as your recursive implementation.
Code-Only Mode
User: Create a function to calculate Fibonacci numbers recursively [CODE ONLY]
AI:
```python
def fibonacci_recursive(n):
if not isinstance(n, int):
raise TypeError("Input must be an integer.")
if n < 0:
raise ValueError("Input must be a non-negative integer.")
# Base cases
if n == 0:
return 0
elif n == 1:
return 1
# Recursive case
return fibonacci_recursive(n - 1) + fibonacci_recursive(n - 2)
- Downloads last month
- 157
Model tree for seedgularity/NazareAI-Python-Programmer-3B
Base model
meta-llama/Llama-3.2-3B-Instruct